sprite movement

Started by
14 comments, last by Rutin 5 years, 9 months ago

I didn't realize you were using GLUT. I really cannot comment on using this for games but GLUT is event driven from what I know which is fine for making simple applications, not games beyond something like chess, or blackjack.

I believe glutTimerFunc() is what is controlling your update rate. So  glutTimerFunc(1000 / FPS(30), Loop, 0) = update every 33.33333 milliseconds.

I wont be able to comment further on GLUT as I don't use it. It's also a depreciated library which really shouldn't be used for 2D game development in this day and age considering libraries like SDL2 and SFML can easily generate window creation for you with greater benefits.

What you should be doing is using something like SDL2 or SFML to generate your window, you'll also benefit from events, keyboard input, mouse input, sprite classes, texture classes, audio, networking, ect... then create a proper time step and game loop from scratch, and use openGL from there without GLUT.

Continuing on this path is just going to be an on going headache as you've stated before you wanted to make a space invader style game.

You can look at these for an example on time steps and a basic game loop:

https://gafferongames.com/post/fix_your_timestep/

http://www.koonsolo.com/news/dewitters-gameloop/

If you still want to keep using GLUT then you'll need to get someone who uses GLUT to help regulate your loop better.

Programmer and 3D Artist

Advertisement

I have also used sdl2 but I don't have any books for it yet.

5 minutes ago, phil67rpg said:

I have also used sdl2 but I don't have any books for it yet.

I would strongly recommend SFML, the tutorials are very easy to follow. :) Your main goal here is to get a window setup quick and easy, while being able to use openGL for your rendering. SFML will help make all your events and input easy to handle. I wouldn't suggest you continue using GLUT if you're serious about progressing in game development considering the amount of time you've already invested.

https://www.sfml-dev.org/

https://www.sfml-dev.org/tutorials/2.5/

 

Programmer and 3D Artist

well I ordered a book on sdl 2

Then work with SDL2. :) It doesn't matter if you use SDL2 or SFML or another good library, but using GLUT is counter-productive considering the other options out there.

Programmer and 3D Artist

This topic is closed to new replies.

Advertisement