diff options
author | Tim Ansell <mithro@mithis.com> | 2009-01-20 10:59:49 (GMT) |
---|---|---|
committer | Tim Ansell <mithro@mithis.com> | 2009-01-20 10:59:49 (GMT) |
commit | 747a90f1c2b05f3c36aa94e37bfbb914458b9185 (patch) | |
tree | 0b1b8ef9d51a5938acc38fdb40b2ecb8131b9786 | |
parent | 012d24122942ceead108a77101515a9d0180976b (diff) |
Really, really crappy collision detection.
-rw-r--r-- | child.png | bin | 1818 -> 1713 bytes | |||
-rw-r--r-- | ovpc.py | 15 | ||||
-rw-r--r-- | raptor.png | bin | 5461 -> 5343 bytes |
3 files changed, 14 insertions, 1 deletions
Binary files differ @@ -4,6 +4,7 @@ import pyglet from pyglet.window import key from random import randrange, random import math +import time from pyglet.gl import * window = pyglet.window.Window(800, 400, caption='OVPC') @@ -48,13 +49,25 @@ def update(dt): if child.y < 0: child.y = 0 - for raptor in pack: + for i, raptor in enumerate(pack): if raptor.x < (0 - raptor.width): reset_enemy(raptor) raptor.x -= dt * 150 raptor.y += dt * randrange(-100, 100) + if raptor.x < child.x: + continue + + if raptor.y+raptor.height*0.5 < child.y: + continue + + if raptor.y-raptor.height*0.5 > child.y+child.height*0.5: + continue + + if (raptor.x-child.x) < (child.width+raptor.width)*0.5-10: + print time.time(), "Collision with", i + @window.event def on_draw(): window.clear() Binary files differ |