Commit 11db5f12 authored by Alan Aguiar's avatar Alan Aguiar
Browse files

if width grows, grows buildings

parent cbc19748
......@@ -3,43 +3,29 @@
# -*- coding: utf-8 -*-
import pygame
import math
build = pygame.image.load('images/buildings.png')
class Build(pygame.sprite.Sprite):
def __init__(self, x=0, y=0):
def __init__(self, parent, x=0, y=0):
pygame.sprite.Sprite.__init__(self)
self.parent = parent
self.mPos = [x, y]
self.image = pygame.surface.Surface((684, 229), 0)
if self.parent.game_w > 684:
t = math.ceil(self.parent.game_w / 684.0)
t = int(t)
else:
t = 1
self.image = pygame.surface.Surface((684 * t, 229), 0)
self.image.fill((255, 255, 255))
self.image.blit(build, (0, 0))
for i in range(t):
self.image.blit(build, (684 * i, 0))
self.image.set_colorkey((255, 255, 255))
self.rect = self.image.get_rect()
self.rect.x = self.mPos[0]
self.rect.y = self.mPos[1]
def setXY(self, aX, aY):
self.mPos = [aX, aY]
def setPosTuple(self, position):
self.mPos = position
def setVel(self, aVec):
self.mVel = aVec
def getX(self):
return self.mPos[0]
def getY(self):
return self.mPos[1]
def getSize(self):
return (self.rect[2], self.rect[3])
def destroy(self):
self.image = None
......@@ -80,7 +80,7 @@ class Flappy():
########################################################################
self.floor = Floor(0, self.floor_y, GAME_SIZE[0])
self.floor.mVel = 0
self.build = Build(0, self.build_y)
self.build = Build(self, 0, self.build_y)
self.bird = Bird(self, self.bird_x, self.bird_y)
self.bird.mAcc = 0
self.end_scores = EndScore(self.end_s_x, 200)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment