2019-04-10 10:31:09 +02:00
|
|
|
import pygame
|
2019-04-16 13:28:11 +02:00
|
|
|
from pygame.math import Vector2
|
|
|
|
|
|
|
|
|
2019-04-10 10:31:09 +02:00
|
|
|
class GridElement(object):
|
|
|
|
def __init__(self, x, y, game):
|
|
|
|
self.game = game
|
2019-04-16 13:28:11 +02:00
|
|
|
self.position = Vector2()
|
|
|
|
self.position.x = x
|
|
|
|
self.position.y = y
|
2019-04-10 10:31:09 +02:00
|
|
|
game.idItem += 1
|
|
|
|
self.number = game.idItem
|
|
|
|
|
2019-04-16 13:43:41 +02:00
|
|
|
#Cała matematyka skalowania odbywa się tutaj
|
2019-04-10 10:31:09 +02:00
|
|
|
def draw(self):
|
2019-04-16 13:28:11 +02:00
|
|
|
self.rect = pygame.Rect(self.position.x * self.game.gridElementWidth, self.position.y * self.game.gridElementHeight, self.game.gridElementWidth, self.game.gridElementHeight)
|
|
|
|
self.game.screen.blit(self.image, (self.position.x * self.game.gridElementWidth, self.position.y * self.game.gridElementHeight))
|