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 / Collision error

Author
Message
Diana DiDi
11
Years of Service
User Offline
Joined: 27th Nov 2012
Location:
Posted: 31st Dec 2012 14:20
Hi! I am quite new to C++ and I've been following a series of tutorials on youtube on how to create an fps game. After getting rid of all the errors, when I compile the program it says "Collision Error. Error During Setup: Object(145) Does Not Exist". Now I checked in the "sc" files to see if anything was missing, however everything I needed was there. One thing I have to mention is that I get several warnings and I am not really sure how much of an effect do they have on my problem.

Warning 3 warning C4552: '+' : operator has no effect; expected operator with side-effect c:\documents and settings\administrator\my documents\visual studio 2008\projects\my fps\my fps\main.cpp 891
Warning 4 warning C4700: uninitialized local variable 'collide' used c:\documents and settings\administrator\my documents\visual studio 2008\projects\my fps\my fps\main.cpp 407
Warning 5 warning C4700: uninitialized local variable 'x' used c:\documents and settings\administrator\my documents\visual studio 2008\projects\my fps\my fps\main.cpp 419
Warning 6 warning C4700: uninitialized local variable 'z' used c:\documents and settings\administrator\my documents\visual studio 2008\projects\my fps\my fps\main.cpp 419
Warning 1 warning C4805: '==' : unsafe mix of type 'int' and type 'bool' in operation c:\documents and settings\administrator\my documents\visual studio 2008\projects\my fps\my fps\main.cpp 253
Warning 2 warning C4805: '==' : unsafe mix of type 'int' and type 'bool' in operation c:\documents and settings\administrator\my documents\visual studio 2008\projects\my fps\my fps\main.cpp 266

A helping hand would really be appreciated thank you.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 31st Dec 2012 19:24
The first warning may be nothing significant, but double-click the warning and it will take you to the code in question.

The next 3 warnings could cause you serious problems.

The last 2 are simple fixes: If you mean to compare two dissimilar variables, you should tell the compiler you mean to do so...
Bad practice:

Though functionally the "1" and "true" are the same, the compiler thinks the integer value could be any size number (within int).
Good practice:

This kind of comparison is not normally done, but you *can* do it.


As for the other warnings, show the code associated with them, and we'll try to figure it out.

The fastest code is the code never written.
Diana DiDi
11
Years of Service
User Offline
Joined: 27th Nov 2012
Location:
Posted: 4th Jan 2013 14:00
Thanks for your answer.
I solved the warnings with the local variables. When I tried the one with "==", it gave me errors. Here's the code before editing



and this is after editing



after editing it, I had this errors

Error 1 error C2143: syntax error : missing ',' before '=='
Error 2 error C2143: syntax error : missing ';' before '{'

As I told you before, I solved the local variables warnings, but now when I try to compile the program it still goes "Collision Errorbject (145) does not exist."
So I looked for the collision code and I can't really figure out what is wrong with it



Of course, if I delete this code it goes "Object(144) does not exist and so on.
Qqite
14
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 5th Jan 2013 00:00 Edited at: 5th Jan 2013 00:01
If your checking to see if takingDamage is a number that isn't zero, then a better way might be just to check if takingDamage != 0 or takingDamage > 0

That would get rid of the cast warning, and would make more sense for reading.





Ventures of the worlds around us are limited only by our imagination.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 5th Jan 2013 05:39
Error 1 error C2143: syntax error : missing ',' before '=='
Error 2 error C2143: syntax error : missing ';' before '{'
These are because you are "declaring" a variable inside an if statement... Here is the correct code (if you still want to do it that way):


Qqite's method is better (more correct), but you *can* do it the other way.....

The fastest code is the code never written.
Diana DiDi
11
Years of Service
User Offline
Joined: 27th Nov 2012
Location:
Posted: 5th Jan 2013 14:13
many many many thanks. that worked perfectly well.

Anyways, although I have now 0 errors/0 warnings, the program won't compile because of the collision error mentioned in my previous posts. any solutions for that please? again, many thanks
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 5th Jan 2013 16:44
Can you post all your code? At least post the initialization and main loop sections so we can see how you're calling everything.

The fastest code is the code never written.
Diana DiDi
11
Years of Service
User Offline
Joined: 27th Nov 2012
Location:
Posted: 6th Jan 2013 12:23



this is the code with the issue



and

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 7th Jan 2013 16:52
Try taking out all the SC parts and then putting them back in one at a time. I can't see anything obviously wrong with your code.....

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-03-28 16:48:57
Your offset time is: 2024-03-28 16:48:57