Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Camera logic woes

Author
Message
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 5th Aug 2009 10:28
I can\'t seem to find why my logic isn\'t working, I\'m sure it\'s something really simple that I\'m just overlooking. But I have programmed it so that when the user pressed W, A, S or D, it should move the camera accordingly, but it doesn\'t. Here\'s the relevant code:

Here is where it\'s defined


here is where it\'s called:


Any help would be greatly appreciated

#ifdef __NEWBIE__
MakeAnAwesomeGame(lots of badies, lots of guns, lots of stuff to do, BIG level)
#endif
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 5th Aug 2009 10:45
Have you defined you scancodes somewhere ? Otherwise the indentifier KEY_A will be nothing.

Are you initializing the value px and pz to 0(or whatever they are meant to be) when you instance the class(in its constructor) ?

According to you Update loop, its taking the current value of px and pz and increment/decrementing it, if the value isnt initialized to 0, it will be some random number that coulde be massively out of range...

Also this bit :



looks to me like the assignment of px to oldpx and then the comparison of whether oldpx is inequal to px is in the wrong order. By assigning those values there and checking them on the next line, they will always be the same, so the camera will never think it has moved.... hope that makes sense.. to fix it, I would assign you "oldpx, oldpz" variables at the top of the loop, before you assign new values to the "px, pz" variables.

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 5th Aug 2009 11:30
Ok thanks that fixed it, but my gun won't follow my camera, it's there, just not moving, can you tell me why this is?

#ifdef __NEWBIE__
MakeAnAwesomeGame(lots of badies, lots of guns, lots of stuff to do, BIG level)
#endif
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 5th Aug 2009 12:22
Without seeing the code that is responsible for your gun and its positioning/rendering i cant say im sorry, if you can post more code someone may be able to help

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 5th Aug 2009 12:29
This is all the code regarding the gun



#ifdef __NEWBIE__
MakeAnAwesomeGame(lots of badies, lots of guns, lots of stuff to do, BIG level)
#endif
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 5th Aug 2009 13:00
sorry for the double post
THis is the code now:



#ifdef __NEWBIE__
MakeAnAwesomeGame(lots of badies, lots of guns, lots of stuff to do, BIG level)
#endif

Login to post a reply

Server time is: 2024-10-01 10:39:06
Your offset time is: 2024-10-01 10:39:06