Coder Social home page Coder Social logo

Not working in Windows 10 about breakingthetower HOT 11 OPEN

40OE avatar 40OE commented on July 29, 2024
Not working in Windows 10

from breakingthetower.

Comments (11)

 avatar commented on July 29, 2024 1

@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

from breakingthetower.

 avatar commented on July 29, 2024

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

from breakingthetower.

 avatar commented on July 29, 2024

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.

from breakingthetower.

 avatar commented on July 29, 2024

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.

from breakingthetower.

 avatar commented on July 29, 2024

@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?

from breakingthetower.

al6x avatar al6x commented on July 29, 2024

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

from breakingthetower.

 avatar commented on July 29, 2024

My fix doesn't work :(

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

from breakingthetower.

 avatar commented on July 29, 2024

My latest fix works, enjoy :)

from breakingthetower.

40OE avatar 40OE commented on July 29, 2024

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

from breakingthetower.

 avatar commented on July 29, 2024

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

from breakingthetower.

bodziozet avatar bodziozet commented on July 29, 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"));.

from breakingthetower.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.