-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathada_potato_sprite.py
More file actions
35 lines (28 loc) · 877 Bytes
/
ada_potato_sprite.py
File metadata and controls
35 lines (28 loc) · 877 Bytes
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
import arcade
import random
from ap_game_constants import *
ADA_IMAGE = arcade.load_texture("images/ada.png", scale=.25)
POTATO_IMAGE = arcade.load_texture("images/potato.png", scale=.25)
class AdaOrPotato(arcade.Sprite):
timer: int
def __init__(self):
super().__init__()
self.texture = ADA_IMAGE
self.timer = 0
self.center_x = random.randint(0, WINDOW_WIDTH)
self.center_y = WINDOW_HEIGHT / 2
def update(self):
self.timer += 1
if self.timer > TIMER_MAXIMUM:
self.timer = 0
self.switch_image()
def switch_image(self):
if self.texture == ADA_IMAGE:
self.texture = POTATO_IMAGE
else:
self.texture = ADA_IMAGE
def get_current_value(self):
if self.texture == ADA_IMAGE:
return 1
else:
return -1