added obstacles
This commit is contained in:
parent
5399d5309c
commit
7d0416f130
@ -5,6 +5,7 @@ from trash import *
|
||||
from truck1 import *
|
||||
from walls import *
|
||||
from settings import *
|
||||
from obstacle import *
|
||||
|
||||
|
||||
class Game:
|
||||
@ -39,6 +40,14 @@ class Game:
|
||||
garbageTruck(self, col, row)
|
||||
if tile == 't':
|
||||
Trash(self, col, row)
|
||||
if tile == 'g':
|
||||
Granny(self, col, row)
|
||||
if tile == 's':
|
||||
Sh(self, col, row)
|
||||
if tile == 'p':
|
||||
Puddle(self, col, row)
|
||||
if tile == 'd':
|
||||
Dog(self, col, row)
|
||||
|
||||
def run(self):
|
||||
self.playing = True
|
||||
|
61
main/src/obstacle.py
Normal file
61
main/src/obstacle.py
Normal file
@ -0,0 +1,61 @@
|
||||
import pygame as pg
|
||||
from settings import TILESIZE
|
||||
|
||||
|
||||
class Puddle(pg.sprite.Sprite):
|
||||
def __init__(self, game, x, y):
|
||||
image = pg.image.load("img\\kaluza.png")
|
||||
self.groups = game.all_sprites
|
||||
pg.sprite.Sprite.__init__(self, self.groups)
|
||||
self.game = game
|
||||
self.image = pg.Surface((TILESIZE, TILESIZE))
|
||||
self.rect = self.image.get_rect()
|
||||
self.image.blit(image, (0, 0))
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.rect.x = x * TILESIZE
|
||||
self.rect.y = y * TILESIZE
|
||||
|
||||
|
||||
class Dog(pg.sprite.Sprite):
|
||||
def __init__(self, game, x, y):
|
||||
image = pg.image.load("img\\pies.png")
|
||||
self.groups = game.all_sprites
|
||||
pg.sprite.Sprite.__init__(self, self.groups)
|
||||
self.game = game
|
||||
self.image = pg.Surface((TILESIZE, TILESIZE))
|
||||
self.rect = self.image.get_rect()
|
||||
self.image.blit(image, (0, 0))
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.rect.x = x * TILESIZE
|
||||
self.rect.y = y * TILESIZE
|
||||
|
||||
class Granny(pg.sprite.Sprite):
|
||||
def __init__(self, game, x, y):
|
||||
image = pg.image.load("img\\granny.png")
|
||||
self.groups = game.all_sprites
|
||||
pg.sprite.Sprite.__init__(self, self.groups)
|
||||
self.game = game
|
||||
self.image = pg.Surface((TILESIZE, TILESIZE))
|
||||
self.rect = self.image.get_rect()
|
||||
self.image.blit(image, (0, 0))
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.rect.x = x * TILESIZE
|
||||
self.rect.y = y * TILESIZE
|
||||
|
||||
|
||||
class Sh(pg.sprite.Sprite):
|
||||
def __init__(self, game, x, y):
|
||||
image = pg.image.load("img\\g.png")
|
||||
self.groups = game.all_sprites
|
||||
pg.sprite.Sprite.__init__(self, self.groups)
|
||||
self.game = game
|
||||
self.image = pg.Surface((TILESIZE, TILESIZE))
|
||||
self.rect = self.image.get_rect()
|
||||
self.image.blit(image, (0, 0))
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.rect.x = x * TILESIZE
|
||||
self.rect.y = y * TILESIZE
|
Loading…
Reference in New Issue
Block a user