-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtile.py
More file actions
29 lines (24 loc) · 945 Bytes
/
Copy pathtile.py
File metadata and controls
29 lines (24 loc) · 945 Bytes
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
import pygame as pg
from configuraçoes import *
from pygame.math import Vector2 as vector
class Tile(pg.sprite.Sprite):
def __init__(self, pos, surf, groups, z):
super().__init__(groups)
self.image = surf
self.rect = self.image.get_rect(topleft = pos)
self.z = z
class CollisionTile(Tile):
def __init__(self, pos, surf, groups):
super().__init__(pos, surf, groups, Camadas["Level"])
self.old_rect = self.rect.copy()
class MovingPlatform(CollisionTile):
def __init__(self, pos, surf, groups):
super().__init__(pos, surf, groups)
#float based movement
self.direction = vector(0, -1)
self.speed = 200
self.pos = vector(self.rect.topleft)
def update(self, deltatime):
self.old_rect = self.rect.copy()
self.pos.y += self.direction.y * self.speed * deltatime
self.rect.topleft = (round(self.pos.x), round(self.pos.y))