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 / for loop not working

Author
Message
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 18th Oct 2009 21:25
I'm trying to use a for loop to create multiple objects..this should be simple but for some reason whenever I run it the camera angles freak out and the level (model) blinks and flash's and it basically just doesn't work. I put this loop into the main darkGDK loop

here is the code for it -



thanks for any help
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 18th Oct 2009 21:41
if this is in while loop, what you are basically doing is recreating 20 cubes and randomly positioning them. the camera isnt doing anything, actually. the objects are just constantly moving to a random position.

if you want to just make the objects and position them once, then just move the whole for loop above the while loop.

If I sound like I know what I am talking about, then I most likely have no idea what I am saying.

If I sound like i have no idea what I am saying, then I most likely know what I am talking about.
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 18th Oct 2009 22:07
thanks for the reply. Without the for loop in the program at all this is what it looks like

http://img9.imageshack.us/i/rightyw.jpg/

but when I put the for loop outside the main loop like you said the camera changes angle like this

http://img9.imageshack.us/i/wrongyp.png/

meaning I can't see the player or if the cubes have been created or not. Any idea why this is happening?
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 18th Oct 2009 22:11
could we see your code? cause it would be easier to tell what's happening. and easier to help you fix it.

If I sound like I know what I am talking about, then I most likely have no idea what I am saying.

If I sound like i have no idea what I am saying, then I most likely know what I am talking about.
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 18th Oct 2009 22:14
do you have autocam off? that would make the camera move "randomly"


Your signature has been erased by a mod
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 18th Oct 2009 22:19
main.cpp


setup.h


canera.h


player.h


collision.h



I know it's a bit messy just now..
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 18th Oct 2009 22:32
ok, i think i know what you are doing. in set up, you load two objects and give them identities 1 and 2. when you make your cubes, you give them identities 0-19, meaning that you are overwriting 1 and 2. the reason the camera goes funky is that it no longer points at the character object, but rather at the cube with identity 2, that's why the angle goes funky. all you really need to do is step up the start on the for loop to start at 3 instead. that should fix your camera angle problem

If I sound like I know what I am talking about, then I most likely have no idea what I am saying.

If I sound like i have no idea what I am saying, then I most likely know what I am talking about.
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 18th Oct 2009 23:59
I did this and it still didn't work...but I managed to fix it by doing that plus changing the call of the loop earlier in the program (just after initial). Thanks for your help

Login to post a reply

Server time is: 2024-10-01 14:33:20
Your offset time is: 2024-10-01 14:33:20