Beispiel #1
0
    def event_step(self, time_passed):
        left_key = ['left', 'a', 'j', 'kp_4'][self.player]
        right_key = ['right', 'd', 'l', 'kp_6'][self.player]
        up_key = ['up', 'w', 'i', 'kp_8'][self.player]
        down_key = ['down', 's', 'k', 'kp_5'][self.player]
        self.xvelocity = (sge.get_key_pressed(right_key) -
                          sge.get_key_pressed(left_key))
        self.yvelocity = (sge.get_key_pressed(down_key) -
                          sge.get_key_pressed(up_key))

        # Limit the circles to inside the room.
        if self.bbox_left < 0:
            self.bbox_left = 0
        elif self.bbox_right >= sge.game.current_room.width:
            self.bbox_right = sge.game.current_room.width - 1
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom >= sge.game.current_room.height:
            self.bbox_bottom = sge.game.current_room.height - 1

        self.set_color()

        # Set view
        my_view = sge.game.current_room.views[self.player]
        my_view.x = self.x - (my_view.width // 2)
        my_view.y = self.y - (my_view.height // 2)
    def event_step(self, time_passed):
        left_key = ['left', 'a', 'j', 'kp_4'][self.player]
        right_key = ['right', 'd', 'l', 'kp_6'][self.player]
        up_key = ['up', 'w', 'i', 'kp_8'][self.player]
        down_key = ['down', 's', 'k', 'kp_5'][self.player]
        self.xvelocity = (sge.get_key_pressed(right_key) -
                          sge.get_key_pressed(left_key))
        self.yvelocity = (sge.get_key_pressed(down_key) -
                          sge.get_key_pressed(up_key))

        # Limit the circles to inside the room.
        if self.bbox_left < 0:
            self.bbox_left = 0
        elif self.bbox_right >= sge.game.current_room.width:
            self.bbox_right = sge.game.current_room.width - 1
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom >= sge.game.current_room.height:
            self.bbox_bottom = sge.game.current_room.height - 1

        self.set_color()

        # Set view
        my_view = sge.game.current_room.views[self.player]
        my_view.x = self.x - (my_view.width // 2)
        my_view.y = self.y - (my_view.height // 2)
Beispiel #3
0
    def event_step(self, time_passed, delta_mult):
	# Movement
	key_motion = (sge.get_key_pressed(self.down_key) -
	              sge.get_key_pressed(self.up_key))
	
	self.yvelocity = key_motion * PADDLE_SPEED
	
	# Keep the paddle inside the window
	if self.bbox_top < 0:
	    self.bbox_top = 0
	elif self.bbox_bottom > sge.game.height:
	    self.bbox_bottom = sge.game.height
Beispiel #4
0
    def event_step(self, time_passed):
        # Movement
        key_motion = (sge.get_key_pressed(self.down_key) -
                      sge.get_key_pressed(self.up_key))

        self.yvelocity = key_motion * PADDLE_SPEED

        # Keep the paddle inside the window
        if self.y < 0:
            self.y = 0
        elif self.y > sge.game.height:
            self.y = sge.game.height
Beispiel #5
0
    def event_step(self, time_passed):
        # Movement
        if self.axis_motion:
            self.yvelocity = self.axis_motion * 4
        else:
            self.yvelocity = (sge.get_key_pressed(self.down_key) -
                              sge.get_key_pressed(self.up_key)) * 4

        # Keep the paddle inside the window
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom > sge.game.height:
            self.bbox_bottom = sge.game.height

        self.axis_motion = 0
    def event_step(self, time_passed):
        self.xvelocity = (sge.get_key_pressed(self.right_key) - sge.get_key_pressed(self.left_key)) * 6
        self.yvelocity = sge.get_key_pressed(self.down_key) - sge.get_key_pressed(self.up_key)

        if self.bbox_left < 0:
            self.bbox_left = 0
        elif self.bbox_right > sge.game.width:
            self.bbox_right = sge.game.width
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom > sge.game.height:
            self.bbox_bottom = sge.game.height

        if self.can_shoot and sge.get_key_pressed("space"):
            self.shoot()
Beispiel #7
0
    def event_step(self, time_passed):
        self.xvelocity = (sge.get_key_pressed(self.right_key) -
                          sge.get_key_pressed(self.left_key)) * 6
        self.yvelocity = (sge.get_key_pressed(self.down_key) -
                          sge.get_key_pressed(self.up_key))

        if self.bbox_left < 0:
            self.bbox_left = 0
        elif self.bbox_right > sge.game.width:
            self.bbox_right = sge.game.width
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom > sge.game.height:
            self.bbox_bottom = sge.game.height

        if self.can_shoot and sge.get_key_pressed('space'):
            self.shoot()
    def event_step(self, time_passed):
        left_key = ["left", "a", "j", "kp_4"][self.player]
        right_key = ["right", "d", "l", "kp_6"][self.player]
        up_key = ["up", "w", "i", "kp_8"][self.player]
        down_key = ["down", "s", "k", "kp_5"][self.player]

        self.xvelocity = sge.get_key_pressed(right_key) - sge.get_key_pressed(left_key)
        self.yvelocity = sge.get_key_pressed(down_key) - sge.get_key_pressed(up_key)

        # Limit the circles to inside the room.
        if self.bbox_left < 0:
            self.bbox_left = 0
        elif self.bbox_right >= sge.game.current_room.width:
            self.bbox_right = sge.game.current_room.width - 1
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom >= sge.game.current_room.height:
            self.bbox_bottom = sge.game.current_room.height - 1
    def event_step(self, time_passed):
        # Movement
        key_motion = sge.get_key_pressed(self.down_key) - sge.get_key_pressed(self.up_key)
        axis_motion = sge.get_joystick_axis(self.joystick, 1)

        if abs(axis_motion) > abs(key_motion) and abs(axis_motion) > abs(self.trackball_motion):
            self.yvelocity = axis_motion * PADDLE_SPEED
        elif abs(self.trackball_motion) > abs(key_motion) and abs(self.trackball_motion) > abs(axis_motion):
            self.yvelocity = self.trackball_motion * PADDLE_SPEED
        else:
            self.yvelocity = key_motion * PADDLE_SPEED

        self.trackball_motion = 0

        # Keep the paddle inside the window
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom > sge.game.height:
            self.bbox_bottom = sge.game.height
Beispiel #10
0
    def event_step(self, time_passed):
        # Movement
        key_motion = (sge.get_key_pressed(self.down_key) -
                      sge.get_key_pressed(self.up_key))
        axis_motion = sge.get_joystick_axis(self.joystick, 1)

        if (abs(axis_motion) > abs(key_motion)
                and abs(axis_motion) > abs(self.trackball_motion)):
            self.yvelocity = axis_motion * PADDLE_SPEED
        elif (abs(self.trackball_motion) > abs(key_motion)
              and abs(self.trackball_motion) > abs(axis_motion)):
            self.yvelocity = self.trackball_motion * PADDLE_SPEED
        else:
            self.yvelocity = key_motion * PADDLE_SPEED

        self.trackball_motion = 0

        # Keep the paddle inside the window
        if self.bbox_top < 0:
            self.bbox_top = 0
        elif self.bbox_bottom > sge.game.height:
            self.bbox_bottom = sge.game.height