/
PlayerEnvCollision.py
44 lines (33 loc) · 1.12 KB
/
PlayerEnvCollision.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pygame
#~ from gameobjects import Player
#~ from gameobjects import StaticObject
import pymunk as pm
from pymunk import Vec2d
import math, sys, random
from utilities import ExitTimer
class PlayerEnvCollision(object):
@staticmethod
def begin(space, arbiter, jukebox):
player_shape, env_shape = arbiter.shapes
player_shape.gameobject.normal = arbiter.contacts[0].normal
#~ if arbiter.contacts[0].normal.y > 0:
#~ # If moving downwards from above
#~ player_shape.gameobject.ground_collision()
return True
@staticmethod
def pre_solve(space, arbiter, jukebox):
#~ a, b = arbiter.shapes
player_shape, env_shape = arbiter.shapes
return True
@staticmethod
def post_solve(space, arbiter, jukebox):
player_shape, env_shape = arbiter.shapes
#~ if(player_shape.body.velocity.y < 0 and player_shape.body.position.y > env_shape.body.position.y):
if arbiter.contacts[0].normal.y > 0:
# If moving downwards from above
player_shape.gameobject.ground_collision()
return True
@staticmethod
def separate(space, arbiter, jukebox):
#~ player_shape, env_shape = arbiter.shapes
return True