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 / Pissed Off Penguins Help

Author
Message
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 21st May 2011 07:50
I'm just starting a remake of the popular mobile game Angry Birds. I hit a small syntax snag when im trying to calculate power of a shot downwards (my game is going to use buoyancy of a penguin rather than gravity).

Somewhere in the either the prototype for the Dist function, the function declaration itself, or in the Refresh_Screen() function is a syntax error preventing the code from running right. it wont build right and if i put in breakpoints they say "this breakpoint won't be hit because the source code is different than the original...."

HELP!

main.cpp:


Globals.h:



JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 21st May 2011 08:06
Try changing this:


to this:


You were using the angle-brackets instead of the parenthesis...

Hope this helps,

JTK
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 21st May 2011 13:42
Note that the standard trig functions such as cos() and sin() use radians, not degrees like the DB variants do.



Support a charitable indie game project!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 21st May 2011 14:51 Edited at: 21st May 2011 14:58
Quote: "Somewhere in the either the prototype for the Dist function, the function declaration itself, or in the Refresh_Screen() function is a syntax error..."


I suppose you don't know that Visual Studio tells you exactly where the syntax error is, you don't need to look through or post the whole code.

1. In the error message there is the line number where in the program the error is. At the bottom of the editor window you see the line number where the cursor is, and you can also use Ctrl G to jump to a line number.

2. Even easier: If you double-click the error message, it takes your cursor to the line where the error happened.

P.S. Breakpoints are for discovering errors when the program is already running. Of course they can't be used if it doesn't even compile. Use the two methods above to find syntax errors. (There are certain errors which the compiler may indicate after the line where the actual problem is, if it doesn't cause an immediate syntax error, but most of the time you can find the problematic line immediately.)
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 21st May 2011 20:47 Edited at: 21st May 2011 20:47
thats the thing, i dont get an error. the program SEEMS to run fine but it runs the last successful build rather than the current one....like it cant build the code or something. but if i comment out everything to do with the Dist() function then it builds properly.

and no getting rid of the angle brackets didnt help


Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 21st May 2011 22:47 Edited at: 21st May 2011 22:52
Here is the solution to both problems.

Build problem: Open Tools, Options, Projects and Solutions, Build and Run. Here there is a drop-down list which lets you choose what to do when a build error happens: launch old version (probably you have that selected), do not launch or prompt to launch. Set it to either "do not launch" or "prompt to launch". Then you will see the errors without running the last successful build.

And the problem with the program: In the Dist function you use the chevron ^ operator as if it means the square or "power of X" of a number. It's not. (Maybe in Basic yes but not here.) It means "bitwise XOR (exclusive or)". The syntax error you get is this:

Dsq^(.5)
illegal, right operand has type "double"
Since bitwise operations are not possible on floating point numbers. It's actually good that it does not compile because it wouldn't do what you want anyway. You should rewrite these lines:



like this:



(Dsq can be an int but for square rooting, it must be converted to double, so it doesn't hurt to define it right away as double.)
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 21st May 2011 23:47
oh okay thanks a ton!


Login to post a reply

Server time is: 2024-10-02 17:31:24
Your offset time is: 2024-10-02 17:31:24