A wolf3d-like java game

have u played wolf3d before? well check out my java version of this game, here is the download link:

http://www.freewebs.com/phu004/javaFPS.zip
(include source code)
run the play.html after you unzip the file.

here are some problems you might meet

  1. Q: nothing happens when i press the keyboard.
    A: you might have turned the caps-lock on, turn it off .

2。Q: the game speed is too fast or too slow.
A: press “+” and “-” to increased and decrease the game speed, until you feel comfortable

3。Q: the crosshair can’t not move up or down, how can i hit the enemy?
A: you only need to aim along the x-axis.

4。 Q: how can i win the game?
A: press “m” and you will see where your objective located on the map

if you don’t manage to download the file, I also provide a link which you can play directly by clicking it

http://www.freewebs.com/phu004/play.html

here is a screen shot of it

http://www.freewebs.com/phu004/startImage.JPG

hope you guys could enjoy my game!

thats pretty good, especially the bit where u can creep up behind that guy! ;D

You seem to have a threading issue in this game. On hyperthreading machines, the graphics are flickering like crazy because walls are missing for a frame or two, doors jump in front of you and back and so on. On non-hyperthreading cpus, i couldn’t reproduce this. Here’s a screenshot of a missing wall for you to see what i’m actually taking about: http://www.jpct.net/pics/missing.jpg

This happens on fast machines(my machine is an old p3 800, so no problem at all), you can try to reduce the frame rate by pressing “-” , you could also check the frame rate by pressing “r”. Anyway I should make my program automatically adjust the frame rate according to other players’ machines.

[quote]This happens on fast machines(my machine is an old p3 800, so no problem at all),
[/quote]
Are you sure? It does happen on a P42.8HT and on a P43.2HT…it doesn’t happen on a Athlon XP3200+ and Athlon64 3000+. Adjusting the speed with r doesn’t help btw.
That’s why i think it may have something to do with threading. I have had this problem myself: What works fine on “normal” cpus shows wierd effects on hyperthreading ones (or dual cpus setups).

It does happen on a P42.8HT and on a P43.2HT…it doesn’t happen on a Athlon XP3200+ and Athlon64 3000+.

//that’s really wired, i dont have a very good understanding how threads work and how threy are related to cpus, so i dont any clue at this point. :-[
But thank you for reminding me of this problem!

Impressive! ran pretty smooth (after I capped the framerate to about 30-35) on my XP // AMD 3200+ // 2.5GHz // 512MB RAM

The lighting effect (not to mention weapon 4’s roation effect) is very cool :wink:

As far as the threading issue goes, I only noticed very minor flickering. I wouldn’t mind help you debug EgonOlsen’s problem but you dont seem to provide the source code to your Ticker class…

seems like i forgot to put my Ticker.java in the source code, here it is http://www.freewebs.com/phu004/Ticker.java

I really appreciate your help, but personally i think my code is difficult for other to read. I merely include any comments in my code since i am the only guy involved making this game. So dont spend too much time on it if you find it difficult to read.

I think that the problem is pretty obvious: You are triggering your game logic (i.e. actionPerformed()) from your Ticker-class. This may happen in the middle of a painting, which results in in-between-states being painted, which is what causes the flickering. Maybe you should consider to overwrite paint() and update() with nothing and do the actual painting from inside your Ticker-triggered method.

Edit: I’ve modified your code to work that way and the problem is gone.

Edit: I’ve modified your code to work that way and the problem is gone.

//Wow you’ve solved the problem that puzzling me for so long, that’s terrific! Can you send your modified code to my phu004@gmail.com? cheers!

[quote]Can you send your modified code to my phu004@gmail.com? cheers!
[/quote]
Done!
Your basic problem was, that rendering and processing of the scene overlapped. You called actionPerformed() from your Ticker which itself called repaint(). But repaint() just schedules your applet for repaint and returns. The actual (re-)paint may happen at any time the VM likes…and if that happens while you are in your actionPerformed() again, you’ll get strange results. Hyperthreading/dual cpu machines are more sensible to this compared to none-HT machines…don’t know exactly why.

Thanks EgonOlsen! I applied the changes you have done in javaFPS.java to my game and my previous applications, now they all run smoother than ever before. ;D ;D ;D

[quote]Thanks EgonOlsen! I applied the changes you have done in javaFPS.java to my game and my previous applications, now they all run smoother than ever before. ;D ;D ;D
[/quote]
At your service… ;D