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 not moving properly

Author
Message
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 9th May 2008 08:22 Edited at: 9th May 2008 08:29
OK... I just started making a little game where you are a camera who can shoot instanced 3d spheres at untextured boxes which flying towards you at high velocity (1) to stop them from killing you...

I'm getting a really strange problem which I have no clue why is happening... When a sphere you can shoot does not exist the camera does not roll on its X-axis but when the sphere does exist it can... Really strange and I have racked my brain to try to come up for a solution but couldn't find one...

Here's the source code::


Any suggestions?

~~It's not who you are underneath, but what you do that defines you.~~
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 9th May 2008 08:30 Edited at: 9th May 2008 08:31
Um... the previous snippet had a whole bunch of commented out code and junk in it... Here's the new snippet with the junk removed...



~~It's not who you are underneath, but what you do that defines you.~~
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 08:46
You have a lot of unnecessary blocks in there, and your system of code indenting and formatting is not particularly consistent. I don't want to seem like I'm dissing your skillz. I am rather saying that I can't follow it well in that form.

VS has a feature called AutoIndent, which can be programmed to indent using standard C formatting, and other options. Or, it can be turned off entirely. Are you using AutoIndent?

I indent and make code blocks a little differently than standard C, too. You do not need to use code blocks until you make something like a multiple line if statment, or a control loop, or a function, or otherwise define something.

This for example, is unnecesary:



You don't need to make that a code block. It should not cause a control error by itself, but it is unnecessary nesting, and its behavior is probably not defined in the compiler, so...it might just be confusing the C++ compiler about your intent.

I have not looked at the code too much, but I think the code would be easier to debug if you reformatted it remove the extra nesting, and moved the locals to the top of the function they are defined/used in.

I will see if I can show you what I mean. It is so much easier to examine code that is laid out logically. I will repost the modified source. Hopefully, something will jump out while I'm editing it. (Hint - that's where you will find alot of bugs, btw.)
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 9th May 2008 08:53 Edited at: 9th May 2008 08:59
So you are saying that I should remove all unnecessary curlies? I can do that... But I want to take a look at your modified source first...

BTW I had no clue AutoIndent existed... I'll look into it... My coding isn't very clean... I just started experimenting with this today so it's even messier than usual... I the future i'll try to keep it clean...

EDIT: Is this sort of better?


~~It's not who you are underneath, but what you do that defines you.~~
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 08:59 Edited at: 9th May 2008 09:00
No, that looks about like the usual level of messiness for the sort of noodling around you are doing.

Here is a quickly edited version, just moving the variables to the top (Because I like to know what's on the stack, and how much of it I am using in a function.), and removing the unnecessary curlies...and using my most stringent formatting. (Except one place where I don't use a code block on an if statement with a single line inside. Its the last one, in fact.)

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 9th May 2008 09:03
Kewl... Except... The problem still remains... I've coded using strange blocks in strange places since I started C++ (two - three months ago)... It's never cuased TOO big of a problem... It wasn't doing anything TOO bad here either...

Do you have any suggestions about the problem...

~~It's not who you are underneath, but what you do that defines you.~~
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 10:13
I lost my connection there for a while. I am installing GDK and setting up VS2003 to use it. Then, I am going to get some procedures for debugging set up, and I will post those results whan I am done.
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 9th May 2008 16:30
Thanks Jinzai... I attached source files if you need them...

~~It's not who you are underneath, but what you do that defines you.~~

Attachments

Login to view attachments
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 16:55 Edited at: 9th May 2008 16:56
Well, I spoke too soon. I am not able to use GDK with VS2003...I'm missing at least one library. (Actually, I think its simply that I have the wrong libcmt.lib, but...it doesn't matter, anyway.) Maybe, I'll look into installing VS2008. I have GDK on my roommates extra machine, but...she fried that one, and I haven't gotten round to seeing what's up with it yet.

Black, huh? Pretty bold name; that happens to be my favorite FPS of all time. I think they got it all right, except that there is no multiplayer or coop modes. (I see why, however.)

btw, I just saw the edit above....very clean!

Later, I'll look into this.
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 00:59
Quote: "Maybe, I'll look into installing VS2008."

Just a question, but what are the reasons for which you prefer VS2003 over VS2008?

Quote: "Black, huh? Pretty bold name; that happens to be my favorite FPS of all time."


That's not the name of my game, it has no name yet... The zip was just automatically named black though because black.png was the first file I added to the archive...

Quote: "btw, I just saw the edit above....very clean!"

Thanks...

~~It's not who you are underneath, but what you do that defines you.~~
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 02:41
To Jason: Hey Jason if you are out there I am wondering if you could take a look at my code to spot a problem...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 02:49 Edited at: 10th May 2008 03:14
looking...

[edit]
So far, I've tidy'd up your code just a smidge... (so I could make sense of all the hardcoded numbers)....

You're doing some things a veteran might not do.. but that "sphere exists" cam acts one way and "sphere not exist" makes camera act another.. is puzzling me also.

I checked (reason I changed the hardcoded numeric values to variables names... like BlackImgID, SphereObjID etc.)

And you aren't (at least I haven't seen it yet) getting a variable hosed or using the wrong one with the camera.

I think I'm going to rearrange your camera code a bit... not because I see anything major wrong... but I'm going to try to get rid of the issue rather than figure out what's causing it ... LOL ... Give me a few....

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 02:50
Thanks man... I really appreciate it...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 03:41


Your Camera Move Mouse Stuff was messed.... in that it must of been because I fixed that and it works now... but I'm not sure why it was working two different ways... depending on sphere bullet existing or not...

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 04:40
Quote: "fCameraAngleX = dbCameraAngleX();
fCameraAngleY = dbCameraAngleY();"


You could have just told me that I was missing that, instead of rewriting the whole thing... You are probably a busy man and I don't want to you to have to sort out noobs' petty problems all day... But nonetheless, THANK YOU VERY MUCH... It now works and is awesome...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 05:01
Quote: "You could have just told me that I was missing that"
LOL.. You're Welcome... I needed to make it more readable for myself first LOL... Once I turned those numbers that meant something to you, to something I could relate to.. then the code read more sensibly to me in that I could follow it faster and understand what you were doing...

As a general rule, I try to snag the camera xyz and camera angles xyz at the top of my loop and store them in variables. Then I let stuff react to those "snapshot'd" variables, then I change camera position last, and then set it, ready for next go round.

But the key is I ask the camera where its at, make whatever decisions from that, then I tell it where to be next. Your code was dicating without regards for the camera's actual position. I mean that when you stuff a number in the cam, its not always the SAMe EXACT value when you read it back due to float rounding etc.. I think this caused your anomally.

As for spending time with a noob... sometimes I can, sometimes I can't... and frankly... if I get a smart guy like you going, then yuo can help others... pay it forward and such

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 05:35
Quote: "if I get a smart guy like you going, then yuo can help others... pay it forward and such "


I guess so... Thanks again for the help...

~~It's not who you are underneath, but what you do that defines you.~~
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 05:48
One more thing... About shooting... Currently how it works is if one sphere exists you can't shoot another... That is sort of unfair and stupid... What would be the best way of timing it so it could create multiple instances based on time...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 14:05
Next Lesson for you: C++ Arrays.

You can even cheat and use a memblock like an array if you wanted to... though I'd stick with the arrays.

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 23:28
I thought of using arrays but took the lazy, long and familiar way instead before I read your post... I'm gonna try arrays for my next minigame...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th May 2008 04:51
Start with Fixed Arrays.. Just to whet your appetite for fancier dynamic stuff later. You'll get familiar with them easier.. At least that's what I did when getting acclimated to C++ a bit... still am getting acclimated LOL... But.. I like them.. that's for sure.

Login to post a reply

Server time is: 2024-09-29 19:23:44
Your offset time is: 2024-09-29 19:23:44