-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiles.py
162 lines (125 loc) · 5.94 KB
/
tiles.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
'''
Nodes, holds, arcs
'''
import pygame
from variables import *
from text_writer import *
import math
class Node():
def __init__(self,line,point,given_fps, special = None):
global judgement_line, height, node_color ,bad_apple_toggled_color,bad_apple_color,debug_color,change_background_color
self.given_fps = given_fps
self.judgement_line = judgement_line
self.height = height
self.name = 'node'
self.y = node_spawning_y_pos
self.line = line # 몇 번 line에 넣을지 결정
self.node_color = node_color
self.color = node_color[change_background_color[0]] #node_color
self.bad_apple_toggled_color = bad_apple_toggled_color
self.bad_apple_color = bad_apple_color
self.debug_color = debug_color
self.point = point
if special == '': # replace it to None object
special = None
self.special = special # special node
def draw(self, screen, screen_freeze = False):
if self.special == 'BadApple':
if screen_freeze: # at screen freeze
pygame.draw.rect(screen, self.bad_apple_toggled_color,
[line_axes[self.line - 1] - line_width // 2, self.y - node_height // 2, line_width,
node_height])
else: # no screen freeze
pygame.draw.rect(screen, self.bad_apple_color,
[line_axes[self.line - 1] - line_width // 2, self.y - node_height // 2, line_width,
node_height])
elif self.special == 'Debug':
pygame.draw.rect(screen, self.debug_color,
[line_axes[self.line - 1] - line_width // 2, self.y - node_height // 2, line_width,
node_height])
else:
pygame.draw.rect(screen, self.node_color[change_background_color[0]],
[line_axes[self.line - 1] - line_width // 2, self.y - node_height // 2, line_width,
node_height])
def move(self,speed):
self.y += (speed*10/self.given_fps)
def fix_loc(self, loc = None):
if loc:
self.y = loc
else:
self.y = self.judgement_line
def check_border(self):
if self.special == 'BadApple' and self.y > self.judgement_line + 5: # 'Late' for special node
#print('border cross for Bad apple!')
return True # border crossed for special node
if creater_mode:
if self.y >= self.judgement_line: #self.height: # then node arrived at the border!
#print("Border!")
return True
else:
return False
else:
if self.y >= self.height: # then node arrived at the border!
#print("Border!")
return True
else:
return False
def special_effect(self):
if self.special=='BadApple':
return 'wait'
def freeze(self):
self.color = self.node_color[change_background_color[0]]
class Hold():
def __init__(self,line,point,length,given_fps,special=None):
global judgement_line, height, hold_color, holding_middle_color , not_holding_color,not_holding_middle_color, debug_color,change_background_color
self.given_fps = given_fps
self.judgement_line = judgement_line
self.height = height
self.name = 'hold'
self.y = node_spawning_y_pos # hold 노드의 y 값은 제일 아래쪽의 y좌표이다. 즉, 홀드 노드의 시작점 좌표!
self.length = length
self.tail = self.y-self.length
self.holding = False # 자신이 눌러지고 있는지 판단
self.line = line # 몇 번 line에 넣을지 결정
self.debug_color = debug_color
self.not_holding_middle_color = not_holding_middle_color
self.holding_middle_color = holding_middle_color
self.color = hold_color[change_background_color[0]] #self.not_holding_color
self.middle_color = not_holding_middle_color
self.hold_color = hold_color
self.point = point
self.this_judgement_pos = node_spawning_y_pos
if special == '': # replace it to None object
special = None
self.special = special # special node
def draw(self,screen,screen_update = True):
if self.special == 'Debug':
pygame.draw.rect(screen,self.debug_color ,[line_axes[self.line-1]-line_width//2,max(self.y-self.length,info_length),line_width,min(self.length,self.y-info_length)])
else:
pygame.draw.rect(screen,self.hold_color[change_background_color[0]],[line_axes[self.line-1]-line_width//2,max(self.y-self.length,info_length),line_width,min(self.length,self.y-info_length)])
pygame.draw.rect(screen,self.middle_color ,[line_axes[self.line-1]-line_width//16,max(self.y-self.length,info_length),line_width//8,min(self.length,self.y-info_length)])
def update_color(self):
if self.holding:
self.middle_color = self.holding_middle_color
else:
self.middle_color = self.not_holding_middle_color
def move(self,speed):
increment = (speed*10/self.given_fps)
self.y += increment
self.this_judgement_pos += increment
self.tail = self.y - self.length
def fix_loc(self, loc = None):
if loc:
self.y = loc
else:
self.y = self.judgement_line
def check_border(self):
if self.tail>= self.height: # then node arrived at the border!
#print("Border!")
return True
else:
return False
def special_effect(self,screen):
pass
def freeze(self):
self.color = self.hold_color[change_background_color[0]]