COMP4300 - Game Programming - Lecture 18 - Advanced Game Main Loop

preview_player
Показать описание
Memorial University - Computer Science 4300 - Fall 2022
Intro to Game Programming

This is a course for students interested in learning the fundamentals of game programming and game engine architecture. Topics include an introduction to: vector math for games, rendering, animation, and artificial intelligence, collision detection, game physics, and user-interfaces. Students will be writing fully functional games using an ECS (Entities, Components, Systems) architecture, using the C++ programming language and the SFML graphics library.

Course Assignments / Files will not be released publicly
Рекомендации по теме
Комментарии
Автор

This is probably one of the best lessons i have seen on the Game loop...

bjbegui
Автор

Hey Dave,

Is it possible for variable time step approach to completely skip collisions? For example I am thinking about a particularly slow system where the elapsed time may be about 20 ms, and my character's position is updated by a proportional amount and skips an object with a thin collision box and appears at the wrong end? Is this possible?

On the other hand, the "catch-up and then render" method seems like it may cause input lag while keeping the in-game world consistent.

Again, thank you so much for these public courses.

berkeozgurarslan
Автор

Back a couple of years ago, when I was trying to write something simple in OpenGL I have been drawing just a couple of triangles on the screen to test things, and obv it resulted in several thousands of fps. My first idea was to implement exactly what Dave told in the middle of the video, with calculating how long did it take to make a frame and sleep for the rest of the time, but for some reason i didn't really worked. The video was supper jittering and laggy. When I googled the problem it turned out that sleep of the Windows is not that precise, and it could take a couple of ms more or less time, which in this case caused this jittering effect. I ended up using an OpenGL implementation of frame locking, but maybe someone knows how I should have solved this problem?

upd. I remember that my next idea was to make a second while loop (inside the main game loop) that runs and basically checks is the elapsed time >= 16 ms, and if yes, just brake and proceed again with the main game loop, and it worked really good, but there was one problem though, that CPU usage on this core was 100% since the thread was spinning almost all the time in this silly elapsed time checking while loop.

TopConductor
Автор

The lessons is very useful, I appreciate it a lot. But I wonder where can I get the lecture pdf, can you help me?

PeterWebster-dc