Skip to content
Snippets Groups Projects
Commit bff2137f authored by Leon Grothus's avatar Leon Grothus
Browse files

fixed scaling

parent 1f81ed05
No related branches found
No related tags found
No related merge requests found
......@@ -7,8 +7,8 @@ A file to store constants in
GRAVITY = Vector2(0, 666) # Gravity applied to all objects
COLLISION_FRICTION = 0.1 # Friction applied when the object is colliding
AIR_FRICTION = 0.01 # Friction applied when the object is in the air
COLLISION_FRICTION = 0.13 # Friction applied when the object is colliding
AIR_FRICTION = 0.012 # Friction applied when the object is in the air
PADDLE_SPEED = 666 # degrees per second
PADDLE_COLLISION_DAMPING = .66 # Factor to scale the velocity with when the paddle is hit
......
data/data.png

282 B | W: | H:

data/data.png

3.68 KiB | W: | H:

data/data.png
data/data.png
data/data.png
data/data.png
  • 2-up
  • Swipe
  • Onion skin
{"asf": 1.0, "master_volume": 50, "music_volume": 21, "sfx_volume": 58, "user_name": "Player"}
\ No newline at end of file
{"asf": 2.0, "master_volume": 50, "music_volume": 21, "sfx_volume": 58, "user_name": "Player"}
\ No newline at end of file
......@@ -117,7 +117,7 @@ class Rigidbody(Component):
self.acceleration += GRAVITY * self.asf
self.velocity += (self.acceleration * scaled_delta_time)
self.velocity *= (1 - (AIR_FRICTION/PTPF)/self.asf)
self.velocity *= (1 - (AIR_FRICTION/PTPF)/max(self.asf, 1))
self.parent.transform.pos += (self.velocity * scaled_delta_time)
......@@ -188,14 +188,14 @@ class Rigidbody(Component):
angle_of_impact = abs(normal.dot(self.velocity.normalize()))
# Calculate the velocity magnitude
velocity_magnitude = self.velocity.length()
# Adjust the friction based on the velocity and the angle of impact
# Adjust the friction based on the velocity and the angle of impact
adjusted_friction = other_collider.friction * (clamp(velocity_magnitude / (500*self.asf), .2, 1)) * (1 + angle_of_impact/10)
reflected_velocity *= clamp(1 - adjusted_friction, 0.5, 1)
# If the other object has a rotation speed, calculate the angular momentum
if other_collider.parent.transform.do_smooth_rotation:
# Calculate the angular velocity vector
angular_velocity = normal * (other_collider.parent.transform.rotation_speed*max(self.asf, 1))/(PADDLE_COLLISION_DAMPING * self.asf)
angular_velocity = normal * ((other_collider.parent.transform.rotation_speed*self.asf)/PADDLE_COLLISION_DAMPING) * (self.asf**(1/2))
# Add the angular momentum to the velocity of the ball
self.velocity = reflected_velocity + angular_velocity
......
......@@ -114,7 +114,7 @@ class MainPinball(Scene):
scale_strength = .25
self.add_gameobject(Plunger(self, V2(width - self.ball_radius*3, height),
V2(width, height), impuls_range=(int(1300*(asf**1.3)), int(1400*(asf**1.3)))))
V2(width, height), impuls_range=(int(1400*asf), int(1600*asf))))
self.left_flipper = Flipper(self, V2(300*asf - 130 * asf, height - 125*asf), 30)
self.right_flipper = Flipper(self, V2(300*asf + 130 * asf, height - 125*asf), 150)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment