Results 1 to 4 of 4
Thread: Value resetting every "tick"
- 10-04-2014, 01:14 AM #1
Member
- Join Date
- Apr 2013
- Location
- Your face.
- Posts
- 94
- Rep Power
- 0
Value resetting every "tick"
Simple as the title says, I'm just making a little "emotion" emulator thing. No matter what I do, the values get reset every frame
Java Code:double happy, curious, angry, sad; public void changeEmotion(double Amount, String Emotion) { System.out.println("Chaning Emotion!"); if (Emotion == "Sadness" && sad >= 100) { return; } else if (Emotion == "Happyness" && happy >= 100) { return; } else if (Emotion == "Angryness" && angry >= 100) { return; } else if (Emotion == "Curiousness" && curious >= 100) { return; } System.out.println("Chaning for real!"); if (Emotion == "Sadness") { sad = sad + Amount; happy = happy - Amount; } else if (Emotion == "Happyness") { happy = happy + Amount; sad = sad - Amount; } else if (Emotion == "Angryness") { angry = angry + Amount; happy = happy - (Amount * 2); } else if (Emotion == "Curiousness") { sad = sad - (Amount / 2); happy = happy + (Amount / 2); angry = angry - Amount; } else { System.out.println("Not a valid emotion, check your code and try again!"); System.exit(WHEN_FOCUSED); }
Any ideas? There's no other threads that even use these values so.
- 10-04-2014, 04:20 AM #2
Re: Value resetting every "tick"
1. Learn to follow Java coding conventions. Variable names start with a lowercase letter. Code Conventions for the Java Programming Language: Contents
2. Never use == to compare Strings or other Objects (unless you really are checking for value identity). Use the /equals(..) method instead.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 10-04-2014, 06:32 AM #3
Member
- Join Date
- Apr 2013
- Location
- Your face.
- Posts
- 94
- Rep Power
- 0
- 10-04-2014, 08:21 AM #4
Similar Threads
-
access denied("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
By klspepper in forum New To JavaReplies: 0Last Post: 12-07-2012, 09:29 AM -
Convert string operation symbols "+", "-", "/", "*" etc.
By Googol in forum New To JavaReplies: 3Last Post: 10-30-2012, 04:06 PM -
loop "play again" in an 8 ball game , loops but wont let me answer my "out.print"
By IareSmart in forum New To JavaReplies: 1Last Post: 02-01-2012, 09:37 PM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 07:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 08:35 AM
Bookmarks