예제 #1
0
 def test_TTF_InitQuit(self):
     sdlttf.TTF_Init()
     sdlttf.TTF_Init()
     sdlttf.TTF_Init()
     sdlttf.TTF_Quit()
     sdlttf.TTF_Quit()
     sdlttf.TTF_Init()
예제 #2
0
    def __init__(self, plantes):
        #initialisation de la sdl
        if SDL_Init(SDL_INIT_VIDEO) < 0:
            print("Problème d'initialisation : " + str(SDL_GetError()))

        #creation de la fenetre
        self.window = SDL_CreateWindow(b"Mon Petit Jardinier",
                                       SDL_WINDOWPOS_CENTERED,
                                       SDL_WINDOWPOS_CENTERED, 600, 600,
                                       SDL_WINDOW_SHOWN)
        if self.window == None:
            print("Erreur lors de la création de la fenêtre.")

        self.windowSurface = SDL_GetWindowSurface(self.window)
        #initialisation de sdl_ttf
        sdlttf.TTF_Init()

        self.plantes = plantes
예제 #3
0
파일: view.py 프로젝트: ruby3141/PyTGM
 def __init__(self, model):
     self.model = model
     sdlttf.TTF_Init()
     self.window = sdl2.ext.Window("PyTGM Alpha", size=self.windowsize)
     self.renderer = sdl2.ext.SoftwareSpriteRenderSystem(self.window)
     self.sfactory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE)
     self.tspr = self.sfactory.from_color(0x00000000,
                                          size=(350, 650),
                                          masks=(0xff000000, 0x00ff0000,
                                                 0x0000ff00, 0x000000ff))
     self.trds = sdl2.ext.Renderer(self.tspr)
     self.trds.blendmode = sdl2.SDL_BLENDMODE_BLEND
     self.tfactory = sdl2.ext.SpriteFactory(sdl2.ext.TEXTURE,
                                            renderer=self.trds)
     self.trds.color = sdl2.ext.Color(255, 255, 255, 0)
     self.trds.clear()
     self.loadtexture()
     self.window.show()
     self.render = self.draw()
예제 #4
0
    def createWindow(self):
        # Create the window context
        if sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) != 0:
            print(sdl2.SDL_GetError())
            return -1
        sdl2ttf.TTF_Init()
        sdl2img.IMG_Init(sdl2img.IMG_INIT_PNG)

        self.window = sdl2.SDL_CreateWindow(self.params["title"].encode(),
                                            sdl2.SDL_WINDOWPOS_UNDEFINED,
                                            sdl2.SDL_WINDOWPOS_UNDEFINED,
                                            self.window_width,
                                            self.window_height,
                                            sdl2.SDL_WINDOW_OPENGL)
        sdl2.SDL_SetWindowBordered(self.window, self.show_borders)
        if not self.window:
            print(sdl2.SDL_GetError())
            return -1

        # Renderer
        self.renderer = sdl2.SDL_CreateRenderer(
            self.window, -1,
            sdl2.SDL_RENDERER_ACCELERATED | sdl2.SDL_RENDERER_PRESENTVSYNC)

        # Build the GUI
        self.buildElements()

        # onStart handler
        if self.onStart is not None:
            if self.onStart[1] is None:
                self.onStart[0]()
            else:
                self.onStart[0](self.onStart[1])

        # look for events
        self._loopForEvents()
예제 #5
0
 def setUpClass(cls):
     SDL_Init(0)
     sdlttf.TTF_Init()
예제 #6
0
        else:
            new_string += char
    return new_string


def search(json_data, sub_key, value):
    for key in json_data.keys():
        if sub_key in json_data[key]:
            if json_data[key][sub_key] == value:
                return key
    return None


if __name__ == "__main__":

    sdlttf.TTF_Init()

    parser = argparse.ArgumentParser(
        description=
        "Finds all media resources and creates an index.json file for regolith to use during runtime."
    )
    parser.add_argument("directories",
                        nargs="+",
                        help="Directories in which to search for resources.")
    parser.add_argument(
        "--file",
        default="./regolith_index.json",
        help=
        "Specify the name of the index file. If the file exists a backup copy will be made."
    )