Beispiel #1
0
	def __init__(self, size):
        super().__init__()

	def on_enter(self, previous_scene):
        super().on_enter(previous_scene)
        self.previous_scene = game_screen
	
	def on_exit(self, next_scene):
		super.on_exit(next_scene)
		self.next_scene = main_menu

app = ezpygame.Application(
	title = '',
	resolution = (width, height),
	update_rate =  30
)

main_menu = Menu()
game_screen = Game()
lose_screen = Lose()
win_screen = Win()
app.run(main_menu)
Beispiel #2
0
            pygame.draw.rect(screen, (255, 0, 0), (10, 28+18, 10, 10))

        if self.current_bet == "heads":
            pygame.draw.rect(screen, (0, 255, 0), (10, 28+2*18, 10, 10))
        else:
            pygame.draw.rect(screen, (255, 0, 0), (10, 28+2*18, 10, 10))

        pygame.draw.rect(screen, (255, 0, 255), (100, 100, 100, 100))
        screen.blit(self.font.render("Coin flip"), (150, 150))
        screen.blit(self.font.render("Coin side: %s" % self.coin.sides[self.coin.side]), (0, 400))
        screen.blit(self.font.render("Bet: %s  Flowers: %s" % (self.bet, self.currency.amount)), (0, 416))


app = ezpygame.Application(
        title="Test",
        resolution=(640, 480),
        update_rate=60,
)
menu = MenuScene()
app.run(GameScene())
"""
class Game:
    def __init__(self):
        self.flowers = Flowers()
        self.coin = Coin()
        self.running = True
        self.bet_rate = 0.95
        self.main_loop()

    def main_loop(self):
        while self.running == True:
Beispiel #3
0
            if event.key == pygame.K_SPACE:
                self._pause()
            if event.key == pygame.K_LEFT:
                self._go_left()
            if event.key == pygame.K_RIGHT:
                self._go_right()
            if event.key == pygame.K_ESCAPE:
                pygame.quit()
                sys.exit()
            if event.key == pygame.K_F5:
                self.hide_timer = 0
                self.show_flag = not (self.show_flag)
        if event.type == pygame.VIDEORESIZE:
            # The main code that resizes the window:
            # (recreate the window with the new size)
            surface = pygame.display.set_mode((event.w, event.h),
                                              pygame.RESIZABLE)
            self.scale_main_image()
        if event.type == pygame.USEREVENT:
            print(event.code)


app = ezpygame.Application(
    title="Gesture drawing",
    resolution=(1280, 720),
    update_rate=60,
)

app._screen = pygame.display.set_mode(app.resolution, pygame.RESIZABLE)

app.run(MainView())

class SharedValues:

    import constants

    health = constants.MAX_HEALTH
    fuel = constants.MAX_FUEL
    oxygen = constants.MAX_OXYGEN

    def reset(self):
        import constants
        self.health = constants.MAX_HEALTH
        self.fuel = constants.MAX_FUEL
        self.oxygen = constants.MAX_OXYGEN


def get_shared_values():
    global shared_values
    if shared_values is None:
        shared_values = SharedValues()
    return shared_values


if __name__ == '__main__':
    from menu import MenuScene
    app = ezpygame.Application(title="Every Woman's Ground",
                               resolution=(SCREEN_WIDTH, SCREEN_HEIGHT),
                               update_rate=FPS)
    app.run(get_menu_scene())
Beispiel #5
0
                    continue
                try:
                    score = int(score)
                except ValueError:
                    print(f'Invalid high score value: {line}')
                    continue
                high_scores.append((name, score))
    except FileNotFoundError:
        print(f'High score file not found: {file_path}')
    return high_scores


def write_high_scores(file_path, high_scores):
    """Write new high scores to a file."""
    with open(file_path, 'w') as file:
        for name, score in high_scores:
            file.write(f'{name}:{score}\n')


if __name__ == '__main__':
    args = parse_args()
    app = ezpygame.Application(
        title='Snake',
        resolution=(args.width, args.height),
        update_rate=args.fps,
    )
    high_scores = read_high_scores(args.scorefile)
    menu_scene = menu.Menu(high_scores, username=args.username)
    app.run(menu_scene)
    write_high_scores(args.scorefile, high_scores)
                self.demo_shape.body.ApplyLinearImpulse(
                    (0, 100), self.demo_shape.body.position, True)

    def draw(self, screen):
        # Called once per frame, to draw to the screen

        screen.fill(black)
        #for shape in self.many_shapes:
        #    shape.draw(screen)
        self.demo_shape.draw(screen)

    def update(self, dt):
        # Called once per frame, to update the state of the game

        # Processing keyboard events here lets you track which keys are being held down
        # keys = pygame.key.get_pressed()
        # if keys[pygame.K_SPACE]:
        #     self.demo_shape.body.ApplyLinearImpulse((0, 30), self.demo_shape.body.position, True)

        # Box2d physics step
        self.world.Step(DT_SCALE * dt, VELOCITY_ITERATIONS,
                        POSITION_ITERATIONS)
        self.world.ClearForces()


if __name__ == '__main__':
    app = ezpygame.Application(title='The Game',
                               resolution=(SCREEN_WIDTH, SCREEN_HEIGHT),
                               update_rate=FPS)
    app.run(DemoScene())