Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Ansell <mithro@mithis.com>2009-01-20 10:59:49 (GMT)
committer Tim Ansell <mithro@mithis.com>2009-01-20 10:59:49 (GMT)
commit747a90f1c2b05f3c36aa94e37bfbb914458b9185 (patch)
tree0b1b8ef9d51a5938acc38fdb40b2ecb8131b9786
parent012d24122942ceead108a77101515a9d0180976b (diff)
Really, really crappy collision detection.
-rw-r--r--child.pngbin1818 -> 1713 bytes
-rw-r--r--ovpc.py15
-rw-r--r--raptor.pngbin5461 -> 5343 bytes
3 files changed, 14 insertions, 1 deletions
diff --git a/child.png b/child.png
index 5c74e53..2e5ce0c 100644
--- a/child.png
+++ b/child.png
Binary files differ
diff --git a/ovpc.py b/ovpc.py
index 14da6ae..ceb87e8 100644
--- a/ovpc.py
+++ b/ovpc.py
@@ -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()
diff --git a/raptor.png b/raptor.png
index 5091fcc..57d7369 100644
--- a/raptor.png
+++ b/raptor.png
Binary files differ