Understanding the language, error messages, etc.
by ajsb113 » Thu Oct 23, 2014 2:27 pm
Here's my code for the game thus far. I'm sorry about how unorganized/messy it is, it's a work in progress. Thanks for taking a look at it!
- Attachments
-
- Maruino.zip
- (2.65 KiB) Downloaded 222 times
-
ajsb113
-
- Posts: 45
- Joined: Tue Jun 24, 2014 4:47 am
- Location: Illinois, United States
by Zoglu » Thu Oct 23, 2014 4:18 pm
I got your timer to work by commenting out your updatePlayer call (file "Maruino", line 44). The problem might come from this !
EDIT : here is what you have at the beginning of your updatePlayer function :
- Code: Select all
if(time = 0){
startGame();
}
If I remember correctly,
if(time = 0) doesn't check if time equals to 0, but instead changes time to 0 and returns true. You should try to change it to
if(time == 0).
-
Zoglu
-
- Posts: 26
- Joined: Thu Oct 09, 2014 5:13 pm
by ajsb113 » Fri Oct 24, 2014 1:55 pm
Thank you! I knew it was going to be something as stupid as a missing = sign
. Thanks for checking it out!
-
ajsb113
-
- Posts: 45
- Joined: Tue Jun 24, 2014 4:47 am
- Location: Illinois, United States
by Myndale » Fri Oct 24, 2014 10:07 pm
There's an interesting trick in the book
Writing Secure Code (I think) in which you write these types of statements with the constant on the left hand side of the equation i.e. "if (0==time) ....". Reason being that constants cannot be assigned to, so if you do accidentally forget an equal sign the compiler will throw up an error.
-
Myndale
-
- Posts: 507
- Joined: Sat Mar 01, 2014 1:25 am
by rodot » Sat Oct 25, 2014 7:33 am
Myndale wrote:There's an interesting trick in the book
Writing Secure Code (I think) in which you write these types of statements with the constant on the left hand side of the equation i.e. "if (0==time) ....". Reason being that constants cannot be assigned to, so if you do accidentally forget an equal sign the compiler will throw up an error.
Nice tip, thanks!
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 4 guests