Skip to content

fix for SPS Python course #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions docs/bird/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
WHITE = (255, 255, 255)

space = pymunk.Space()
space.gravity = 0, -900
space.gravity = 0, 900

draw_options = pymunk.pygame_util.DrawOptions(screen)

Expand All @@ -33,7 +33,6 @@ def post_solve_bird_wood(arbiter, space, _):
bird, wood = arbiter.shapes

if arbiter.total_impulse.length > 500:
print(arbiter.total_impulse.length)
space.remove(wood, wood.body)
for obj in Game.objects:
if obj.body == wood.body:
Expand Down Expand Up @@ -122,7 +121,7 @@ def draw_score(self):
screen.blit(self.score_img, (20, 20))

def set_ground(self):
shape = pymunk.Segment(space.static_body, (0, 10), (1200, 10), 4)
shape = pymunk.Segment(space.static_body, (0, 590), (1200, 590), 4)
shape.friction = 1
shape.collision_type = 3
space.add(shape)
Expand Down Expand Up @@ -158,7 +157,7 @@ def launch_bird(self, p0, p1):
"""Get two sling points to launch the bird."""
p0 = from_pygame(p0, screen)
p1 = from_pygame(p1, screen)
v = (Vec2d(p0) - Vec2d(p1)) * 10
v = (Vec2d(*p0) - Vec2d(*p1)) * 10
b = Bird(pos=p1)
b.body.apply_impulse_at_local_point(v)

Expand All @@ -169,31 +168,31 @@ def set_level(self, level):
self.set_ground()

if level == 1:
Column((1000, 100))
Column((1060, 100))
Beam((1030, 145))
Column((1000, 200))
Column((1060, 200))
Beam((1030, 245))
Pig((1140, 60))
Column((1000, 500))
Column((1060, 500))
Beam((1030, 455))
Column((1000, 400))
Column((1060, 400))
Beam((1030, 355))
Pig((1140, 540))

elif level == 2:
for i in range(2):
Column((1000, 60 + i*100))
Column((1060, 60 + i*100))
Beam((1030, 105 + i*100))
Pig((1000, 60))
Column((995, 540 - i*100))
Column((1060, 540 - i*100))
Beam((1030, 495 - i*100))
Pig((1020, 540))

elif level == 3:
for x in range(500, 800, 30):
Column((x, 60))
Pig((850, 60))
Column((x, 540))
Pig((850, 540))

elif level == 4:
Column((500, 60))
Column((500, 540))
for x in range(500, 700, 85):
Column((x+83, 60))
Beam((x+40, 105))
Pig((x+40, 50))
Column((x+83, 540))
Beam((x+40, 495))
Pig((x+40, 550))

Pig((850, 100))
Pig((850, 500))