-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter.py
More file actions
21 lines (19 loc) · 731 Bytes
/
character.py
File metadata and controls
21 lines (19 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from kivy.uix.image import Image
from kivy.app import App
class Character(Image):
velocity = 0
pos_x = 3
moving = False
def on_touch_move(self, touch):
if self.moving == False:
if touch.dx > 0:
self.velocity = 1000
elif touch.dx < 0:
self.velocity = -1000
super().on_touch_move(touch)
def on_touch_up(self, touch):
if self.velocity > 0:
self.source = "Images/jump_images/" + App.get_running_app().current_character + "_jump_right.png"
elif self.velocity < 0:
self.source = "Images/jump_images/" + App.get_running_app().current_character + "_jump_left.png"
return super().on_touch_up(touch)