-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditor.py
More file actions
52 lines (49 loc) · 2.35 KB
/
Editor.py
File metadata and controls
52 lines (49 loc) · 2.35 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
import arcade
class Editor(arcade.Window):
def __init__(self):
super().__init__(1000, 1000, "Labyrinth")
self.block_liste= arcade.SpriteList(use_spatial_hash=True)
self.hintergrund_liste=arcade.SpriteList(use_spatial_hash=True)
self.mauern=[(1,1)]
Level=open("Level.txt","r")
self.mauern=Level.readline(2).split(";")
print(self.mauern)
for i in range(20):
for j in range(20):
block=arcade.Sprite("Grafiken/Mauer.png")
if (i,j) in self.mauern:
#block.color=75, 128, 83
block.center_x=(i*50)+25
block.center_y=(j*50)+25
self.block_liste.append(block)
else:
block.color=75, 128, 83
block.center_x=(i*50)+25
block.center_y=(j*50)+25
self.hintergrund_liste.append(block)
def on_mouse_press(self, x: int, y: int, button: int, modifiers: int):
self.mouse_position=arcade.Sprite()
self.mouse_position.set_hit_box([(-1,-1),(-1,1),(1,-1),(1,1)])
self.mouse_position.center_x=x
self.mouse_position.center_y=y
if arcade.check_for_collision_with_list(self.mouse_position,self.hintergrund_liste):
block=arcade.check_for_collision_with_list(self.mouse_position,self.hintergrund_liste)[0]
block.color=255,255,255
self.block_liste.append(block)
self.hintergrund_liste.remove(arcade.check_for_collision_with_list(self.mouse_position,self.hintergrund_liste)[0])
elif arcade.check_for_collision_with_list(self.mouse_position,self.block_liste):
block=arcade.check_for_collision_with_list(self.mouse_position,self.block_liste)[0]
block.color=75, 128, 83
self.hintergrund_liste.append(block)
self.block_liste.remove(arcade.check_for_collision_with_list(self.mouse_position,self.block_liste)[0])
return super().on_mouse_press(x, y, button, modifiers)
def on_update(self, delta_time: float):
self.hintergrund_liste.update()
self.block_liste.update()
return super().on_update(delta_time)
def on_draw(self):
self.clear()
self.hintergrund_liste.draw()
self.block_liste.draw()
Editor()
arcade.run()