Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working in Windows 10 #1

Open
40OE opened this issue Apr 13, 2017 · 11 comments
Open

Not working in Windows 10 #1

40OE opened this issue Apr 13, 2017 · 11 comments

Comments

@40OE
Copy link

40OE commented Apr 13, 2017

Title. Woud love to see support for this.

@ghost
Copy link

ghost commented Jul 27, 2017

@40OE You could be more accurate. I've just tried to run the JAR in command line with Oracle Java 1.8 and the games is frozen, I see the window but it doesn't react, nothing happens when I click.

@ghost
Copy link

ghost commented Jul 27, 2017

This is the root cause:

"Thread-2" #18 prio=5 os_prio=0 tid=0x00000000217ac000 nid=0x23cc runnable [0x00000000245ff000]
java.lang.Thread.State: RUNNABLE
at com.mojang.tower.TowerComponent.run(TowerComponent.java:119)

  • locked <0x00000007568a2f78> (a com.mojang.tower.TowerComponent)
    at java.lang.Thread.run(Thread.java:745)

"AWT-EventQueue-0" #16 prio=6 os_prio=0 tid=0x00000000217a3000 nid=0x103c waiting for monitor entry [0x00000000237ed000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.mojang.tower.TowerComponent.mousePressed(TowerComponent.java:416)

  • waiting to lock <0x00000007568a2f78> (a com.mojang.tower.TowerComponent)

Rather use a queue and remove the synchronized keywords. When mousePressed() is called, it should add a Runnable into this queue. Then, the Runnable should be removed and called just before rendering here:
https://github.com/alexeypetrushin/BreakingTheTower/blob/master/src/com/mojang/tower/TowerComponent.java#L125

Markus wrote "Do not distribute altered versions of this game in any way". Therefore, I can't "distribute" a fixed version. Good luck.

@ghost
Copy link

ghost commented Jul 27, 2017

I confirm that this bug isn't reproducible under GNU Linux. I've just tested the game under Mageia Linux 6 with OpenJDK 1.8 update 131.

@ghost
Copy link

ghost commented Jul 27, 2017

@40OE Please give it a try: https://github.com/gouessej/BreakingTheTower/blob/master/Tower.jar

@alexeyPetrushin Do you want me to make a pull request?

@al6x
Copy link
Owner

al6x commented Jul 27, 2017

Hmm, thanks, but no, I'm scared by the license, it says code shouldn't be modified :)

@ghost
Copy link

ghost commented Jul 28, 2017

My fix doesn't work :(

@alexeyPetrushin Ok, I understand your position. I'll go on trying to fix this bug anyway.

@ghost
Copy link

ghost commented Jul 28, 2017

My latest fix works, enjoy :)

@40OE
Copy link
Author

40OE commented Aug 9, 2017

thanks gouessej, the fix works fine! If markus sees this, hopefully he'll understand haha

@ghost
Copy link

ghost commented Aug 9, 2017

@40OE Actually, I think that Markus will strongly refuse to use my fix because he won't be interested in maintaining this game (he wrote in java-gaming.org that he found it bad) and because he won't admit that I'm able to fix something he created. We have some disagreements but it doesn't prevent me from respecting him and from appreciating some of his games.

@ghost
Copy link

ghost commented Jun 5, 2018

@40OE I've just moved my source code to Sourceforge as my server isn't ready to host it yet and I'm leaving Github: https://sourceforge.net/p/breakingthetower

@bodziozet
Copy link

bodziozet commented Feb 10, 2024

Hi. I dont know if threads are the problem here. Because I have the issue that the game is frozen on title screen and is not responsive to click to start. So I looked at the source code and found out that in TowerComponent.java on line 108 of run function there is a variable lastTime that is declared as float. And then there is this tick while loop where you add to lastTime a double variable msPerTick which is a fraction of something like 0.03333333. And the while loop has a condition while (now - lastTime > msPerTick) { if (!paused && frameTicks++ < MAX_TICKS_PER_FRAME) tick(); lastTime += msPerTick; }
So at every while loop cycle the lastTime variable is incremented by msPerTick until lastTime is big enough to break the while loop but the problem is that because lastTime is float it is not properly incremented by the fraction. It allways stays the same value (hence the game is stuck at that loop). When i changed lastTime from float to double then it started to get incremented and the game is not frozen anymore. But to be honest it still not working good in the terms that it is trash fps performance. It do not work smoothly but it actually works. And one more thing. The name of the variable msPerTick is misleading because it suggest storing time in miliseconds per tick. But it is actualy a fraction of 1/TICKS_PER_SECOND so actually it store time of one tick in seconds right?

Ok 20 minutes later I actually made the game to run smooth. To do this first you have to change lastTime from float to double. And then around line 117 (i dont know for sure the line because the code is poluted by my modifications:D) there is variable now. So you need to set now to double now = (System.nanoTime() / 1000000d) / 1000.0d;. And also if you have problem loading the game from source code from your IDE you need to move the res files like logo.gif island.gif sheet.gif and winscreen.gif from res folder to src.com.mojang.tower folder or to change the resource path name in bitmaps.java file starting at line 33 logo = ImageIO.read(Bitmaps.class.getResource("logo.gif"));.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants