Exemplo n.º 1
0
    def __init__(self):
        super(Tutorial, self).__init__()
        self.title = Line((game.screen_size[0] / 2, 150), "Tutorial",
                          game.get_font('title'))

        self.cursor = Cursor()
        self.hand_screen = HandScreen(
            (3 * game.screen_size[0] / 4, game.screen_size[1] / 2))

        self.set_letter()

        game.global_state_changed.subscribe(self.global_state_changed)
Exemplo n.º 2
0
    def __init__(self):
        super(MainMenu, self).__init__()

        self.title = Line((game.screen_size[0] / 2, game.screen_size[1] / 4),
                          "Houd de knop ingedrukt", game.get_font('title'))

        self.cursor = Cursor()
        self.start_button = Button(
            (game.screen_size[0] / 2, game.screen_size[1] / 2),
            self.start_button_pressed)

        game.global_state_changed.subscribe(self.global_state_changed)
Exemplo n.º 3
0
class MainMenu(game.State):
    def __init__(self):
        super(MainMenu, self).__init__()

        self.title = Line((game.screen_size[0] / 2, game.screen_size[1] / 4),
                          "Houd de knop ingedrukt", game.get_font('title'))

        self.cursor = Cursor()
        self.start_button = Button(
            (game.screen_size[0] / 2, game.screen_size[1] / 2),
            self.start_button_pressed)

        game.global_state_changed.subscribe(self.global_state_changed)

    def update(self, delta):
        self.title.update(delta)
        self.cursor.update(delta)
        self.start_button.update(delta)

    def draw(self, surface):
        self.title.draw(surface)
        self.start_button.draw(surface)
        self.cursor.draw(surface)

    def start_button_pressed(self):
        game.set_global_state('tutorial')

    def global_state_changed(self, previous_state, new_state):
        if new_state is 'main_menu':
            self.cursor.set_position((0, 0))
            self.cursor.cursor_up()
Exemplo n.º 4
0
    def __init__(self):
        super(Game, self).__init__()

        self.cursor = Cursor()

        self.cursor = Cursor()
        self.return_button = CancelButton((128, game.screen_size[1] - 128),
                                          self.return_button_pressed)

        self.hand_screen = HandScreen((game.screen_size[0] - 256, 256))

        self.block_manager = BlockManager(
            (game.screen_size[0] / 2, 4 * game.screen_size[1] / 7),
            self.hand_screen)

        game.global_state_changed.subscribe(self.global_state_changed)
Exemplo n.º 5
0
 def __init__(self, name):
     random.seed()
     video_mode = sf.VideoMode(800, 600, 32)
     style = sf.Style.CLOSE
     self.window_image = sf.Image.load_from_file(
         bytes(os.path.join("assets", "you.png"), 'UTF-8'))
     self.window = sf.RenderWindow(video_mode, bytes(name, 'UTF-8'), style)
     self.window.set_icon(40, 40, self.window_image.get_pixels())
     self.window.framerate_limit = 60
     self.window.show_mouse_cursor = False
     self.state = State()
     self.scene = scenes.Intro(self.state)
     self.cursor = Cursor()
     self.pause_img = sf.Texture.load_from_file(
         bytes(os.path.join("assets", "paused.png"), 'UTF-8'))
     self.pause_sprite = sf.Sprite(self.pause_img)
     self.pause = False
     self.run()
Exemplo n.º 6
0
class Game(game.State):
    def __init__(self):
        super(Game, self).__init__()

        self.cursor = Cursor()

        self.cursor = Cursor()
        self.return_button = CancelButton((128, game.screen_size[1] - 128),
                                          self.return_button_pressed)

        self.hand_screen = HandScreen((game.screen_size[0] - 256, 256))

        self.block_manager = BlockManager(
            (game.screen_size[0] / 2, 4 * game.screen_size[1] / 7),
            self.hand_screen)

        game.global_state_changed.subscribe(self.global_state_changed)

    def update(self, delta):
        self.cursor.update(delta)
        self.return_button.update(delta)
        self.hand_screen.update(delta)

        self.block_manager.update(delta)

        if self.block_manager.is_finished:
            game.set_global_state('tutorial')

    def draw(self, surface):
        self.return_button.draw(surface)
        self.block_manager.draw(surface)
        self.hand_screen.draw(surface)
        self.cursor.draw(surface)

    def return_button_pressed(self):
        game.set_global_state('tutorial')

    def global_state_changed(self, previous_state, new_state):
        if new_state is 'game':
            self.block_manager.reset()
Exemplo n.º 7
0
class Tutorial(game.State):
    def __init__(self):
        super(Tutorial, self).__init__()
        self.title = Line((game.screen_size[0] / 2, 150), "Tutorial",
                          game.get_font('title'))

        self.cursor = Cursor()
        self.hand_screen = HandScreen(
            (3 * game.screen_size[0] / 4, game.screen_size[1] / 2))

        self.set_letter()

        game.global_state_changed.subscribe(self.global_state_changed)

    def update(self, delta):
        self.title.update(delta)
        self.cursor.update(delta)
        self.hand_screen.update(delta)
        self.pose_tutorial.update(delta)

        if not self.pose_tutorial.is_active:
            game.set_global_state('game')

    def draw(self, surface):
        self.title.draw(surface)
        self.hand_screen.draw(surface)
        self.pose_tutorial.draw(surface)
        self.cursor.draw(surface)

    def global_state_changed(self, previous_state, new_state):
        if new_state is 'tutorial':
            self.cursor.set_position((0, 0))
            self.cursor.cursor_up()

            self.set_letter()

    def set_letter(self):
        self.letter = random.sample(game.get_property('available_letters'),
                                    1)[0]

        self.title.set_text('De letter %s' % self.letter.upper())

        self.pose_tutorial = PoseTutorial(
            (game.screen_size[0] / 4, game.screen_size[1] / 2),
            self.hand_screen.get_pose, self.letter)
Exemplo n.º 8
0
	def __init__(self, name):
		random.seed()
		video_mode = sf.VideoMode(800, 600, 32)
		style = sf.Style.CLOSE
		self.window_image = sf.Image.load_from_file(bytes(os.path.join("assets", "you.png"), 'UTF-8'))
		self.window = sf.RenderWindow(video_mode, bytes(name, 'UTF-8'), style)
		self.window.set_icon(40, 40, self.window_image.get_pixels())
		self.window.framerate_limit = 60
		self.window.show_mouse_cursor = False
		self.state = State()
		self.scene = scenes.Intro(self.state)
		self.cursor = Cursor()
		self.pause_img = sf.Texture.load_from_file(bytes(os.path.join("assets", "paused.png"), 'UTF-8'))
		self.pause_sprite = sf.Sprite(self.pause_img)
		self.pause = False
		self.run()
Exemplo n.º 9
0
class LeeroyJenkins:
    def __init__(self, name):
        random.seed()
        video_mode = sf.VideoMode(800, 600, 32)
        style = sf.Style.CLOSE
        self.window_image = sf.Image.load_from_file(
            bytes(os.path.join("assets", "you.png"), 'UTF-8'))
        self.window = sf.RenderWindow(video_mode, bytes(name, 'UTF-8'), style)
        self.window.set_icon(40, 40, self.window_image.get_pixels())
        self.window.framerate_limit = 60
        self.window.show_mouse_cursor = False
        self.state = State()
        self.scene = scenes.Intro(self.state)
        self.cursor = Cursor()
        self.pause_img = sf.Texture.load_from_file(
            bytes(os.path.join("assets", "paused.png"), 'UTF-8'))
        self.pause_sprite = sf.Sprite(self.pause_img)
        self.pause = False
        self.run()

    def run(self):
        while True:
            try:
                self.step()
            except Quit:
                self.window.close()
                sys.exit()

    def step(self):
        if self.scene.finished:
            self.scene = self.scene.next
        self.handle_events()
        if not self.pause:
            self.update()
        self.render()

    def handle_events(self):
        for event in self.window.iter_events():
            if event.type == sf.Event.CLOSED or (
                    event.type == sf.Event.KEY_PRESSED
                    and event.code == sf.Keyboard.ESCAPE):
                self.quit()
            elif (event.type == sf.Event.KEY_PRESSED
                  and event.code == sf.Keyboard.P):
                self.pause = not self.pause
            elif event.type == sf.Event.MOUSE_BUTTON_RELEASED and self.pause:
                self.pause = False
            elif event.type == sf.Event.LOST_FOCUS:
                self.pause = True
            elif event.type == sf.Event.GAINED_FOCUS:
                self.pause = False
            elif not self.pause:
                self.scene.handle_event(self.cursor, event)

    def render(self):
        self.window.clear(sf.Color.BLACK)
        self.scene.render(self.window)
        self.cursor.draw(self.window)
        if self.pause:
            self.window.draw(self.pause_sprite)
        self.window.display()

    def update(self):
        self.scene._update(self.cursor, self.window.frame_time)
        self.cursor.position = sf.Mouse.get_position(self.window)

    def quit(self):
        raise Quit
Exemplo n.º 10
0
class LeeroyJenkins:

	def __init__(self, name):
		random.seed()
		video_mode = sf.VideoMode(800, 600, 32)
		style = sf.Style.CLOSE
		self.window_image = sf.Image.load_from_file(bytes(os.path.join("assets", "you.png"), 'UTF-8'))
		self.window = sf.RenderWindow(video_mode, bytes(name, 'UTF-8'), style)
		self.window.set_icon(40, 40, self.window_image.get_pixels())
		self.window.framerate_limit = 60
		self.window.show_mouse_cursor = False
		self.state = State()
		self.scene = scenes.Intro(self.state)
		self.cursor = Cursor()
		self.pause_img = sf.Texture.load_from_file(bytes(os.path.join("assets", "paused.png"), 'UTF-8'))
		self.pause_sprite = sf.Sprite(self.pause_img)
		self.pause = False
		self.run()
		
	def run(self):
		while True:
			try:
				self.step()
			except Quit:
				self.window.close()
				sys.exit()

	def step(self):
		if self.scene.finished:
			self.scene = self.scene.next
		self.handle_events()
		if not self.pause:
			self.update()
		self.render()

	def handle_events(self):
		for event in self.window.iter_events():
			if event.type == sf.Event.CLOSED or (event.type ==
			    sf.Event.KEY_PRESSED and event.code == sf.Keyboard.ESCAPE):
				self.quit()
			elif (event.type == sf.Event.KEY_PRESSED and
			      event.code == sf.Keyboard.P):
				self.pause = not self.pause
			elif event.type == sf.Event.MOUSE_BUTTON_RELEASED and self.pause:
				self.pause = False
			elif event.type == sf.Event.LOST_FOCUS:
				self.pause = True
			elif event.type == sf.Event.GAINED_FOCUS:
				self.pause = False
			elif not self.pause:
				self.scene.handle_event(self.cursor, event)

	def render(self):
		self.window.clear(sf.Color.BLACK)
		self.scene.render(self.window)
		self.cursor.draw(self.window)
		if self.pause:
			self.window.draw(self.pause_sprite)
		self.window.display()

	def update(self):
		self.scene._update(self.cursor, self.window.frame_time)
		self.cursor.position = sf.Mouse.get_position(self.window)

	def quit(self):
		raise Quit