how do you make doors?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
how do you make doors?
I'm still new to this and I wanna make this horror game with rooms that you can enter, I was wondering how I could make a functional door, can anyone please teach me how to do it
Re: how do you make doors?
Something like:
Code: Select all
function ifDoorCollision (door, player)
if door.open then
-- don't check the door
return false
else
-- returns true on collision between door and player
return ifCollision (door, player)
end
end
-
- Party member
- Posts: 548
- Joined: Wed Oct 05, 2016 11:53 am
Re: how do you make doors?
You'll have to be a bit more specific by what you mean by doors. Do you mean doors that you can open/close, like what darkfrei's code suggests, or do you mean more like area transitions?
Re: how do you make doors?
if the game is tile-based like Pacman or Sokoban ( https://simplegametutorials.github.io/love/sokoban/ ) and you already have collisions working then could just edit your level-table.
like:
That is just to explain the principle, of course instead of hardcoded numbers you eventually might want something to keep track of doors and triggers that open/close them.
like:
Code: Select all
level[6][7] = empty --open the door
level[6][7] = wall --close the door
Re: how do you make doors?
Show us what you have so far. It's unlikely anyone will create a whole (mini) game for you just to demonstrate this.
If you don't have anything yet, these are some of the things you'll want to consider:
- is the game tile-based? Or are you using pre-rendered image maps?
- is the player confined to 1 tile at a time?
- you'll want some tables to store maps & their objects (doors, windows, potted plants, monsters, etc)
- you'll need some way to draw these things to the screen
Try to get something that runs, then ask for help improving it.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Re: how do you make doors?
I agree with milon on this one. Please decide what game you want at all, decide what it looks like, how the player moves, etc.. And only then add in the doors.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest