Esempio n. 1
0
"""

Simplest possible game, as function.

"""
from game_api import arcadeapi as arcade


@arcade.draw
def draw_hello():
    arcade.draw_text('Hello World', 10, 200, (0, 0, 0), 20)


# Multiple handlers are possible
@arcade.draw
def draw_hello(window):  # window is optional parameter
    msg = f'Optional window argument has width {window.width}'
    arcade.draw_text(msg, 50, 100, (0, 0, 0), 10)


if __name__ == '__main__':
    arcade.run()
from game_api import arcadeapi as arcade

arcade.draw_text('Hello World', 10, 200, (0, 0, 0), 20)
arcade.run()  # Or pass args to customize window
    if window.ball.x_position > window.width - window.ball.radius \
            and window.ball.velocity > 0:
        window.ball.velocity *= -1

    # Did the ball hit the left side of the screen while moving left?
    if window.ball.x_position < window.ball.radius \
            and window.ball.velocity < 0:
        window.ball.velocity *= -1


@arcade.draw
def draw_the_ball(window):
    arcade.draw_circle_filled(window.ball.x_position, window.height // 2,
                              window.ball.radius, arcade.color.GREEN)


@arcade.draw
def draw_some_text(window):
    arcade.draw_text("This is a simple template to start your game.", 10,
                     window.height // 2, arcade.color.BLACK, 20)


@arcade.key_press
def press_space(key, key_modifiers):
    if key == arcade.key.SPACE:
        print("You pressed the space bar.")


if __name__ == "__main__":
    arcade.run(700, 600, background_color=arcade.color.MAHOGANY)
"""

Simplest possible game, as function.

"""
from game_api import arcadeapi as arcade


@arcade.draw
def draw_hello():
    arcade.draw_text('Hello World', 10, 200, (0, 0, 0), 20)


if __name__ == '__main__':
    arcade.run(420, 240, title='Hi', background_color=(100, 100, 100))