Sign in to follow this  

[java] Simple Java Applet Game Finished: Looking for Feedback

This topic is 3496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You could use the A-tag, so we don't need to copy&paste.

The game itself was quite psychedelic. It ran a with a low FPS on my admittedly somewhat outdated laptop. How are you drawing those circles?

Share this post


Link to post
Share on other sites
What is the A-tag? I tried adding [a] and [/a] but that doesn't do anything.

As for the circles, I am using Graphics.fillOval() and Graphics.drawOval(). If there is a faster way to do that, please let me know, as I am kind of a noob when it comes to graphics with java. I get somewhere from 100-200 FPS on my machine when the game is in full action.

Share this post


Link to post
Share on other sites
<a href = "link"> Description </a>

fillOval and drawOval are probably fast enough. There might be a slight speed improvement if you used bitmaps, but I doubt it. I guess there are just too many circles for my old lappie.

I tried it on a faster machine too and it's much better, though when you shoot, there's a weird jerk where all the balls seem to jump a bit.

Share this post


Link to post
Share on other sites
Quote:
Original post by scottrick49
can you be more specific?

Not much. It's not very easy to see, but it's as if a couple of frames would not be rendered when I release the mouse button.

Share this post


Link to post
Share on other sites
psychedelic indeed.

I reckon that a more clear explanation of the game is needed somewhere - for me it ran for about 2-3 mins while i tried to get it to start (pressing spacebar did nothing, and the mouse didn;t appear - then suddenly it started working properly and I was able to play.

Good stuff though

Share this post


Link to post
Share on other sites
Yeah, a small explanation of what you're supposed to do in the game would've been nice.

The space bar didn't work because for some reason the applet didn't have focus at first. If you click anywhere on the applet, the space will work. Probably a good idea to remove the space to start thing though, since keyboard isn't really needed in the game anyway.

Share this post


Link to post
Share on other sites
As said above, you need to give the java applet focus before it will recognize the spacebar.

True, you don't need the spacebar to start since you can click the button. The spacebar does use your slow-motion ability though once the game has started. I thought about putting some instructions on the front page, but I thought a more simplified look worked better. I feel that the game is so simple that no explanation is really needed and after you play once you pretty much have the hang of it.

Share this post


Link to post
Share on other sites
Quote:
Original post by scottrick49
I feel that the game is so simple that no explanation is really needed and after you play once you pretty much have the hang of it.

I had no idea that there was a slow motion feature. You might wish to place that note closer to the center of the screen and in a bigger font.

BTW, The jerk appears even when I click on an empty spot, when the explosion circles don't appear. What are you doing in response to the mouse release event? I guess you're iterating over all of the circles and testing for hits. How many circles are there? Are you doing something else?

Share this post


Link to post
Share on other sites
Quote:
Original post by SnotBob
I had no idea that there was a slow motion feature. You might wish to place that note closer to the center of the screen and in a bigger font.

BTW, The jerk appears even when I click on an empty spot, when the explosion circles don't appear. What are you doing in response to the mouse release event? I guess you're iterating over all of the circles and testing for hits. How many circles are there? Are you doing something else?


For collision detection, it is not iterating over all the circles. This would be slower, I think, and also there would be no easy way to tell which circle is on top in the case when you would hit multiple circles. Everytime you fire, a "collision image" is drawn by painting just the circles (none of the explosions or ripple effets), each with a unique color based on their internal id number. Then using the mouse coordinates, I get the color of where you are aiming, and if that color is not black, you have hit a circle (whose color is also its internal id). Its very fast and perfectly accurate collision detection which will take less than the time it takes to draw the screen once to perform.

Only a couple other things occur when you shoot:

1) the cursor changes color
2) ripple effect is created (very cheap i doubt this is the problem)
3) PixelGrabber object is created (used in the collision detection process to grab the pixel color of a given pixel from the collision image).
4) if you hit, a explosion is created at that point; again very cheap process.

I am not creating a new image everytime you shoot; the old one is cleared and reused.

Share this post


Link to post
Share on other sites
Quote:
Original post by scottrick49
For collision detection, it is not iterating over all the circles. This would be slower, I think, and also there would be no easy way to tell which circle is on top in the case when you would hit multiple circles.

Actually, I'm quite sure your method is much slower that iterating through all of them, since you have to do that anyway to draw them, don't you? I'd bet that this is the culprit behind the jerk.

You'd know which circle is on the top by testing them in the same order they are drawn and grabbing the last one that matches. It's true that iterating over all of them is not the fastest method, but it should be significantly faster than your method. If you'd wish to make it even faster (not really worth the trouble for the speed up you get, but makes for an interesting excersise) you could partition the screen into a grid and keep track of which circles are in which boxes.

Share this post


Link to post
Share on other sites
well obviously unless you are using some sort of grid to sort the circles, you will have to iterate through them all when detecting hits. At any one time there are only 50-100 objects on the screen (usually like 60); I didn't think that would be too bad to iterate through.

Maybe you are right though. I was thinking this sort of "picking" method would be faster than doing the calculations for every circle to determine if the given point is within its bounds. Since the actual painting to the image is fast, and since the image is never actual displayed on the screen, I thought it seemed reasonable. Maybe creating the PixelGrabber object for the image is slower than I thought?

I remember when I first added in collision detection and not seeing any noticable delay. I can smash down on the mouse as fast as I possibly can and not notice anything.

How fast is your computer? I'm on a core2duo, maybe that has something to do with it.

Share this post


Link to post
Share on other sites
Quote:
Original post by scottrick49
How fast is your computer? I'm on a core2duo, maybe that has something to do with it.

Mine's 1.6Ghz AMD, so it's a bit slower.

And no, the PixelGrabber isn't the reason why it's slow. Simply drawing a circle is going to be at least an order of magnitude slower that doing the bounds check.

Share this post


Link to post
Share on other sites
The game is finished now. I made modifications to the hit detection so that it uses simple bounds checking, instead of the image/color thing I was doing before. SnotBob if you are around I would be curious to see if you can see any performance difference. I also made some other changes to improve drawing, and smooth the circle animations more. Most of the change is just the addition of global highscores, which it turns out probably took just as long to write as the rest of the game.

The only issue I know about with the game is a problem with the Opera browser and retrieving the highscores. To retrieve the highscores, the applet just grabs a text file off the internet, and for some reason in the Opera browser it will keep grabbing an older version (presumably cached somehow?). It doesn't happen with IE or FF. If anybody has any ideas how to fix that, please let me know.

linky!

Share this post


Link to post
Share on other sites

This topic is 3496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this