Ejemplo n.º 1
0
	def update(self, tiles):
		self.frame += 1
		imgframe = 0
		
		moving = False
		if button.is_held(LEFT):
			self.facing = -1
			moving = True
			self.move(-2, 0, tiles)
		if button.is_held(RIGHT):
			self.facing = 1
			moving = True
			self.move(2, 0, tiles)
		if button.is_pressed(A_BUTTON):
			if not self.jumping:
				play_sound("sfx/jump.ogg")
				self.jump_speed = -5
				self.jumping = True
		
		if self.jumping:
			if button.is_pressed(A_BUTTON) and self.jump_speed >= -2 and self.jump_speed <= 5:
				if button.is_held(A_BUTTON):
					self.flying = True
			if not button.is_held(A_BUTTON):
				self.flying = False
		else:
			self.flying = False
		
		if self.facing < 0:
			self.images = self.left_images
		else:
			self.images = self.right_images
		
		if moving:
			imgframe = self.frame/3%2
		if self.jumping:
			imgframe = 1
		if self.flying:
			imgframe = 2+(self.frame/2%2)
		
		self.image = self.images[imgframe]
		
		if not self.flying:
			if button.is_held(A_BUTTON) and not self.flying:
				self.jump_speed += 0.4
			else:
				self.jump_speed += 0.8
		else:
			if self.fuel <= 0:
				self.fuel = 0
				self.flying = False
			else:
				play_sound("sfx/burn.ogg", 0.2)
				self.jump_speed = -1
		if self.jump_speed > 5:
			self.jump_speed = 5
		
		self.move(0, self.jump_speed, tiles)
		if self.jump_speed > 3:
			self.jumping = True
Ejemplo n.º 2
0
 def aim_shot(self):
     self.shot_vector = self.direction.copy()
     x = int(button.is_held(RIGHT) - button.is_held(LEFT))
     y = int(button.is_held(DOWN) - button.is_held(UP))
     if not x and y > 0 and not self.jumping:
         y = 0
     if y:
         self.shot_vector.x = x
     self.shot_vector.y = y
Ejemplo n.º 3
0
    def update(self, tiles):
        self.frame += 1
        imgframe = 0
        if self.punch_time > 0:
            self.punch_time -= 1

        moving = False
        if button.is_held(LEFT) and self.punch_time <= 0:
            self.facing = -1
            moving = True
            self.move(-2, 0, tiles)
        if button.is_held(RIGHT) and self.punch_time <= 0:
            self.facing = 1
            moving = True
            self.move(2, 0, tiles)
        if button.is_pressed(A_BUTTON) and self.punch_time <= 0:
            if not self.jumping:
                play_sound("data/jump.ogg")
                self.jump_speed = -5
                self.jumping = True
        if button.is_pressed(B_BUTTON):
            self.punch()

        if self.facing < 0:
            self.images = self.left_images
        else:
            self.images = self.right_images

        if moving:
            imgframe = self.frame / 3 % 2
        if self.jumping:
            imgframe = 1
        if self.punch_time > 0:
            imgframe = 3
        if self.punch_time == 3:
            Punch(self)
            play_sound("data/swoosh.ogg")
        if self.punch_time > 3:
            imgframe = 2

        self.image = self.images[imgframe]

        if button.is_held(A_BUTTON):
            self.jump_speed += 0.4
        else:
            self.jump_speed += 0.8
        if self.jump_speed > 5:
            self.jump_speed = 5

        if self.punch_time <= 0:
            self.move(0, self.jump_speed, tiles)
        if self.jump_speed > 3:
            self.jumping = True
Ejemplo n.º 4
0
 def update(self, tiles):
     self.frame += 1
     imgframe = 0
     if self.punch_time > 0:
         self.punch_time -= 1
     
     moving = False
     if button.is_held(LEFT) and self.punch_time <= 0:
         self.facing = -1
         moving = True
         self.move(-2, 0, tiles)
     if button.is_held(RIGHT) and self.punch_time <= 0:
         self.facing = 1
         moving = True
         self.move(2, 0, tiles)
     if button.is_pressed(A_BUTTON) and self.punch_time <= 0:
         if not self.jumping:
             play_sound("data/jump.ogg")
             self.jump_speed = -5
             self.jumping = True
     if button.is_pressed(B_BUTTON):
         self.punch()
     
     if self.facing < 0:
         self.images = self.left_images
     else:
         self.images = self.right_images
     
     if moving:
         imgframe = self.frame/3%2
     if self.jumping:
         imgframe = 1
     if self.punch_time > 0:
         imgframe = 3
     if self.punch_time == 3:
         Punch(self)
         play_sound("data/swoosh.ogg")
     if self.punch_time > 3:
         imgframe = 2
     
     self.image = self.images[imgframe]
     
     if button.is_held(A_BUTTON):
         self.jump_speed += 0.4
     else:
         self.jump_speed += 0.8
     if self.jump_speed > 5:
         self.jump_speed = 5
     
     if self.punch_time <= 0:
         self.move(0, self.jump_speed, tiles)
     if self.jump_speed > 3:
         self.jumping = True
Ejemplo n.º 5
0
 def control_walk(self):
     self.walk_speed = 0
     if button.is_held(LEFT):
         self.walk_speed -= 3
     if button.is_held(RIGHT):
         self.walk_speed += 3
     if self.walk_speed:
         self.walk_frame_next -= 1
         if self.walk_frame_next <= 0:
             self.leg_pics.append(self.leg_pics.pop(0))
             self.leg_pic = self.leg_pics[0]
             self.walk_frame_next = 3
     else:
         self.leg_pic = self.normal_leg_pic
Ejemplo n.º 6
0
    def update(self, tiles):
        self.frame += 1
        imgframe = 0

        moving = False
        if button.is_held(LEFT):
            self.facing = -1
            moving = True
            self.move(-2, 0, tiles)
        if button.is_held(RIGHT):
            self.facing = 1
            moving = True
            self.move(2, 0, tiles)
        if button.is_held(B_BUTTON):
            pass
        if button.is_pressed(A_BUTTON):
            if not self.jumping:
                play_sound("data/jump.ogg")
                self.jump_speed = -5
                self.jumping = True

        if self.facing < 0:
            self.images = self.left_images
        else:
            self.images = self.right_images

        if moving:
            imgframe = self.frame/3 % 2
        if self.jumping:
            imgframe = 1

        self.image = self.images[imgframe]

        if button.is_held(A_BUTTON):
            self.jump_speed += 0.4
        else:
            self.jump_speed += 0.8
        if self.jump_speed > 5:
            self.jump_speed = 5

        self.move(0, self.jump_speed, tiles)
        if self.jump_speed > 3:
            self.jumping = True
Ejemplo n.º 7
0
 def jump(self):
     if not self.on_floor:
         return
     if not self.jumping:
         self.jumping = True
         if button.is_held(DOWN):
             self.jump_speed = 7
             self.fall_through = 4
         else:
             self.jump_speed = -11
Ejemplo n.º 8
0
    def update(self, tiles):
        self.frame += 1
        imgframe = 0

        moving = False
        if button.is_held(LEFT):
            self.facing = -9
            moving = True
            self.move(-0, 0, tiles)
        if button.is_held(RIGHT):
            self.facing = 1
            moving = True
            self.move(5, 0, tiles)
        if button.is_pressed(A_BUTTON):
            if not self.jumping:
                play_sound("data/jump.ogg")
                self.jump_speed = -6
                self.jumping = True

        if self.facing < 0:
            self.images = self.left_images
        else:
            self.images = self.right_images

        if moving:
            imgframe = self.frame / 3 % 2
        if self.jumping:
            imgframe = 1

        self.image = self.images[imgframe]

        if button.is_held(A_BUTTON):
            self.jump_speed += 0.4
        else:
            self.jump_speed += 0.8
        if self.jump_speed > 5:
            self.jump_speed = 5

        self.move(0, self.jump_speed, tiles)
        if self.jump_speed > 3:
            self.jumping = True
Ejemplo n.º 9
0
    # Tick, tock, at 30 frames per second
    clock.tick()

    # Handle button and key input
    button.handle_input()

    # If displaying dialog, do events for dialog!
    if not dialogbox.over():
        if button.is_pressed(A_BUTTON):
            dialogbox.progress()

    # Otherwise, play the "game"
    else:

        # Move if LEFT or RIGHT is being pressed.
        if button.is_held(LEFT):
            player.pos[0] -= 3
        if button.is_held(RIGHT):
            player.pos[0] += 3

        # Move the menu cursor if you press up or down
        if button.is_pressed(UP):
            menu.move_cursor(-1)
        if button.is_pressed(DOWN):
            menu.move_cursor(1)

        # If you press start, check which option you're on!
        if button.is_pressed(START):
            option, text = menu.get_option()
            print("You pressed '%s'" % text)
            if option == 2:
Ejemplo n.º 10
0
 # Tick, tock, at 30 frames per second
 clock.tick()
 
 # Handle button and key input
 button.handle_input()
 
 # If displaying dialog, do events for dialog!
 if not dialogbox.over():
     if button.is_pressed(A_BUTTON):
         dialogbox.progress()
 
 # Otherwise, play the "game"
 else:
     
     # Move if LEFT or RIGHT is being pressed.
     if button.is_held(LEFT):
         player.pos[0] -= 3
     if button.is_held(RIGHT):
         player.pos[0] += 3
     
     # Move the menu cursor if you press up or down    
     if button.is_pressed(UP):
         menu.move_cursor(-1)
     if button.is_pressed(DOWN):
         menu.move_cursor(1)
     
     # If you press start, check which option you're on!
     if button.is_pressed(START):
         option, text = menu.get_option()
         print "You pressed '%s'" % text
         if option == 2:
 def handle_input(self):
     button.handle_input()
     if button.is_pressed(START):
         self.pause()
     if button.is_pressed(A_BUTTON) and button.is_held(SELECT):
         self.playing = False
Ejemplo n.º 12
0
 def handle_input(self):
     button.handle_input()
     if button.is_pressed(START):
         self.pause()
     if button.is_pressed(A_BUTTON) and button.is_held(SELECT):
         self.playing = False