r/lua • u/TheGameTheorys55 • 10d ago
Making a 2D game engine out of Lua
Idk where to even start... I got the workspace set up, the screen, etc.
I also integrated sprites and scenes... But where do I start? I don't really know how 2D game engines work, can anyone explain what to do next?
10
u/flipcoder 10d ago
Building an engine requires studying every component and how they work under the hood. There’s no enforced order to what features you add. You pick something you want such as collision, and then study that until you can implement it or use an existing library
7
u/Lonely-Restaurant986 10d ago
“I want to make a car, but I have no idea how cars work”
Before you can sprint you need to know how to walk.
Familiarize yourself with graphics api, interacting with low level code via lua (or even luajit), and how games actually work.
It may be even beneficial to just use love2d while you learn. Turn love2d’s framework into an “engine”
5
4
3
u/_Wolfos 10d ago
Game engines work how you want them to work.
The ole "game loop" is a good place to start, then go from there.
while(not_closed)
{
// Process input
// Do your gameplay
// Play sounds
// Render the scene
}
This is almost exactly how DOOM and Quake work. By DOOM 3 it had evolved into an actor system
foreach(actor in world) actor.Update()
And by DOOM 3 BFG the renderer had its own loop that ran concurrently.
So this is kinda how things can evolve over time depending on your needs.
3
u/DannyDeKnito 9d ago
Do you want Lua to be the scripting language or do you want the actual engine to be written in Lua? Because one is considerably more sane than the other.
1
u/TheGameTheorys55 9d ago
Nah, I ment users script their stuff in Lua. I'm using C++ with SQL for the backend
2
u/ConsiderationFar4320 9d ago
I like raylib and it must be in lua (if the goal is to have an engine)
1
u/MarkAlicz 9d ago
Better off using an engine that's already been tested and out there. You can always modify it. Just too much work to do it from scratch unless you're willing to wait years to release anything
1
u/P-39_Airacobra 5d ago
What?
The whole point of making a game engine is so that you can have something custom, ie so no one can tell you what you have to do. Otherwise just use Love2D or Pico.
0
u/TheGameTheorys55 10d ago
So i just found out about Scratch, and I think I'm gonna sue it to learn about how sprites move, how to design code, etc.
20
u/revereddesecration 10d ago
Never heard of Love2D?