-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_block.py
216 lines (193 loc) · 7.49 KB
/
class_block.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import pygame
from colors import colors
from colour import Color
class Block(object):
colorbox = colors
highest_point = None
def __init__(self, x, y, size, height_ground, height_water, temp_surface, temp_air, clouds, color):
self.color = color
self.height_ground = height_ground
self.height_water = height_water
self.future_height_water = 0
self.temp_air = temp_air
# self.x = x
# self.y = y
# self.size = size
# self.temp_surface = temp_surface
# self.future_temp_air = 0
# self.cloud_concentration = clouds
# self.vegetation = []
# self.isDay = True
# self.filter = "waves map"
# self.wave_counter = 0
def update_data(self):
self.height_water += self.future_height_water
self.future_height_water = 0
# self.temp_air += self.future_temp_air
# self.future_temp_air = 0
# def pib(self):
# temp_difference = self.temp_surface - self.temp_air
# self.temp_air += (temp_difference * 20) / 100
# self.temp_surface -= (temp_difference * 5) / 100
# def draw(self, screen, x, y, size, highest_point, filter):
# color = (0, 0, 0)
# self.filter = filter
#
# if self.filter == "perlin noise":
# color = self.draw_perlin_noise()
#
# if self.filter == "elevation map":
# color = self.draw_elevation_map()
#
# if self.filter == "waves map color":
# color = self.draw_waves_map_color()
#
# if self.filter == "waves map wb":
# color = self.draw_waves_map_wb()
#
# if self.filter == "temperature air":
# color = self.draw_temperature_air()
#
# pygame.draw.rect(screen, color, (x, y, size, size))
def draw_test(self):
variation = int(self.highest_point)
green = Color("green")
gradient = list(green.range_to(Color("red"), int(self.highest_point)+10))
color = gradient[int(self.height_ground) - 1]
# if self.height_ground < variation * 2:
# color = gradient[0]
# elif self.height_ground < variation * 4:
# color = gradient[1]
# elif self.height_ground < variation * 6:
# color = gradient[2]
# elif self.height_ground < variation * 8:
# color = gradient[3]
# elif self.height_ground < variation * 10:
# color = gradient[4]
# elif self.height_ground < variation * 12:
# color = gradient[5]
# elif self.height_ground < variation * 14:
# color = gradient[6]
# else:
# color = gradient[7]
return str(color)
def draw_perlin_noise(self):
if self.height_ground < 1:
self.height_ground = 1
percent = (self.height_ground * 100) / self.highest_point
rgb = int((255 * percent) / 100)
color = (rgb, rgb, rgb)
return color
def draw_elevation_map(self):
variation = 18 # height difference of place
if self.height_water > 0:
if self.height_water < variation:
color = self.colorbox["Blue-gray Crayola"]
elif self.height_water < variation * 2:
color = self.colorbox["Blue Klein"]
elif self.height_water < variation * 3:
color = self.colorbox["Green-blue Crayola"]
elif self.height_water < variation * 4:
color = self.colorbox["Cobalt blue"]
else:
color = self.colorbox["Traffic blue"]
else:
if self.height_ground < variation * 2:
color = self.colorbox["Pearl green"]
elif self.height_ground < variation * 4:
color = self.colorbox["Dark spring green"]
elif self.height_ground < variation * 6:
color = self.colorbox["Green"]
elif self.height_ground < variation * 8:
color = self.colorbox["Muslim green"]
elif self.height_ground < variation * 10:
color = self.colorbox["Verdejo green"]
elif self.height_ground < variation * 12:
color = self.colorbox["Pear green"]
elif self.height_ground < variation * 14:
color = self.colorbox["Golden birch"]
else:
color = self.colorbox["Redhead"]
return color
def draw_waves_map_color(self):
water_level = 150
variation = 20
if self.height_water > 0:
if self.wave_counter > 30:
color = self.colorbox["Scarlet"]
elif self.wave_counter > 25:
color = self.colorbox["Red-orange Crayola"]
elif self.wave_counter > 20:
color = self.colorbox["Bittersweet"]
elif self.wave_counter > 15:
color = self.colorbox["Neon carrot"]
elif self.wave_counter > 10:
color = self.colorbox["Lemon-yellow Crayola"]
elif self.wave_counter > 5:
color = self.colorbox["Moderate aquamarine"]
elif self.wave_counter > 0:
color = self.colorbox["Blue screen of death"]
# elif self.wave_counter > -5:
# color = self.colorbox["Byzantine"]
# elif self.wave_counter > -15:
# color = self.colorbox["Dark magenta"]
# elif self.wave_counter < -15:
# color = self.colorbox["Byzantium"]
else:
color = (0, 0, 0)
else:
elevation = self.height_ground - water_level
if elevation < variation:
color = self.colorbox["Green"]
elif elevation < variation * 2:
color = self.colorbox["Muslim green"]
elif elevation < variation * 3:
color = self.colorbox["Verdejo green"]
elif elevation < variation * 4:
color = self.colorbox["Pear green"]
elif elevation < variation * 5:
color = self.colorbox["Golden birch"]
else:
color = self.colorbox["Redhead"]
return color
def draw_waves_map_wb(self):
water_level = 150
variation = 20
if self.height_water > 0:
rgb = (255 / 50) * self.wave_counter
if rgb > 255:
rgb = 255
if rgb < 0:
rgb = 0
color = (rgb, rgb, rgb)
else:
elevation = self.height_ground - water_level
if elevation < variation:
color = self.colorbox["Green"]
elif elevation < variation * 2:
color = self.colorbox["Muslim green"]
elif elevation < variation * 3:
color = self.colorbox["Verdejo green"]
elif elevation < variation * 4:
color = self.colorbox["Pear green"]
elif elevation < variation * 5:
color = self.colorbox["Golden birch"]
else:
color = self.colorbox["Redhead"]
return color
def draw_temperature_air(self):
if self.temp_air > 0:
rgb = (255 / 30) * self.temp_air
if rgb > 255:
rgb = 255
if rgb < 0:
rgb = 0
color = (rgb, 0, 0)
else:
rgb = (255 / 30) * abs(self.temp_air)
if rgb > 255:
rgb = 255
if rgb < 0:
rgb = 0
color = (0, 0, rgb)
return color