Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  PacDasher  (Read 7073 times)
0 Members and 1 Guest are viewing this topic.
Offline oranda

Senior Newbie





« Posted 2003-06-09 01:48:59 »

Hello,

This is my first post to java-gaming.org, announcing the creation of a new Pac-Man clone, called PacDasher.

PacDasher requires J2SE 1.4 -- a large part of my reason for creating the game was to experiment with the latest 2D API and garbage collection features. The game allows custom mazes to be written in XML. Sample mazes, faithful to the original Midway versions, are included.

The latest version, 0.8.5, can be downloaded at

https://sourceforge.net/projects/pacdasher

More info at

http://www.oranda.com/java/pacdasher

Bug reports to code@oranda.com. I am an experienced Java developer but this is my first arcade game, so comments and criticisms would be welcomed.

In developing the game I learnt a number of lessons. They will be old news for most people on this board (which I often used to research issues) but I'd like to share my experience as I think many other first-time Java game creators will go through the same things and maybe this summary will save them some time:


1. Review double buffering and understand the new BufferStrategy class.

2. Garbage collection is your biggest enemy as it interrupts the animation. Create a minimum of objects in the main iteration loop (instead reuse objects with pools, etc.) Measure the memory put on the heap per frame (for PacDasher <2K per frame). Java API calls can create a lot of garbage too. Choose a low-pause garbage collector on the java command-line. Call System.gc() at natural pauses in the game.

3. Also important for a constant frame rate is to eliminate Hotspot's opportunistic compilation. Use -Xcomp or -Xint.

4. Whereas most OO designs will concentrate on reusability, arcade game designs should concentrate on performance to compensate for Java's relative slowness.

5. Design data structures based on expected usage. What is the most common question that processing will put to your UI model? Also, for decent frame rates(PacDasher has 50 fps) only use Collections if you really need their methods. Prefer arrays.

6. It would be nice to use layers to separate what changes from what doesn't. This is well supported in the MIDP 2.0 Game API. Unfortunately in J2SE there are a lot of technical difficulties. Images take too much time to combine. Alternatively, JLayeredFrame, as with other Swing components, is heavy in terms of memory and there seems to be no way to really efficiently clear a Graphics (foreground) context (help?). Note that transparent colors are slow too.

That's all. By the way, while testing I found my video card is too old to take advantage of the new hardware acceleration features in Java, so things like BufferStrategy would just be extra overhead from my perspective and I ended up not using them.

James McCabe,
SCJP, SCWCD, available for work around Denver.


Click to Play
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #1 - Posted 2003-06-09 02:45:59 »

Good points:

- Very cleanly coded! Good job!
- Well engineered
- Seems true to the original

Not so good points:

- Not active rendered. BufferStrategy is designed for use in a hard loop, not constant calls to "repaint()". Those repaint calls are costing you in FPS as the AWT thread will call "paint()" whenever it feels like it. Assuming the 1.4.2 VM, you should be able to get ~500 fps.
- The keys don't work for me. I checked the code and it looks like I should be able to use the arrow keys to control pac-man. Unfortunately, pac-man doesn't respond!
- Your run script is missing "-cp pacdasher.jar". Better yet would be to make pacdasher.jar executable.


BTW, layering is easy once you break out of the AWT/Swing world. I'm sure I'll get flamed for *another* link, but you should check out the GAGE2D Parallax scrolling stuff. Triple-parallax scrolling or better all managed automatically in a simple bit of code.

EDIT: Didn't see the part about no longer using buffer strategy. I had to download 7.5 since the 8.5 zip file is corruptted. Personally, I think not using BufferStrategy is a mistake. You should be able to get excellent performance even out of older video cards. My best guess as to why it may be giving poor performance is due to the "repaint()" calls.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline benny

Junior Member




Java rocks! But then again anime rocks too!


« Reply #2 - Posted 2003-06-21 16:19:47 »

I can't get PacDasher to work. I added all the jars to my classpath using the Windows enviroment variables changer, but it still doesn't work. When I try to run it, it says "Exception Main not found" or something like that. Then, when i try the "Build" batch file i get a whole list of compile errors. Any suggestions (I would love to have PacMan on my computer!!!!) Cheesy

Windows XP Professional
Pentium II 450 MHz with 256 MB of SD-RAM
64 MB GeForce4 MX-440 SE

Arnold Schwarzenegger runs for governor: Lets cut violence in half with a laser guided machine gun across the barren, charred wastelands--for the children.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oranda

Senior Newbie





« Reply #3 - Posted 2003-06-22 20:30:46 »

Hi Benny,

Jerason showed me that 0.8.8 has poor packaging. I've just made 0.8.9:

http://prdownloads.sourceforge.net/pacdasher/pacdasher_0_8_9.zip?download

Use the run and cleanbuild scripts. I've tested it under NT4 and RedHat 9. Let me know how you get on: I'm interested in bug reports for different machines than my own, and general suggestions.

James
Offline benny

Junior Member




Java rocks! But then again anime rocks too!


« Reply #4 - Posted 2003-07-06 02:28:05 »

Ok, now PacDasher works and as your docs say the animation is smooth. But the controls are far from smooth.  Angry The game takes three seconds to detect my arrowkey input. During these three seconds PacMan goes in a straight direction, gets stuck at a wall, and starts chewing at it. After these three seconds PacDasher detects my key input for 2 seconds and then PacMan does his thing with the wall again for 3 seconds. Also during these three seconds, I noticed that the computer kind of "freezes". The Caps Lock doesn't respond and when (in Windows XP) the mouse is over the X button in the PacDasher window, the X button doesn't detect the mouse layover.

To make a long speech short, the controls are really sluggish. This game makes me feel that I suck at PacMan (before now I was really good Cheesy).

Please fix the controls, so that I can appease my bruised ego.  Cheesy

Windows XP Professional
Pentium II 450 MHz with 256 MB of SD-RAM
64 MB GeForce4 MX-440 SE

Arnold Schwarzenegger runs for governor: Lets cut violence in half with a laser guided machine gun across the barren, charred wastelands--for the children.
Offline benny

Junior Member




Java rocks! But then again anime rocks too!


« Reply #5 - Posted 2003-07-09 14:37:50 »

Adding on to my previous message:

The performance is better when I run it on RedHat 7.2, but Pac-Man is still a bit slow to respond (this time chewing on walls for a second).

Quote
Call System.gc() at natural pauses in the game


I never knew that the Java Runtime can immediately garbage collect whenever you use System.gc()!! I thought the command just told the VM to garbage collect at some time.

You lucky bastard, I want RedHat 9  Angry

Windows XP Professional
Pentium II 450 MHz with 256 MB of SD-RAM
64 MB GeForce4 MX-440 SE

Arnold Schwarzenegger runs for governor: Lets cut violence in half with a laser guided machine gun across the barren, charred wastelands--for the children.
Offline oranda

Senior Newbie





« Reply #6 - Posted 2003-07-25 17:30:33 »

0.9.0 is out there. Now with an ant build.

There are several reports of the keys being sluggish. I can't promise this is fixed in the latest version, as I have not reproduced the problem on my local machine. So this is currently the most frustrating thing.

Benny, System.gc() only suggests that the garbage collector run. Though in my experience it generally runs right away.

James

Offline Kevdog

Junior Member





« Reply #7 - Posted 2003-07-25 19:10:56 »

With JDk 1.4.x it is not recommended to call System.gc() anymore.  This can actually hurt performance.  At one of the JavaOne performance sessions, they said that the System.gc() can 'force' a full garbage collection cycle, when it may not be necessary.  Given the new short-lived area (can't think of the correct name atm.. too tired!) garbage collection is not such the pain it was, though you should still keep created objects to a minimum Cheesy

There are only 10 types of people, those who understand binary and those who don't!
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #8 - Posted 2003-07-25 19:32:26 »

Quote
Given the new short-lived area (can't think of the correct name atm.. too tired!)


The "nursery" of the "generational garbage collector". The idea is that short lived objects go into the nursery, then when all those objects are dead, the entire memory heap gets dumped. Rather efficient actually.

BTW, it's no wonder you're having keyboard issues. First, you explicitly enabled the keyboard event mask (that's a no-no), then you put the following code on your Canvases:

1  
2  
3  
4  
public void addKeyListener(KeyListener listener)
{
    pacframe.addKeyListener(listener);
}


You've got a 50/50 chance that the keys will ever go to the frame considering that frames are non-keyboard focusable. Which of course, brings me to another point. Your entire code structure would be much simpler if you got rid of the AWT components and used only direct rendering on the frame. Not only would you be guaranteed that the frame would get the events, you would also be able to remove the tremendous number of hacks and cruft that you have just to support multiple canvases. I'd send you to look at GAGE to get a good idea of how properly to do it, but I'm afraid my server is down right now. Sad

That being said, this release is much easier to wade through. I haven't tried compiling it yet, but the ANT script is a good sign. Keep up the good work. Smiley


Edit: The GAGE server is back!

Java Game Console Project
Last Journal Entry: 12/17/04
Offline benny

Junior Member




Java rocks! But then again anime rocks too!


« Reply #9 - Posted 2003-08-04 15:08:51 »

Hey guess what! I switched my video card to a GeForce 4 MX 440 SE and all the keyboard input problems were gone!!!

Does PacDasher need 2D hardware acceleration or something?

However, whenever I eat a ghost it takes some time for it to return to the center (2 seconds).

Windows XP Professional
Pentium II 450 MHz with 256 MB of SD-RAM
64 MB GeForce4 MX-440 SE

Arnold Schwarzenegger runs for governor: Lets cut violence in half with a laser guided machine gun across the barren, charred wastelands--for the children.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oranda

Senior Newbie





« Reply #10 - Posted 2004-05-09 12:32:36 »

PacDasher 0.93 has been released. Note that J2SE 1.5 beta 1 (http://java.sun.com/j2se/1.5.0/download.jsp) or above is now required. If you have this you might even be able to run it now from your browser:

http://www.oranda.com/java/pacdasher/pacdasher.jnlp

As usual the source can be downloaded at http://www.sourceforge.net/projects/pacdasher.

Changes since my last post include bug fixes, J2SE 1.5, java.util logging, Web Start (a requested feature), and more mazes. To see a sample maze, try

run spiral.xml

You can make your own mazes. The XML format is fairly self-explanatory I think: let me know if it is not.

If you encounter a bug, especially anything to do with key input or jerkiness, please send me the pacdasher.log (in the same directory as the run script) and let me know what video card you are using. I can be reached at code@NOSPAMBoTSoranda.com (without the 'NOSPAMBoTS'). Thank you to all who have commented and made suggestions in the past.

Human interest: see today's NYT report on 'Pac-Manhattan'. http://www.nytimes.com/2004/05/09/fashion/09GAME.html.


 
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #11 - Posted 2004-05-09 23:28:36 »

Why 1.5 only?  I was about to try it on the Mac until I read that. Sad

Offline digitprop

Junior Member





« Reply #12 - Posted 2004-05-10 06:19:03 »

I get an error when trying to webstart it. The reason is obviously a reference to localhost in the JNLP file:

1  
2  
3  
4  
5  
6  
7  
8  
9  
<?xml version="1.0" encoding="utf-8"?>

<jnlp spec="1.0+"

  codebase="http://localhost:8080/pacdasher"

  href="pacdasher.jnlp">

  ...

M. Fischer . www.digitprop.com
Offline deepFlame

Senior Newbie




Java games rock!


« Reply #13 - Posted 2004-05-10 20:00:09 »

Hey,

your game is very well coded.  Congrats.

But  it's coded for 1.5 sadly :-( . So I can't use it within Eclipse.
What IDE do you use? Is it a netbeans version?

Running the game I saw that it uses the full CPU power. Perhaps you should do a Thread.sleep(x) in the game loop.

Also it would be very cool if you would use CVS on sourceforge to get all the code updates. But it's only a thought...
Offline oranda

Senior Newbie





« Reply #14 - Posted 2004-05-12 02:06:18 »

PacDasher 0.95 is out -- now with sound. PacDasher is a maze arcade game which is: free, open-source, and configurable.

digitprop: I corrected the blooper in the Web Start config. If you clear your cache in the Java Control Panel, it ought to work now:

http://www.oranda.com/java/pacdasher/pacdasher.jnlp

swpalmer: Sorry about the Mac thing. The features in J2SE 1.5 were too attractive for me to resist.

deepFlame: That's interesting about  the CPU.  PacDasher has frame rate control so it grabs all the sleep() it can get.  On my 1.4MHz Wintel system, it takes 30% CPU. I know it performs much worse on Linux. On the IDE question, I am using the latest NetBeans (3.6). It doesn't support 1.5 either but I manage.

James McCabe, SCJP, SCWCD, SCBCD.
Offline DrBizzar0

Junior Member




Raj raj!


« Reply #15 - Posted 2004-05-12 05:23:43 »

Dunno if it supposed to be this slow, but it takes me 14 seconds to cross the long path at the bottom of level1. And it takes a 100% of the cpu time, so if it's supposed to sleep in the free time there must be something wrong Wink. WinXP, Athlon 2.0Ghz, Gf4, Java1.5b1.
Offline deepFlame

Senior Newbie




Java games rock!


« Reply #16 - Posted 2004-05-12 08:08:54 »

Quote
That's interesting about  the CPU.  PacDasher has frame rate control so it grabs all the sleep() it can get.  On my 1.4MHz Wintel system, it takes 30% CPU.


The new vbersion has the same problem. 100% CPU and it's kind of slow. But not so slow like discribed above :-).

Hope my specs help:
Win XP
Athlon 1800+
ATI Radeon 9500
Java 1.5b
Offline oranda

Senior Newbie





« Reply #17 - Posted 2004-05-12 21:29:28 »

I think I've fixed the worst of it. CPU usage is now less than a quarter of what it was. PacDasher 0.96 uses full-screen exclusive mode to ensure that the page flipping abilities of most video cards will work. Also, there is extra double buffering for the complex maze.

It should take less than 5 seconds to cross the long path at the bottom of level1.

If you clear your Java Console, and go to

http://www.oranda.com/java/pacdasher/pacdasher.jnlp

...I hope you will have a better experience. If you are using the full version from sourceforge.net, and it is still slow, please send me your pacdasher.log as there is a lot of good debugging info in there.

James
Offline DrBizzar0

Junior Member




Raj raj!


« Reply #18 - Posted 2004-05-13 11:20:34 »

yes, now it's running fine Cheesy
Offline deepFlame

Senior Newbie




Java games rock!


« Reply #19 - Posted 2004-05-13 16:06:38 »

Yeah, that's the way it's ment to be played  Smiley
The speed is good now.

But is there a "special key" to exit the game or is it just F4?
And it would be nice if the game is in the middle of the screen too, but I think thats on your mind  also Wink.

Good game, thanks
Offline Jens

Senior Member




Java for games!


« Reply #20 - Posted 2004-05-13 16:38:38 »

That's a nice game.  Smiley Smiley

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline oranda

Senior Newbie





« Reply #21 - Posted 2004-05-25 02:11:16 »

PacDasher 0.98 has been released. It contains bug fixes and extra effects. Also there are two configurations:

The classic maze with 8 levels (I thought 256 was too many), each a little faster than the last:

http://www.oranda.com/java/pacdasher/pacdasher.jnlp

... and a configuration with five different mazes, one for each level:

http://www.oranda.com/java/pacdasher/pacdasherVariety.jnlp

Try the latest version (also at sourceforge.net) and let me know if there is anything I should fix before 1.0. Has anybody tried it on Linux yet?

The comments so far have been very helpful.

James
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #22 - Posted 2004-05-25 02:23:37 »

Quote

Try the latest version (also at sourceforge.net) and let me know if there is anything I should fix before 1.0. Has anybody tried it on Linux yet?


I would try it, except you aren't allowing any standard VM's (webstart is setup to only allowed the as-yet-unreleased 1.5.x JVM) which kind of limits your playerbase Sad.

I've got another machine with 1.5.x beta installed for compatibility tests (and because of compiler bugs in 1.4.x!) but only use it for compiling really so might have to setup lots of extra stuff to get a windowing system etc on there Sad.

malloc will be first against the wall when the revolution comes...
Offline TheBohemian

Junior Member




Java will rule them all!


« Reply #23 - Posted 2004-05-28 09:40:13 »

you can have 1.4 support by reweaving the class files: retroweaver.sf.net

this helps when you have used generics and iterable (for-each).

if you have used anything from the JDK 1.5 API you should wrap the functionality. eg. use System.currentTimeMillis() when system property java.version reports 1.4 and System.nanoTimer() on 1.5 only.

btw: game runs nice on linux

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline oranda

Senior Newbie





« Reply #24 - Posted 2004-06-14 03:15:12 »

Thanks TheBohemian. Retroweaver seems to work pretty well. In release 0.99 of PacDasher I have a run14 script for people using Java 1.4:

http://prdownloads.sourceforge.net/pacdasher/pacdasher_0_9_9.zip

Hope this works for Mac users like swpalmer. There is just one extra bug in the 1.4 version, to do with sound.

Version 0.99 also has fruit at each level, a classic Pac-Man feature missing till now.

Let me know of any problems. I'm afraid I won't have much more time to work on PacDasher, as I am going back into industry soon.

James



Offline rreyelts

Junior Member




There is nothing Nu under the sun


« Reply #25 - Posted 2004-06-17 17:09:20 »

Quote
Thanks TheBohemian. Retroweaver seems to work pretty well.

Uh oh, blah^3. Are you ready to give Retroweaver a try yet? Wink

God bless,
-Toby Reyelts

About me: http://jroller.com/page/rreyelts
Jace - Easier JNI: http://jace.reyelts.com/jace
Retroweaver - Compile on JDK1.5, and deploy on 1.4: http://retroweaver.sf.net.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #26 - Posted 2004-06-17 18:03:28 »

Quote

Uh oh, blah^3. Are you ready to give Retroweaver a try yet? Wink


Just to be clear: I never had a reason not to try retroweaver (and indeed it's solely thanks to me that it's sticky in the forums).

However, there are really huge reasons why it's exceptionally dangerous for people with businesses etc to bet the farm on such things.

Anyway, if a webstart version appears that uses retroweaver then I'll certainl play this game Grin

malloc will be first against the wall when the revolution comes...
Offline rreyelts

Junior Member




There is nothing Nu under the sun


« Reply #27 - Posted 2004-06-17 19:12:10 »

Quote

(and indeed it's solely thanks to me that it's sticky in the forums)

Oh, I see. Nice. Apparently, I haven't been getting notifications when posts got added to that thread. Looks like I need to do some replying.

Quote
However, there are really huge reasons why it's exceptionally dangerous for people with businesses etc to bet the farm on such things.

To each their own I suppose. The majority of users that contact me about Retroweaver are using it for business purposes. They don't seem to think they're "betting the farm", but they sure are happy about the productivity gains they get.

God bless,
-Toby Reyelts

About me: http://jroller.com/page/rreyelts
Jace - Easier JNI: http://jace.reyelts.com/jace
Retroweaver - Compile on JDK1.5, and deploy on 1.4: http://retroweaver.sf.net.
Offline oranda

Senior Newbie





« Reply #28 - Posted 2004-06-21 04:00:48 »

Quote
Anyway, if a webstart version appears that uses retroweaver then I'll certainl play this game


http://www.oranda.com/java/pacdasher/pacdasher14.jnlp

Web Start for 1.4 gives you a scarier certificate message than 1.5. Also, if the keys don't work at first, check that there isn't a dialog blocking things in the background. Lastly, sound is not supported for the 1.4 version.

By the way, has anybody tried the run14 script in the distro?

James
Offline oranda

Senior Newbie





« Reply #29 - Posted 2004-09-20 05:09:12 »

I have released 1.0 (final) of PacDasher, the free Java arcade game. It is downloadable at http://sourceforge.net/project/showfiles.php?group_id=81889&package_id=83945

On unzipping the file, just execute the run script -- assuming you have the latest version of Java. As always, the game can be run from the Web at http://www.oranda.com/java/pacdasher/pacdasher.jnlp.

Thanks to everybody for giving feedback over the past eighteen months and helping make this software what it is.

James
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (21 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (87 views)
2014-09-10 06:39:09

Tekkerue (42 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59: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!