Alot of the tutorials on the web instruct me on how to create a randomly generated map with varying sized rooms etc. I dont want this, I want a Binding of Isaac style map where each room is the same size and is the only thing on the screen.
Therefore, Im trying to find a way to generate a map where a group of say 8-10 randomly selected rooms out of the room pool are picked and grouped together to create a map.
Ive tried doing this but havent managed to get very far. This is the code that I used to try and make things random
def main():
rooms = []
room = Room1()
rooms.append(room)
room = Room2()
rooms.append(room)
room = Room3()
rooms.append(room)
room = Room4()
rooms.append(room)
current_room_no = random.randint(0, 2)
current_room = rooms[current_room_no]
# Game Logic
player.move(current_room.wall_list)
if player.rect.x < -15:
if current_room_no == 0:
current_room_no = random.randint(0, 3)
current_room = rooms[current_room_no]
player.rect.x = 790
elif current_room_no == 3:
current_room_no = random.randint(0, 3)
current_room = rooms[current_room_no]
player.rect.x = 790
elif current_room_no == 2:
current_room_no = random.randint(0, 3)
current_room = rooms[current_room_no]
player.rect.x = 790
else:
current_room_no = 0
current_room = rooms[current_room_no]
player.rect.x = 790
if player.rect.x > 801:
if current_room_no == 0:
current_room_no = random.randint(0, 3)
current_room = rooms[current_room_no]
player.rect.x = 0
elif current_room_no == 1:
current_room_no = random.randint(0, 3)
current_room = rooms[current_room_no]
player.rect.x = 0
elif current_room_no == 2:
current_room_no = random.randint(0, 3)
current_room = rooms[current_room_no]
player.rect.x = 0
else:
current_room_no = 0
current_room = rooms[current_room_no]
player.rect.x = 0
Let me know if any more code is needed!
Aucun commentaire:
Enregistrer un commentaire