Заготовка игры танки

This commit is contained in:
2026-05-25 15:44:45 +03:00
parent 3b8452da18
commit 3029eaf485
113 changed files with 278 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
import arcade
import math
from tank import Tank
from map import Map
from bullet import Bullet
from bonus import Bonus
SCREEN_WIDTH = 768
SCREEN_HEIGHT = 576
class MainView(arcade.View):
def __init__(self):
super().__init__()
self.background_color = (100,100,200)
self.map = Map(SCREEN_WIDTH,SCREEN_HEIGHT,64,64)
self.player = list(filter(lambda tank: tank.type=='player', Tank.ls))[0]
def on_draw(self):
self.clear()
self.map.draw()
Tank.draw()
Bonus.draw()
Bullet.draw()
def on_update(self,time_delta):
Tank.update()
Bonus.update_list(time_delta)
Bullet.update_list()
def on_mouse_motion(self,x,y,dx,dy):
self.player.gun_to_xy(x,y)
def on_key_press(self,key,mod):
if key == arcade.key.A:
self.last_key = key
self.player.move(-1,0)
elif key == arcade.key.D:
self.last_key = key
self.player.move(1,0)
elif key == arcade.key.W:
self.last_key = key
self.player.move(0,1)
elif key == arcade.key.S:
self.last_key = key
self.player.move(0,-1)
def on_key_release(self,key,mod):
if self.last_key == key:
self.player.move(0,0)
def on_mouse_press(self,x,y,but,mod):
if but == 1:
self.player.shoot()
if __name__ == '__main__':
window = arcade.Window(SCREEN_WIDTH,SCREEN_HEIGHT,"Моя игра")
view = MainView()
window.show_view(view)
arcade.run()