This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
69 lines (53 loc) · 1.92 KB
/
app.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
import arcade
from src.characters.luffy.model import LuffyPlayer
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
SCALE = 2
PLAYER_1_DEFAULT_POSITION = "right"
PLAYER_2_DEFAULT_POSITION = "left"
DIRECTION_LEFT = -1
DIRECTION_RIGHT = 1
class MyGame(arcade.Window):
def __init__(self):
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "One Fight")
self.background = None
self.move_speed = 0
self.player_1 = LuffyPlayer(280, 100, PLAYER_1_DEFAULT_POSITION)
self.player_2 = LuffyPlayer(1000, 100, PLAYER_2_DEFAULT_POSITION)
def setup(self):
self.background = arcade.load_texture("assets/backgrounds/arena.png")
def on_draw(self):
arcade.start_render()
arcade.draw_texture_rectangle(
SCREEN_WIDTH // 2,
SCREEN_HEIGHT // 2,
SCREEN_WIDTH,
SCREEN_HEIGHT,
self.background
)
self.player_1.draw()
self.player_2.draw()
def update(self, delta_time):
self.player_1.update()
self.player_2.update()
hit_list = arcade.check_for_collision(self.player_1.animation.get_sprite(), self.player_2.animation.get_sprite())
if self.move_speed != 0: # If player is moving
self.player_1.move(self.move_speed)
def on_key_press(self, symbol: int, modifiers: int):
if symbol == arcade.key.LEFT:
self.move_speed = DIRECTION_LEFT
if symbol == arcade.key.RIGHT:
self.move_speed = DIRECTION_RIGHT
if symbol == arcade.key.K:
self.player_1.action_basic_attack(-1)
def on_key_release(self, symbol: int, modifiers: int):
if symbol == arcade.key.LEFT:
self.player_1.stop("left")
self.move_speed = 0
elif symbol == arcade.key.RIGHT:
self.player_1.stop("right")
self.move_speed = 0
if __name__ == "__main__":
window = MyGame()
window.setup()
arcade.run()