Lazy Foo's Tutorial 17 (Collision Detection)

Started by
1 comment, last by Motoky 10 years, 11 months ago

Hey, I am currently working through Lazy Foo's tutorials. I have been doing pretty well with the previous tutorials. Obviously running into walls, but managed to get passed them due to silly little errors or mistakes I couldn't see which were to blatant when I finally did find the problem...

Anyway, the problem I am having is with the Timer class. I've got it working in previous projects, but it's just cooperating in this one project.

The function I am talking about is it returns the time in milliseconds, but it is all based on whether the timer is running and if it's paused or not.

I have uploaded my project. It's probably not perfect, but I am just trying to get it up and running before I make modifications, add more comments and such. I can't seem to copy and paste code properly, it just comes out as a jumbled mess with huge gaps between nearly every word and it would take me ages to sort it out, so it just quicker to upload my project and you can have a look through it all.

Like I said, it's just the Timer class giving me trouble. It just stops at the getTicks() function when I debug. It stops at the first line in that function which is:

if(started == true)

Now this exact class works in other projects.

Advertisement
You have not initialized the fps pointer in SDLManager. I don't really see the why fps should be a pointer in the first place.

I had a look through my code before looking at your reply and I noticed I hadn't even started the timer. I also initialized a Timer object in my Main source file along with the SDLManager header file. I was trying to start the timer with a different Timer object, but retrieve the FPS on another Timer object...

I decided to initialize my timer in my Main source file, get rid of it in the SDLManager. The program is up and running now, but still having a little trouble with the movement of the square, but I will sort that out myself. I've had this problem before and I managed to get it fixed before.

Thanks a lot though.

This topic is closed to new replies.

Advertisement