-
Notifications
You must be signed in to change notification settings - Fork 0
/
maryolib.py
52 lines (38 loc) · 1.19 KB
/
maryolib.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pygame
# RGB renk tanimlamalari
BLACK = (0, 0, 0)
GREEN = (20, 255, 140)
GREY = (210, 210, 210)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
PURPLE = (255, 0, 255)
YELLOW = (255, 255, 0)
CYAN = (0, 255, 255)
BLUE = (100, 100, 255)
class MaryoImageObject(pygame.sprite.Sprite):
def __init__(self, width, height, image_path, x=0, y=0):
super(MaryoImageObject, self).__init__()
self.width = width
self.height = height
self.image = pygame.image.load(image_path).convert_alpha()
self.image = pygame.transform.scale(self.image, (width, height))
self.rect = self.image.get_rect()
self.weight = 50
self.down_speed = 1
self.is_jumped = True
self.move_to(x,y)
def apply_gravity(self):
if self.is_jumped:
self.move_down(self.down_speed)
self.down_speed += 1
def move_to(self, x, y):
self.rect.x = x
self.rect.y = y
def move_right(self, pixels=5):
self.rect.x += pixels
def move_left(self, pixels=5):
self.rect.x -= pixels
def move_down(self, pixels=5):
self.rect.y += pixels
def move_up(self, pixels=5):
self.rect.y -= pixels