import libtcodpy as libtcod import random #actual size of the window SCREEN_WIDTH = 160 SCREEN_HEIGHT = 80 #fake map for now currentMap = [] #booleans gameExit = False #some variables WORLD_WIDTH = 80 WORLD_HEIGHT = 40 ROOM_WIDTHMIN = 1 ROOM_HEIGHTMIN = 1 ROOM_WIDTH = 15 ROOM_HEIGHT = 5 LIMIT_FPS = 20 #20 frames-per-second maximum ########################### # CLASSES ####################### class Object: #this is a generic object: the player, a monster, an item, the stairs... #it's always represented by a character on screen. def __init__(self, x, y, char, color): self.x = x self.y = y self.char = char self.color = color def move(self, dx, dy): self.x += dx self.y += dy def draw(self): #set the color and then draw the character that represents this object at its position libtcod.console_set_default_foreground(con, self.color) libtcod.console_put_char(con, self.x, self.y, self.char, libtcod.BKGND_NONE) def clear(self): #erase the character that represents this object libtcod.console_put_char(con, self.x, self.y, ' ', libtcod.BKGND_NONE) ######################## # FUNCTIONS ######################### def createWorld(): theTempNum = 0 for i in range(WORLD_WIDTH): tempList = [] for r in range(WORLD_HEIGHT): tempVal = 0 #lets pad so the rooms aren't on the edge if(r>ROOM_WIDTH and r<(WORLD_WIDTH-(ROOM_WIDTH+2))and i>ROOM_HEIGHT and i<(WORLD_HEIGHT-(ROOM_HEIGHT+2))): #how likely is it that this tile will be a room if there is no #other room on this row? 90% as of now. if(random.randrange(1,100)>60): #inc counter theTempNum = theTempNum + 1 #this is the room tempVal = theTempNum tempList.append(tempVal) currentMap.append(tempList) text_file = open("world.wld", "w") #now fill out the rooms counter = 0 for i in range(WORLD_WIDTH): for r in range(WORLD_HEIGHT): if currentMap[i][r]>0: if currentMap[i][r]!=counter: counter = currentMap[i][r] #how big will the room be? w_roomRange = random.randrange(ROOM_WIDTHMIN,ROOM_WIDTH) h_roomRange = random.randrange(ROOM_HEIGHTMIN,ROOM_HEIGHT) #modify the map for x in range(-h_roomRange,h_roomRange): for y in range(-w_roomRange,w_roomRange): if(i+x>1 and i+x1 and r+y