예제 #1
0
 def draw(self):
     x,y,z = motion.get_attitude() if use_motion else scene.gravity()
     r,g,b = abs(x), abs(y), abs(z)  # No negative colors
     scene.background(r, g, b)
     scene.tint(1-r, 1-g, 1-b)
     scene.text(fmt.format(x, y, z), font_size=32,
                x=self.center.x, y=self.center.y)
예제 #2
0
 def draw(self):
     x,y,z = motion.get_attitude() if use_motion else scene.gravity()
     r,g,b = abs(x), abs(y), abs(z)
     scene.background(r, g, b)
     super(Advice, self).draw()
     scene.tint(1-r, 1-g, 1-b)
     scene.text(self.answer, 'Futura', 45, *self.center)
예제 #3
0
 def control_player(self):
     tilt = gravity().x
     if abs(tilt) > DEAD_ZONE:
         move = self.dt * tilt * PLAYER_CONTROL_SPEED
         self.player.frame.x += move
         self.player.frame.x = max(self.player.frame.x, 0)
         self.player.frame.x = min(self.player.frame.x,
                                   self.bounds.w - self.player.frame.w)
예제 #4
0
 def control_player(self):
     tilt = gravity().x
     if abs(tilt) > DEAD_ZONE:
         move = self.dt * tilt * PLAYER_CONTROL_SPEED
         self.player.frame.x += move
         self.player.frame.x = max(self.player.frame.x, 0)
         self.player.frame.x = min(self.player.frame.x,
                                   self.bounds.w - self.player.frame.w)
예제 #5
0
 def control_player(self):
     tilt = scene.gravity().x
     if abs(tilt) > DEAD_ZONE:
         move = self.dt * tilt * PLAYER_CONTROL_SPEED
         self.player.frame.x += move
         if self.player.frame.x < 0:
             self.player.frame.x = 0
         elif self.player.frame.x > self.bounds.w - self.player.frame.w:
             self.player.frame.x = self.bounds.w - self.player.frame.w
예제 #6
0
    def update_player(self):
        # The gravity() function returns an (x, y, z) vector that describes the current orientation of your device.
        x, y, z = sc.gravity()

        # Determine player's position
        pos = self.player.position

        # If the camera is not moving, update player's y-coordinate
        if self.moving == False:
            self.count += 1

            pos.y = pos.y + self.jump[self.count % len(self.jump)]

        # Determine if the relevant accelerations are of significant magnitude
        g = [abs(x) > 0.01, abs(y) > 0.01]

        # The components of the gravity vector are in the range 0.0 to 1.0, so we have to multiply it with some factor to move the player more quickly. 35 works pretty well, but feel free to experiment.
        max_speed = 35

        # Check the orientation. In Ladnscape orientation, the x direction of movement corresponds to the y coordinate of the accelerometer
        if any(g) and self.orientation == 'LANDSCAPE':

            # change position x depending on the accelerometer data and the speed of the game (higher as the game progresses)
            pos.x += -y * max_speed

            # We simply add the x component of the gravity vector to the current position, and clamp the value between 27 and the scene's width, so the alien doesn't move outside of the screen boundaries.
            pos.x = max(27, min(self.size.w - 27, pos.x))

            # Ensure that the player is facing in the direction of motion using appropriate scaling
            self.player.x_scale = cmp(-y, 0)

        elif any(g) and self.orientation == 'PORTRAIT':

            # apply similar equations in the Portrait case
            pos.x += x * max_speed
            pos.x = max(27, min(self.size.w - 27, pos.x))
            self.player.x_scale = cmp(x, 0)

        # Update the final player position
        self.player.position = pos

        # Create appropriate textures for more fluid motion
        if pos.y < 70:
            self.player.texture = landing_texture

            if pos.y < 33:
                sound.play_effect('arcade:Jump_5', 0.05)
        else:
            self.player.texture = jumping_texture
예제 #7
0
	def draw(self):
		x,y,z = motion.get_attitude() if use_motion else scene.gravity()
		r,g,b = abs(x), abs(y), abs(z)
		scene.background(r, g, b)
		scene.tint(1-r, 1-g, 1-b)
		scene.text(answer.format(x, y, z), font_size=45, x=self.center.x, y=self.center.y)
		for p in self.particles:
			p.update()
			p.draw()
		for t in self.touches.values():
			for p in self.particles:
				tx, ty = t.location.x, t.location.y
				d = (p.x - tx)*(p.x - tx)+(p.y - ty)*(p.y - ty)
				d = sqrt(d)
				p.vx = p.vx - 5/d*(p.x-tx)
				p.vy = p.vy - 5/d*(p.y-ty)
				p.colour = Color(random.random(), random.random(), random.random())
예제 #8
0
 def draw(self):
     x, y, z = motion.get_attitude() if use_motion else scene.gravity()
     r, g, b = abs(x), abs(y), abs(z)
     scene.background(r, g, b)
     scene.tint(1 - r, 1 - g, 1 - b)
     scene.text(answer.format(x, y, z),
                font_size=45,
                x=self.center.x,
                y=self.center.y)
     for p in self.particles:
         p.update()
         p.draw()
     for t in self.touches.values():
         for p in self.particles:
             tx, ty = t.location.x, t.location.y
             d = (p.x - tx) * (p.x - tx) + (p.y - ty) * (p.y - ty)
             d = sqrt(d)
             p.vx = p.vx - 5 / d * (p.x - tx)
             p.vy = p.vy - 5 / d * (p.y - ty)
             p.colour = Color(random.random(), random.random(),
                              random.random())
 def draw(self, a=1):
     super(self.__class__, self).draw()
     g = scene.gravity()
     self.frame.x += g.x * 10
     self.frame.y += g.y * 10
예제 #10
0
    def check_inputs(self):
        g = gravity()

        if abs(g.y) > 0.1:
            self.input = True
            self.acc.x += ACC * g.y
예제 #11
0
 def draw(self, a=1):
     super(self.__class__, self).draw()
     g = scene.gravity()
     self.frame.x += g.x * 10
     self.frame.y += g.y * 10