-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter.py
More file actions
146 lines (135 loc) · 4.73 KB
/
Copy pathcharacter.py
File metadata and controls
146 lines (135 loc) · 4.73 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
146
import boards as Boards
import cameramanager as cam
from timer import Timer
import tomllib, os
#import main
colors = {
"red": (255,0, 0 ),
"green": (0, 255,0 ),
"blue": (0, 0, 255),
"gray": (30, 30, 30 ),
}
class create():
def __init__(self):
with open(os.getcwd()+'\ConfigFiles\characterProperties.toml', "rb") as f:
configFile = tomllib.load(f)
print(configFile)
self.x = configFile['body']['xpos']
self.y = configFile['body']['ypos']
self.xl = configFile['body']['xlength']
self.yl = configFile['body']['ylength']
self.xv = 0
self.yv = 0
self.allowControl = True
self.gr = False
self.st = False
self.wj = False
self.w = None
self.dead = False
self.speed = configFile['run']['runSpeed']
self.acc = configFile['run']['runAcceleration']
self.decel = configFile['run']['runDeceleration']
self.dyndecel = 1
self.jumppower = configFile['jump']['jumpPower']
self.gravity = configFile['jump']['gravityStrength']
self.dashes = configFile['dash']['dashCount']
self.dashstate = False
self.dashleave = True
self.dashlength = configFile['dash']['dashLength']
self.dashcooldown = configFile['dash']['dashCooldownLength']
self.dashspeed = configFile['dash']['dashSpeed']
self.dashlist = [False, False, False, False]
self.dashslow = configFile['dash']['dashDeceleration']
self.color = colors["red"]
self.DCsuper = 0
self.DChyper = 0
def die(self):
self.x = 500
self.y = 0
self.xv = 0
self.dashes = 1
self.dead = True
def jump(self):
self.yv = self.jumppower
self.gr = False
self.dashslow = 1
self.xv * 2
self.dashslow = 1
if self.dashleave or self.dashstate:
print("Dash Cancel")
if not self.xv == 0:
self.xv = abs(self.xv)/ self.xv * 24
if self.dashlist[3] == True:
print("Hyper")
self.yv = -13
self.xv *= 3
def walljump(self, wallcheck):
if wallcheck[0] and wallcheck[1]:
self.yv = self.jumppower
elif wallcheck[0]:
self.xv = -7
self.yv = self.jumppower
elif wallcheck[1]:
self.xv = 7
self.yv = self.jumppower
if self.dashleave or self.dashstate:
if self.dashlist[0]:
print("Dash Cancel")
self.yv *= 1.2
self.xv *= 1.5
#Run on the first frame of a check
def dash(self):
input = ["up", "left", "right", "down", "jump", "dash"]
self.dashes -= 1
self.dashslow = 2
for i in range(4):
if Boards.getP(input[i]):
self.dashlist[i] = True
if self.dashlist == [False, False, False, False]:
self.dashlist[2] = True
#Run every frame, to run checks and blocks of code for all dash related stuff
def dashManager(char):
if not Timer.get("dash") and char.dashstate:
char.color = colors["green"]
if char.dashlist[0]:
if char.yv > -char.dashspeed:
char.yv = -char.dashspeed
if char.dashlist[1]:
if char.xv > -char.dashspeed:
char.xv = -char.dashspeed
if char.dashlist[2]:
if char.xv < char.dashspeed:
char.xv = char.dashspeed
if char.dashlist[3]:
if char.yv < char.dashspeed:
char.yv = char.dashspeed
if char.dashlist[3]:
if char.dashlist[0]:
char.yv = 0
# char.xv *= 1.2
elif char.dashstate:
char.dashstate = False
char.dashleave = True
char.color = (200, 200, 200)
Timer.set("dashleave", char.dashcooldown)
if Timer.get("dashleave") == False:
if char.gr:
char.dashes = 1
if Timer.get("dashleave") == True:
char.dashlist = [False, False, False, False]
char.dashleave = False
char.color = colors["blue"]
if char.dashes > 0:
char.color = colors["red"]
if char.dashslow > 1:
char.dashslow / 1.066
if char.dashslow < 1:
char.dashslow = 1
#print(char.dashlist, Timer.get("dash"))
def resetDash(self):
self.dashes = 1
self.dashstate = False
self.dashleave = False
Timer.set("dashleave", True)
Timer.set("dash", True)
Timer.set("dashcool", True)