Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2013
    Location
    Your face.
    Posts
    94
    Rep Power
    0

    Default 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);
    		}
    And yes, I realize it says "Chaning". It's an inside joke ^^

    Any ideas? There's no other threads that even use these values so.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default 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.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    Apr 2013
    Location
    Your face.
    Posts
    94
    Rep Power
    0

    Default Re: Value resetting every "tick"

    Quote Originally Posted by DarrylBurke View Post
    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.

    db
    I wrote this up in like five minuets, just to see if it'd work. Apparently it's not, but I'd like to keep going with it.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Value resetting every "tick"

    Quote Originally Posted by RiokuTheSlayer View Post
    I wrote this up in like five minuets, just to see if it'd work. Apparently it's not, but I'd like to keep going with it.
    So you expect help with code that is fundamentally flawed?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  2. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  3. Replies: 1
    Last Post: 02-01-2012, 08:37 PM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •