-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatforms.py
More file actions
145 lines (130 loc) · 4.08 KB
/
Copy pathplatforms.py
File metadata and controls
145 lines (130 loc) · 4.08 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
print(__name__, "Platforms")
from timer import Timer
import boards as Boards
#from main import kill
platcolors = {
0: (0, 0, 0),
1: (0, 255, 0),
2: (50, 50, 0),
3: (255, 0, 0),
4: (255, 150, 0),
}
placeprop = {
0: {
"#HasPlaceReq": False,
"#object": False,},
1: {
"#HasPlaceReq": False,
"#object": False,},
2: {
"#HasPlaceReq": True,
"xl": False,
"yl": 7,
"#object": False,},
3: {
"#HasPlaceReq": True,
"xl": False,
"yl": False,
"#object": False,},
4: {
"#HasPlaceReq": True,
"xl": 30,
"yl": 10,
"#object": True},
}
#Finds next available ID for platform listing, so that when a platform gets
#deleted, that spot is detected and used instead of never getting used
def NextID(platformList) -> int:
keylist = platformList.keys()
#print(keylist, platformList)
for i in range(len(platformList)):
if not i in keylist:
name = i
return name
return len(platformList)
class create():
def __init__(self, x, y, xl, yl, type = 0) -> None:
self.x = x
self.y = y
self.xl = xl
self.yl = yl
self.type = type
self.color = platcolors[self.type]
class collision():
#C = Character, P = Platform, L = Length
def check(cx, cy, cxl, cyl, px, py, pxl, pyl) -> list[bool]: #Checks
lis = [False, False, False, False, False]
if cy + cyl >= py and cy <= py + pyl:
if cx + cxl >= px and cx <= px + pxl:
lis[0] = True
if cy + cyl < py + 10 and cx + cxl > px and cx < px + pxl:
lis[1] = True
if cx + cxl < px + 20 and cy + cyl - 5 > py and cy < py + pyl:
lis[2] = True
if cy > py + pyl - 10 and cx + cxl > px and cx < px + pxl:
lis[3] = True
if cx > px + pxl - 20 and cy + cyl - 5> py and cy < py + pyl:
lis[4] = True
#print(lis, " | ", cx, cy, cxl, cyl, px, py, pxl, pyl)
return lis
class types():
def wall(prop) -> None:
wallcheck = prop["wallcheck"]
char = prop["char"]
pTBC = prop["platformToBeChecked"]
if wallcheck[1]:
char.gr = True
char.y = pTBC.y - char.yl
char.yv = 0
#Timer.set("dashcool", True)
Timer.set("CoyoteTime", 0, True)
#Left
if wallcheck[2]:
char.x = pTBC.x - char.yl
if Timer.get("grace", True) > 5:
char.xv = 0
else:
Timer.set("grace", 0, True)
#Bottom
if wallcheck[3]:
char.yv = 0
char.y = pTBC.y + pTBC.yl
#Right
if wallcheck[4]:
char.x = pTBC.x + pTBC.xl
if Timer.get("grace", True) > 5:
char.xv = 0
else:
Timer.set("grace", 0, True)
if wallcheck[2] or wallcheck[4]:
char.wj = True
char.w = [wallcheck[2], wallcheck[4]]
def passthrough(prop) -> None:
wallcheck = prop["wallcheck"]
char = prop["char"]
pTBC = prop["platformToBeChecked"]
if wallcheck[1]:
if char.yv >= 0 and not Boards.getP("down"):
char.gr = True
char.y = pTBC.y - char.yl
char.yv = 0
#Timer.set("dashcool", True)
Timer.set("CoyoteTime", 0, True)
def lava(prop) -> None:
if prop["wallcheck"][0]:
prop["char"].die()
def bounce(prop) -> None:
char = prop["char"]
if prop["wallcheck"][0]:
char.resetDash()
char.yv = -22
if char.xv > char.speed:
char.xv = char.speed
elif char.xv < -char.speed:
char.xv = -char.speed
functionList = {
1: wall,
2: passthrough,
3: lava,
4: bounce,
}