Trashmaster/agent.py

30 lines
700 B
Python
Raw Normal View History

2022-03-09 22:39:34 +01:00
import pygame.image
class trashmaster(pygame.sprite.Sprite):
2022-03-22 11:55:01 +01:00
def __init__(self,x,y,img):
2022-03-09 22:39:34 +01:00
super().__init__()
2022-03-22 11:55:01 +01:00
self.width=x
self.height=y
self.x = 0
self.y = 0
2022-03-11 13:00:11 +01:00
self.image = pygame.image.load(img)
2022-03-22 11:55:01 +01:00
self.image = pygame.transform.scale(self.image, (self.width,self.height))
2022-03-09 22:39:34 +01:00
self.rect = self.image.get_rect()
2022-03-22 11:55:01 +01:00
def movement(self, key, vel):
if key == pygame.K_LEFT:
self.x -= vel
if key == pygame.K_RIGHT:
self.x += vel
if key == pygame.K_UP:
self.y -= vel
if key == pygame.K_DOWN:
self.y += vel
return (self.x, self.y)