Page 1 of 1

how do you make doors?

Posted: Tue Jun 21, 2022 5:09 am
by Kiro
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?

Posted: Tue Jun 21, 2022 12:14 pm
by darkfrei
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

Re: how do you make doors?

Posted: Tue Jun 21, 2022 2:11 pm
by MrFariator
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?

Posted: Tue Jun 21, 2022 4:12 pm
by knorke
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:

Code: Select all

level[6][7] = empty --open the door
level[6][7] = wall --close the door
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.

Re: how do you make doors?

Posted: Wed Jun 22, 2022 4:41 pm
by milon
Kiro wrote: Tue Jun 21, 2022 5:09 am 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
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.

Re: how do you make doors?

Posted: Thu Jun 23, 2022 12:31 am
by steVeRoll
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.