-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
50 lines (41 loc) · 1.24 KB
/
main.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
import arcade
import random
from math import *
import time
from GenarateTerain import MyTerain
class MyGame(arcade.Window):
def __init__(self, width, height, title, resizable = False):
super().__init__(width, height, title, resizable = resizable)
self.MyTerain = MyTerain(width, height)
self.player_x = 0
self.player_speed = 300
self.right = False
self.left = False
def on_draw(self):
arcade.start_render()
self.worldlist = self.MyTerain.world_list_uncomplied
self.worldlist.draw()
def update(self, delta_time):
self.MyTerain.load_unload_chunks(self.player_x)
if self.right == True:
self.player_x += self.player_speed * delta_time
if self.left == True:
self.player_x -= self.player_speed * delta_time
def on_key_press(self, symbol, modifiers):
if symbol == arcade.key.D:
self.right = True
if symbol == arcade.key.A:
self.left = True
def on_key_release(self, symbol, modifiers):
if symbol == arcade.key.D:
self.right = False
if symbol == arcade.key.A:
self.left = False
def on_mouse_press(self, x, y, button, modifiers):
if button == arcade.MOUSE_BUTTON_LEFT:
self.MyTerain.destroy_block(x,y)
def main():
game = MyGame(1270, 700, "Game", resizable=True)
arcade.run()
if __name__ == "__main__":
main()