-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer_file.py
More file actions
28 lines (23 loc) · 1.06 KB
/
player_file.py
File metadata and controls
28 lines (23 loc) · 1.06 KB
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
import pygame
import config
class player_class:
def __init__(self, x_position, y_position):
print("Player created")
self.position = [x_position, y_position]
self.image = pygame.image.load("imgs/player_down.png")
self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
self.rect = pygame.Rect(self.position[0]*config.SCALE,
self.position[1]*config.SCALE,
config.SCALE,
config.SCALE)
def update(self):
print("Player updated")
def update_position(self, new_position):
self.position[0] = new_position[0]
self.position[1] = new_position[1]
def render(self, screen, camera):
screen.blit(self.image, self.rect)
self.rect = pygame.Rect(self.position[0]*config.SCALE-(camera[0]*config.SCALE),
self.position[1]*config.SCALE-(camera[1]*config.SCALE),
config.SCALE,
config.SCALE)