-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspaceship.py
35 lines (27 loc) · 841 Bytes
/
spaceship.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
import os
import pygame
#speed of spaceship
STEP = 20
class Spaceship():
def __init__(self, window):
self.window = window
self.img = pygame.image.load(os.path.join('assets/img', 'space-invaders.png'))
self.x = 370
self.y = 480
#Returns spaceship position on x/y axis
def getX(self):
return self.x
def getY(self):
return self.y
#Initialises ship movement on x/y axis, and creates boundaries for movement
def move_left(self):
self.x -= STEP
if self.x <= 0:
self.x = 0
def move_right(self):
self.x += STEP
if self.x >= 735:
self.x = 735
#applies spaceship image on screen
def show(self):
self.window.blit(self.img,(self.x,self.y))