Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (801)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Solved] Weird if Statement/System.out behavior  (Read 1269 times)
0 Members and 1 Guest are viewing this topic.
Offline Dev Crucio

Senior Devvie


Medals: 9
Projects: 1
Exp: 9 years


CaveGear


« Posted 2015-06-12 11:41:40 »

1  
2  
3  
4  
Misc.log("Update");
if (time >= 1000) {
   Misc.log("Time");
}

where Misc has this function:
1  
2  
3  
4  
public static void log(String msg) {
   Date date = new Date();
   System.out.println("[" + new Timestamp(date.getTime()) + "] " + msg);
}


Time is a float that increses with my delta time (which is calculated in millieseconds) so after one second it should pass into the if state as well (it's in my game loop)

I tested it with outputs to see what in my code isn't working.

with both Misc.log(); calls arround the if statement both get called, however if I remove the Misc.log("Update"); it doesn't ever output "Time" in my console, nothing else changed, why is this and how can i fix it? :/
Without both the code inside that if() doesn'T get called either

Twitch - See me developing CaveGear Smiley
Offline Opiop
« Reply #1 - Posted 2015-06-12 12:04:55 »

That's something you're going to have to use a debugger for and figure out on your own. Its not something we can take a look at and be like, oh here's the issue because its messing up somewhere else in your code. Using a debugger is super easy!
Offline Dev Crucio

Senior Devvie


Medals: 9
Projects: 1
Exp: 9 years


CaveGear


« Reply #2 - Posted 2015-06-12 12:27:05 »

alright, gonna do that  Roll Eyes

Twitch - See me developing CaveGear Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Dev Crucio

Senior Devvie


Medals: 9
Projects: 1
Exp: 9 years


CaveGear


« Reply #3 - Posted 2015-06-12 12:35:43 »

figured out time was a long and the delta value that gets added a float, without the Misc.log it's running under 1ms per update which keeps the long to 0 and with the Misc.log it's a bit above 1ms  Cranky wow

changed the time variable to be a float as well

Twitch - See me developing CaveGear Smiley
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (357 views)
2019-09-04 15:33:17

hadezbladez (5195 views)
2018-11-16 13:46:03

hadezbladez (2080 views)
2018-11-16 13:41:33

hadezbladez (5417 views)
2018-11-16 13:35:35

hadezbladez (1130 views)
2018-11-16 13:32:03

EgonOlsen (4554 views)
2018-06-10 19:43:48

EgonOlsen (5417 views)
2018-06-10 19:43:44

EgonOlsen (3095 views)
2018-06-10 19:43:20

DesertCoockie (3988 views)
2018-05-13 18:23:11

nelsongames (4593 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!