Files

84 lines
2.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import arcade
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
class Player(arcade.Sprite):
def __init__(self):
super().__init__(
':resources:/images/animated_characters/female_adventurer/femaleAdventurer_idle.png',
scale = 1
)
self.center_x = SCREEN_WIDTH//2
self.center_y = SCREEN_HEIGHT//2
#self.texture_left = arcade.SpriteSheet('./tiles/gold.png').get_texture_grid((64,64),4,4)
class Object(arcade.Sprite):
def __init__(self,x,y):
super().__init__()
self.textures = arcade.SpriteSheet('./assets/tiles/BODY_animation.png').get_texture_grid((64,64),8,8)
self.center_x = x
self.center_y = y
self.cur_texture = 0
self.set_texture(self.cur_texture)
self.timer = 0
def update(self,delta_time):
self.timer += delta_time
if self.timer >= 0.5:
if self.cur_texture >= len(self.textures)-1:
self.cur_texture = 0
else:
self.cur_texture += 1
self.timer = 0
self.set_texture(self.cur_texture)
class MainView(arcade.View):
def __init__(self):
super().__init__()
self.background_color = (100,100,200)
self.player = Player()
self.sprite_list = arcade.SpriteList()
self.sprite_list.append(self.player)
self.sprite_list.append(Object(100,50))
self.tilemap = arcade.load_tilemap('./assets/level1.tmx', scaling=1)
self.flor_list = self.tilemap.sprite_lists["flor"]
def on_update(self,delta_time):
self.sprite_list.update()
def on_draw(self):
self.clear()
self.flor_list.draw()
arcade.draw_circle_filled(400,300,100,(255,255,0))
arcade.draw_circle_filled(350,330,20,(0,0,0))
arcade.draw_arc_outline(400,280,150,100,(0,0,0),200,340,10)
self.sprite_list.draw()
arcade.draw_circle_filled(450,330,20,(0,0,0))
def on_key_press(self,key,mod):
if key == arcade.key.A:
self.player.change_x = -5
elif key == arcade.key.D:
self.player.change_x = 5
elif key == arcade.key.W:
self.player.change_y = 5
elif key == arcade.key.S:
self.player.change_y = -5
def on_key_release(self,key,mod):
if key == arcade.key.A or key == arcade.key.D:
self.player.change_x = 0
if key == arcade.key.W or key == arcade.key.S:
self.player.change_y = 0
if __name__ == '__main__':
window = arcade.Window(SCREEN_WIDTH,SCREEN_HEIGHT,'Игра с видом сверху')
view = MainView()
window.show_view(view)
arcade.run()