Player Class - Code
From RoboWiki
Return back to project page: Game Controller - Jakub Vojtek
Python code for the Color Sorter project:
import pygame
class Player:
def __init__(self, x, y, width, height, speed):
self.x = x
self.y = y
self.width = width
self.height = height
self.speed = speed
self.image = pygame.image.load("pictures/jet.png").convert_alpha()
self.image = pygame.transform.rotate(self.image, 90) # Rotate the image 90 degrees left
self.image = pygame.transform.scale(self.image, (width, height)) # Resize the image
def move_left(self):
self.x -= self.speed
def move_right(self):
self.x += self.speed