Main Menu

Game Loop

Started by Mihai_Ionut_Floares, December 06, 2020, 21:38:57

Previous topic - Next topic

Mihai_Ionut_Floares

I finally completed this http://www.opengl-tutorial.org/beginners-tutorials/
But everything in my code is very very messy. The game loop is this while loop: while(!glfwWindowShouldClose(window))
The most game engines allow you to create small scripts with only 1 certain thing to do, where you have some methods like Update in unity which is executed every frame. I tried to create a separate java file to move a cube from outside the main class, calling the GameLoop() method, each frame, but it wasn't working. How to handle the gameloop from outside?

Source_of_Truth

I fear you need to re-evaluate you approach a bit. Unity is an engine, that basically means that you are just injecting some code of yours into existing structures. This is why concepts like the Update()-Method exist.

LWJGL on the other hand is simply a java-binding for the raw OpenGL-API, the "graphic card's language" so to speak. LWJGL is a library only, that means you basically have to write everything you know from Unity yourself, from asset handling to game logic.
A game loop is just one concept of how to build a game, albeit a broadly used one  :o.

In short, LWJGL is NOT an engine. If you want to focus more on scripting and less on technical tasks that make a game tick, I would recomment you take a look at this instead, which is much more engine and less library. Internally, it uses LWJGL.