I made this, may do more work on it later
This game is nice and small, but still quite fun. The object is to score as many points as possible by blowing enemy spacecraft to smithereens. You start in your species' home system, and you can fly to the other three species' systems by jumping through the gateways/wormholes/jumpnodes/portals. In the code they are called gateways, but that is inconsequential.
Your controls are as follows:
Menu Item Selection: Mouse
Accelerate: Up
Rotate: Left + Right
Decelerate: Down
Shoot: CTRL
Afterburner (Speed boost): S
Pause: Enter
Traverse Gateway: J (hold)
I have made significant changes since the last version, including the addition of friendly and hostile carriers, and the gateway system. Because I have given up on netplay, I didn't post this in the existing topic I made on converting a 1P game to 2P(+) networked.
http://www.esnips.com/doc/e2157da2-e83c-48f7-ab55-0031e053f509
Comments/Feedback wanted. Also if you'd like to know how I did something, feel free to ask, but keep it simple and specific, nothing like "how did you make the ai for the enemies?"
# 1
Sounds very nice! Well done.Ill download it later to see how it looks.
# 2
$ unzip HP2SN2v1.zip
Archive: HP2SN2v1.zip
extracting: Images/Amberwilt.png
inflating: Images/Behemoth2.png
inflating: Images/Blast1.png
extracting: Images/Blast2.png
inflating: Images/Blast3.png
inflating: Images/Blast4.png
inflating: Images/Blast5.png
inflating: Images/Blast6.png
inflating: Images/Blast7.png
inflating: Images/HumanBullet.png
inflating: Images/KyrnBullet.png
inflating: Images/Marduk2.png
extracting: Images/Mbalu's Moon.png
extracting: Images/Scarab.png
extracting: Images/Scythe.png
inflating: Images/TauruksethBullet.png
inflating: Images/Thumbs.db
inflating: Images/Trillian2.png
inflating: Images/Vel'atir2.png
inflating: Images/VuntuBullet.png
inflating: Images/Warp0.png
inflating: Images/Warp1.png
inflating: HardPoint2.jar
$ java -jar HardPoint2.jar
Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:323)
at hardpoint2.SuperImage.<init>(SuperImage.java:31)
at hardpoint2.SuperImage.forName(SuperImage.java:61)
at hardpoint2.HP2.<init>(HP2.java:62)
at hardpoint2.HP2.main(HP2.java:190)In general it's best to pack resources in the jar.
# 3
Well done!
Some thoughts:
- The game plays quite slow now. I'm getting 10-12fps on my system, which is a bit low. I have a feeling it could be a lot faster with some optimization. It's also utilizing close to 100% of my processor, which leads me to believe there are some endless loops or something?
- The player-sprite could perhaps be made to tilt in the direction the player is steering?
- It's a little difficult to understand what's going on, and what the things you're encountering are.
- It takes a full 15 seconds from pressing the New Game button until the game starts. If such a long load-time really is required (and I doubt it) the game should display a load-screen with some kind of progress-indicator.
Anyway, it's a good effort! Keep it up.
# 4
Ok, about the images thing, I can't tell from the unzip output, but it seems like you may not have unzipped stuff in the proper directories. It should have placed all of the image files in a subfolder called Images\ and this has been a frequent cause of such problems.
I have no idea why it is so slow on some computers and so much faster on mine. I tried threading the map calculations, and that improved it on my computer from alternating between 21 and 32 fps to between (now) 32 and sixtysomething fps. The problem is probably with the Graphics, but I have no idea how to improve that. On the computers at my school, though, it takes like a minute to load the images (I know that's what's causing the delay because I have experimented and it only happens the first time it loads them, which is when you press New Game), so what you have is considerably better.
However I will post my drawShip method to see if anyone can help, as it is pissing me off that people are unable to enjoy this wonderful game.
public void drawShip(double x, double y, double cx, double cy, double theta, BufferedImage img, Graphics2D g)
{
AffineTransform n = AffineTransform.getTranslateInstance(x, y);
n.rotate(theta);
n.translate(-cx, -cy);
g.drawImage(img, n, this);
}
I have tried to limit the number of ships on the screen, but that doesn't seem to do much good, and it isn't very fun that way. Is there anything better in the standard Java packages that draws faster than the Graphics2D's (of a BufferedImage) and can take get the same job done with the same input parameters?
# 5
> Ok, about the images thing, I can't tell from the unzip output,
> but it seems like you may not have unzipped stuff in the
> proper directories. It should have placed all of the image files
> in a subfolder called Images\ and this has been a frequent
> cause of such problems.
Yes. The reason is that you've hard-coded the path separator. When I edit the class files to replace Images\ with Images/ it loads the images. I still think that putting your resources in the jar is the best thing to do, but if you really don't want to then I suggest making SuperImage.forName do a String.replace('\\', java.io.File.separatorChar);
The game runs at 3fps. A quick profile suggests that you're spawning insane numbers of threads (300+ in a few seconds), and this will be slow with some setups. You might want to look at reusing your threads - http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html may be helpful.
# 6
Oh, my...
Thank you for telling me about this. I had theorized that it was getting bogged down in the Graphics part, but I think now that it might be my game loop, or at least that is part of it. I will post code if I think it is pertinent, or if you think it is necessary. Oh, and thanks for noticing the \\ thing.