Male_zoo_Projekt_SI/terrain_obstacle.py

37 lines
1.5 KiB
Python

import pygame
class Terrain_Obstacle:
def __init__(self, x, y, type , image):
self.x = x - 1
self.y = y - 1
self.type = type
self.image = image
def draw(self, screen, grid_size):
scaled_image = pygame.transform.scale(self.image, (grid_size, grid_size))
screen.blit(scaled_image, (self.x * grid_size, self.y * grid_size))
def create_obstacles():
puddle_image = pygame.image.load('images/puddle.png')
bush_image = pygame.image.load('images/bush.png')
puddle1 = Terrain_Obstacle(0,0,'puddle', puddle_image)
puddle2 = Terrain_Obstacle(0,0,'puddle', puddle_image)
puddle3 = Terrain_Obstacle(0,0,'puddle', puddle_image)
puddle4 = Terrain_Obstacle(0,0,'puddle', puddle_image)
puddle5 = Terrain_Obstacle(0,0,'puddle', puddle_image)
puddle6 = Terrain_Obstacle(0,0,'puddle', puddle_image)
puddle7 = Terrain_Obstacle(0,0,'puddle', puddle_image)
bush1 = Terrain_Obstacle(0,0,'bush', bush_image)
bush2 = Terrain_Obstacle(0,0,'bush', bush_image)
bush3 = Terrain_Obstacle(0,0,'bush', bush_image)
bush4 = Terrain_Obstacle(0,0,'bush', bush_image)
bush5 = Terrain_Obstacle(0,0,'bush', bush_image)
Terrain_Obstacles = [puddle1, puddle2, puddle3, puddle4, puddle5, puddle6, puddle7, bush1, bush2, bush3, bush4, bush5]
return Terrain_Obstacles
def draw_Terrain_Obstacles(Terrain_Obstacles, const):
for terrain_obstacle in Terrain_Obstacles:
terrain_obstacle.draw(const.screen, const.GRID_SIZE)