Exemple #1
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)

    # let's have a background
    background = ImageNode.from_image(0, 0, 'sprites.wallpaper')
    # we want a window to display with a HorizontalContainer
    node1 = GuiImage(Resources.colour_surface(100, 30, (200, 32, 32)))
    node2 = GuiImage(Resources.colour_surface(100, 30, (32, 200, 32)))
    node3 = GuiImage(Resources.colour_surface(100, 30, (32, 32, 200)))
    c1 = VerticalContainer([node1, node2, node3], (214, 214, 214),
                           align_children=Align.TOP)

    node6 = GuiImage(Resources.colour_surface(100, 50, (32, 32, 200)))
    node5 = GuiImage(Resources.colour_surface(100, 50, (32, 200, 32)))
    node4 = GuiImage(Resources.colour_surface(100, 100, (200, 32, 32)))
    c2 = VerticalContainer([node6, node5, node4], (214, 214, 214),
                           align_children=Align.TOP)

    node7 = GuiImage(Resources.colour_surface(100, 30, (200, 32, 32)))
    node8 = GuiImage(Resources.colour_surface(100, 30, (32, 200, 32)))
    node9 = GuiImage(Resources.colour_surface(100, 30, (32, 32, 200)))
    c3 = VerticalContainer([node7, node8, node9], (214, 214, 214),
                           align_children=Align.TOP)

    hcontainer = HorizontalContainer([c1, c2, c3], (214, 214, 214),
                                     align_children=Align.TOP)
    window = Window(hcontainer)

    # add the window to a scene
    scene = Scene([background, window])
    controller.add_scene('start', scene)
    controller.run('start')
Exemple #2
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)

    # let's have a background
    background = ImageNode.from_image(0, 0, 'sprites.wallpaper')

    # a button needs 2 things - the text to display, and the message to send
    button = Button('Close', Message(MessageType.EXIT_GAME))
    bc = VerticalContainer([button], background=(214, 214, 214))
    window = Window(bc, xpos=-1, ypos=-1)

    # add the window to a scene
    scene = Scene([background, window])
    controller.add_scene('start', scene)
    controller.run('start')
Exemple #3
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)

    # let's have a background for a change.
    # a very simple ImageNode will do
    background = ImageNode.from_image(0, 0, 'sprites.wallpaper')
    # this time, we want a window to display
    # but a window must display 'something', so we'll use an ImageNode
    window_contents = GuiImage.from_image('sprites.dog')
    window = Window(window_contents)
    # add the window to a scene
    scene = Scene([background, window])
    # I add the scene to the ENGINE
    controller.add_scene('start', scene)
    # I tell the engine what scene to start and run the controller
    controller.run('start')
Exemple #4
0
def game():
    # start the engine. It needs to know where the resources file is
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)
    # add a sprite. We need a position, and image
    sprite = ImageNode.from_image(100, 100, 'sprites.soldier')

    # we want the unit to flash every second, so add a tween
    # all times are in milliseconds for the engine
    sprite.tween = FlashTween(500)

    # I add the node to a new scene
    scene = Scene([sprite])
    # I add the scene to the engine
    controller.add_scene('start', scene)
    # I tell the engine what scene to start and run the controller
    controller.run('start')
Exemple #5
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)

    # let's have a background
    background = ImageNode.from_image(0, 0, 'sprites.wallpaper')
    # we want a window to display with a VerticalContainer
    node1 = GuiImage.from_image('sprites.dog')
    node2 = GuiImage.from_image('sprites.pattern')
    container = VerticalContainer([node2, node1, node2], (214, 214, 214))
    window = Window(container)
    # add the window to a scene
    scene = Scene([background, window])
    # I add the scene to the ENGINE
    controller.add_scene('start', scene)
    # I tell the engine what scene to start and run the controller
    controller.run('start')
Exemple #6
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)
    # add a sprite from an image
    sprite = ImageNode.from_image(100, 100, 'sprites.soldier')

    # we want the unit to move, so add a tween
    # all times are in milliseconds for the engine
    # this move rect is a VECTOR, so we move by this amount
    move = pygame.Rect(300, 0, 0, 0)
    sprite.tween = MoveTween(4000, sprite.rect, move)

    # I add the node to a SCENE
    scene = Scene([sprite])
    # I add the scene to the ENGINE
    controller.add_scene('start', scene)
    # I tell the engine what scene to start and run the controller
    controller.run('start')
Exemple #7
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)

    # let's have a background
    background = ImageNode.from_image(0, 0, 'sprites.wallpaper')
    # we want a window to display with a VerticalContainer
    node1 = GuiImage(Resources.colour_surface(200, 80, (200, 32, 32)))
    node2 = GuiImage(Resources.colour_surface(175, 80, (32, 200, 32)), align=Align.CENTRE_RIGHT)
    node3 = GuiImage(Resources.colour_surface(150, 80, (32, 32, 200)))
    container = VerticalContainer([node1, node2, node3], (214, 214, 214), align_children=Align.CENTRE_LEFT)
    window = Window(container)
    # add the window to a scene
    scene = Scene([background, window])
    # I add the scene to the ENGINE
    controller.add_scene('start', scene)
    # I tell the engine what scene to start and run the controller
    controller.run('start')
Exemple #8
0
def game():
    resources = os.path.join(os.getcwd(), '../')
    controller = wargame.engine.init(resources)
    # add a sprite from an image
    sprite = ImageNode.from_image(100, 100, 'sprites.soldier')

    # add a chained tween with >1 tween
    sprite.tween = ChainedTween([
        MoveTween(500, sprite.rect, pygame.Rect(100, 0, 0, 0)),
        MoveTween(500, sprite.rect, pygame.Rect(0, 100, 0, 0)),
        MoveTween(500, sprite.rect, pygame.Rect(-100, 0, 0, 0)),
        MoveTween(500, sprite.rect, pygame.Rect(0, -100, 0, 0))
    ],
                                loop=True)

    # I add the node to a SCENE
    scene = Scene([sprite])
    # I add the scene to the ENGINE
    controller.add_scene('start', scene)
    # I tell the engine what scene to start and run the controller
    controller.run('start')