Wersja z problemem generowania prostokatnych map
This commit is contained in:
parent
e7bede9f5f
commit
7cf49721a5
@ -3,4 +3,3 @@ from DataModels.Cell import Cell
|
|||||||
class GC( Cell ):
|
class GC( Cell ):
|
||||||
def __init__( self, x, y, max_rubbish, yellow = 0, green = 0, blue = 0):
|
def __init__( self, x, y, max_rubbish, yellow = 0, green = 0, blue = 0):
|
||||||
Cell.__init__(self, x, y, max_rubbish, yellow, green, blue )
|
Cell.__init__(self, x, y, max_rubbish, yellow, green, blue )
|
||||||
|
|
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
6 5
|
6 5
|
||||||
|
1 0
|
||||||
Y R R R E H
|
Y R R R E H
|
||||||
E R E R R R
|
E R E R R R
|
||||||
H R B R H R
|
H R B R H R
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
13 4
|
13 4
|
||||||
|
3 0
|
||||||
E Y R R R H H R R R E E E
|
E Y R R R H H R R R E E E
|
||||||
H R R H R R R R H R R H E
|
H R R H R R R R H R R H E
|
||||||
E E R E H E R H R E R R G
|
E E R E H E R H R E R R G
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
12 10
|
12 10
|
||||||
|
1 0
|
||||||
Y R R R E H R R R R R E
|
Y R R R E H R R R R R E
|
||||||
E R E R R E R E H E R H
|
E R E R R E R E H E R H
|
||||||
H R R H R R R R R R R E
|
H R R H R R R R R R R E
|
||||||
|
Binary file not shown.
@ -4,7 +4,9 @@ CELL_SIZE = 64
|
|||||||
FPS = 60
|
FPS = 60
|
||||||
|
|
||||||
map = open( sys.argv[1], 'r' )
|
map = open( sys.argv[1], 'r' )
|
||||||
GRID_WIDTH, GRID_HEIGHT, GC_X, GC_Y = [int(x) for x in map.readline(2).split()]
|
|
||||||
|
GRID_WIDTH, GRID_HEIGHT = [int(x) for x in map.readline().split()]
|
||||||
|
GC_X, GC_Y = [int(x) for x in map.readline().split()]
|
||||||
|
|
||||||
WINDOW_HEIGHT = GRID_HEIGHT * CELL_SIZE
|
WINDOW_HEIGHT = GRID_HEIGHT * CELL_SIZE
|
||||||
WINDOW_WIDTH = GRID_WIDTH * CELL_SIZE
|
WINDOW_WIDTH = GRID_WIDTH * CELL_SIZE
|
||||||
|
17
main.py
17
main.py
@ -1,7 +1,7 @@
|
|||||||
import pygame, sys
|
import pygame, sys
|
||||||
|
|
||||||
from random import randint
|
from random import randint
|
||||||
from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_CAPACITY, FPS
|
from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_CAPACITY, FPS, GC_X, GC_Y
|
||||||
|
|
||||||
from DataModels.Grass import Grass
|
from DataModels.Grass import Grass
|
||||||
from DataModels.House import House
|
from DataModels.House import House
|
||||||
@ -12,10 +12,11 @@ from DataModels.GC import GC
|
|||||||
pygame_sprites = pygame.sprite.Group()
|
pygame_sprites = pygame.sprite.Group()
|
||||||
|
|
||||||
FPS_CLOCK = pygame.time.Clock()
|
FPS_CLOCK = pygame.time.Clock()
|
||||||
GAME_WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32)
|
GAME_WINDOW = pygame.display.set_mode( (WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32)
|
||||||
|
|
||||||
map = open(sys.argv[1], 'r')
|
map = open(sys.argv[1], 'r')
|
||||||
map.readline()
|
map.readline()
|
||||||
|
map.readline()
|
||||||
|
|
||||||
map_objects = [ [ None for y in range(0,GRID_WIDTH)] for x in range(0, GRID_HEIGHT)]
|
map_objects = [ [ None for y in range(0,GRID_WIDTH)] for x in range(0, GRID_HEIGHT)]
|
||||||
|
|
||||||
@ -33,8 +34,9 @@ def generate( letter ):
|
|||||||
i = 0
|
i = 0
|
||||||
for y in map.readlines():
|
for y in map.readlines():
|
||||||
for x in y.split():
|
for x in y.split():
|
||||||
x_coord = i % GRID_WIDTH
|
|
||||||
y_coord = i // GRID_WIDTH
|
y_coord = i % GRID_WIDTH
|
||||||
|
x_coord = (i - y_coord)//GRID_WIDTH
|
||||||
|
|
||||||
yellow, green, blue = [randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2)]
|
yellow, green, blue = [randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2)]
|
||||||
if x is 'E':
|
if x is 'E':
|
||||||
@ -51,16 +53,11 @@ for y in map.readlines():
|
|||||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord)
|
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
print( GRID_WIDTH, GRID_HEIGHT )
|
|
||||||
print( map_objects )
|
|
||||||
|
|
||||||
|
|
||||||
for line in map_objects:
|
for line in map_objects:
|
||||||
for item in line:
|
for item in line:
|
||||||
pygame_sprites.add(item)
|
pygame_sprites.add(item)
|
||||||
|
|
||||||
pygame_sprites.add( GC(0,0,2) )
|
pygame_sprites.add( GC(GC_X, GC_Y, 2) )
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user