how do you make doors?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Kiro
Prole
Posts: 1
Joined: Tue Jun 21, 2022 5:04 am

how do you make doors?

Post 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
User avatar
darkfrei
Party member
Posts: 1197
Joined: Sat Feb 08, 2020 11:09 pm

Re: how do you make doors?

Post 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
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
MrFariator
Party member
Posts: 548
Joined: Wed Oct 05, 2016 11:53 am

Re: how do you make doors?

Post 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?
User avatar
knorke
Party member
Posts: 274
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: how do you make doors?

Post 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.
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: how do you make doors?

Post 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.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
steVeRoll
Party member
Posts: 139
Joined: Sun Feb 14, 2016 1:13 pm

Re: how do you make doors?

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests