j_jerrik
JGO n00b  Posts: 21
|
 |
«
on:
2008-01-25 08:26:55 » |
|
Hey everyone, Have been writing my first game in Java, its still WIP, but playable. Its an arena shooter done in Java2d. Take a look, and leave a comment. http://www.sparx.dkNeed some tips on implementing a global hiscore table. Check out my music --> http://www.myspace.com/hazerec
|
|
|
|
Sticko
Guest
|
 |
«
Reply #1 on:
2008-01-25 14:06:40 » |
|
Looks great and plays great!  I did a global high score table on my game by getting my applet to send the data to a servlet like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| URL url = new URL(cHOST_NAME); URLConnection urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { ((HttpURLConnection)urlConnection).setRequestMethod("POST"); } else { throw new Exception("this connection is NOT an HttpUrlConnection connection"); } urlConnection.setUseCaches(false); urlConnection.setDefaultUseCaches(false); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/octet-stream"); urlConnection.connect();
OutputStream os = urlConnection.getOutputStream(); os.write(bytes); os.flush(); os.close(); |
You probably don't need to make it an octet-stream if you're just sending Strings.
|
|
|
|
|
g666
Sr. Member   Posts: 388
|
 |
«
Reply #2 on:
2008-01-25 16:43:28 » |
|
nothing happens when i press S here 
|
desperately seeking sanity
|
|
|
Games published by our own members! Go get 'em!
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #3 on:
2008-01-25 16:55:26 » |
|
Looks great and plays great!  I did a global high score table on my game by getting my applet to send the data to a servlet like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| URL url = new URL(cHOST_NAME); URLConnection urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { ((HttpURLConnection)urlConnection).setRequestMethod("POST"); } else { throw new Exception("this connection is NOT an HttpUrlConnection connection"); } urlConnection.setUseCaches(false); urlConnection.setDefaultUseCaches(false); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/octet-stream"); urlConnection.connect();
OutputStream os = urlConnection.getOutputStream(); os.write(bytes); os.flush(); os.close(); |
You probably don't need to make it an octet-stream if you're just sending Strings. Thanks  -Think im gonna make a quick filebased solution tonight, my server runs php so no servlets. quote author=g666 link=topic=18091.msg142010#msg142010 date=1201297408] nothing happens when i press S here  [/quote] Make sure that the applet is in focus, by pressing the mouse button while the pointer is on the applet.
|
|
|
|
CaptainJester
JGO Neuromancer     Posts: 1127 Medals: 6
Make it work; make it better.
|
 |
«
Reply #4 on:
2008-01-25 16:55:56 » |
|
Did you click the applet to give it focus first?
|
|
|
|
CaptainJester
JGO Neuromancer     Posts: 1127 Medals: 6
Make it work; make it better.
|
 |
«
Reply #5 on:
2008-01-25 16:57:00 » |
|
-Think im gonna make a quick filebased solution tonight, my server runs php so no servlets.
It doesn't have to be a servlet, you can just send a request to a web page to record the highscores.
|
|
|
|
kappa
« League of Dukes » JGO Kernel      Posts: 2268 Medals: 50
★★★★★
|
 |
«
Reply #6 on:
2008-01-25 17:24:06 » |
|
game looks nice but runs way too slow here, probably due the size of the applet, would probably be equally as good at half that size.
|
|
|
|
|
oNyx
JGO Kernel      Posts: 2942 Medals: 5
pixels! :x
|
 |
«
Reply #7 on:
2008-01-25 18:02:45 » |
|
Runs fine here, but the size is really too big for an applet. Keep in mind that the most common resolution still is 1024x768.
The steering behavior of some of the enemies was a bit weird and jittery in spots.
Found it odd that the bullets explode when leaving the screen.
|
|
|
|
gouessej
JGO Kernel      Posts: 3433 Medals: 26
TUER
|
 |
«
Reply #8 on:
2008-01-25 18:27:08 » |
|
game looks nice but runs way too slow here, probably due the size of the applet, would probably be equally as good at half that size.
Slow? Really? Personally, I prefer when it is big.... I'm talking about the size of the applet of course  .
|
Julien Gouesse
|
|
|
EgonOlsen
JGO Strike Force    Posts: 810 Medals: 6
|
 |
«
Reply #9 on:
2008-01-26 06:33:37 » |
|
Way to fast here...a game lasts 1-2 seconds before i'm dead without the slightest chance to survive (Athlon X2 4200+, GF 7600gt, Java 6u10 (early access version with D3D pipeline)).
|
|
|
|
Games published by our own members! Go get 'em!
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #10 on:
2008-01-26 10:16:17 » |
|
Way to fast here...a game lasts 1-2 seconds before i'm dead without the slightest chance to survive (Athlon X2 4200+, GF 7600gt, Java 6u10 (early access version with D3D pipeline)).
Think im going to test it with Java 6u10 with the D3D/Opengl pipeline today, and try to make some sort of speed test, so speed of game adapts to computer used..... Do you know when Java 6u10 is officially released ??
|
|
|
|
|
|
Noya
JGO n00b  Posts: 33
|
 |
«
Reply #12 on:
2008-01-26 13:12:25 » |
|
Same problem here: Pressing S doesn't do anything. And yes, the applet has focus.
|
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #13 on:
2008-01-26 13:34:25 » |
|
Same problem here: Pressing S doesn't do anything. And yes, the applet has focus.
Ups my fault(put a faulty version up late last night), should be ok now.
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #14 on:
2008-01-26 13:40:44 » |
|
game looks nice but runs way too slow here, probably due the size of the applet, would probably be equally as good at half that size.
Whats your machines specs?
|
|
|
|
kappa
« League of Dukes » JGO Kernel      Posts: 2268 Medals: 50
★★★★★
|
 |
«
Reply #15 on:
2008-01-26 19:50:58 » |
|
AMD 3000+, 1GB RAM, NVIDIA 5900xt, Linux, Java 1.6
|
|
|
|
|
CommanderKeith
JGO Wizard     Posts: 1447 Medals: 9
|
 |
«
Reply #16 on:
2008-01-26 21:03:02 » |
|
Wow, love the graphics!!! How did you do it, obviously using java2D? All of those little effects with the pixels flying about are great.
Runs sweet here, no problem. 3ghz win XP java 6 u10
|
|
|
|
Noya
JGO n00b  Posts: 33
|
 |
«
Reply #17 on:
2008-01-27 06:30:04 » |
|
Yeah, now it works. It is really fun to play (and the controls feel good especially with a touchpad).
Every 2 seconds or so the game will begin to hang and continue after a few hundred milliseconds. My JVM process uses 100% cpu all the time. Get's my machine cooking ^^ 2.0Ghz Dual Core, 1G RAM, ATI X1600, Ubuntu Linux 7.10
|
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #18 on:
2008-01-27 08:02:55 » |
|
Wow, love the graphics!!! How did you do it, obviously using java2D? All of those little effects with the pixels flying about are great.
Its my own own little java2d engine, all graphics are done via java2d line/rect/oval drawing (no photoshop here), to keep the graphics simple, but stylish. All animations are prerendered then cached. The explosion are made with my own simple particle system(no physics, only velocity and speed), also prerendered and cached. Glad you like it
|
|
|
|
phu004
Full Member   Posts: 109
NoSuchPersonException
|
 |
«
Reply #19 on:
2008-01-28 05:29:43 » |
|
Nice fire work, running very smooth here.
Have you implemented the fifth type of enemy in your demo? I wonder what can it do .
Celeron M 1.5Ghz Java1.6
|
|
|
|
|
dishmoth
Sr. Member   Posts: 494 Medals: 15
|
 |
«
Reply #20 on:
2008-01-29 12:04:16 » |
|
Nice game! It may just be my eyes, but it seems that the bullets don't quite move in the direction they're pointing sometimes. For example, they seem to be pointing North-North-East when they're fired due North. Perhaps you're rounding in the wrong direction when mapping from an angle to an image? Simon
|
|
|
|
princec
« League of Dukes » JGO Kernel      Posts: 7802 Medals: 77
Eh? Who? What? ... Me?
|
 |
«
Reply #21 on:
2008-01-30 12:54:02 » |
|
+1 positive feedback here, well done  Cas 
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #22 on:
2008-02-04 14:54:21 » |
|
Thanx for all the feedback  Updated to v0.7 -Better graphics -Better enemy bevior -General Performance/Game tuning www.sparx.dk
|
|
|
|
princec
« League of Dukes » JGO Kernel      Posts: 7802 Medals: 77
Eh? Who? What? ... Me?
|
 |
«
Reply #23 on:
2008-02-04 15:40:01 » |
|
Suddenly runs at hundreds of frames per second, unplayable :/ What did you change? Cas 
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #24 on:
2008-02-04 16:03:52 » |
|
Suddenly runs at hundreds of frames per second, unplayable :/ What did you change? Cas  only 2ms sleeptime, Before i calculated the sleeptime each frame, so i could get a stable frame rate, was not sure if it worked, but will change it back right away..
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #25 on:
2008-02-04 16:39:23 » |
|
Calculate sleeptime for each frame again.
Put a frame counter on, but are getting some very unstable readings.
.....
public static final int FRAME_RATE = 80; public static int sleepTimeMs=1000/FRAME_RATE; private int frameTime=1000000000/FRAME_RATE;
...... public void paint(Graphics g){ long startTime = System.nanoTime(); Graphics2D g2d=(Graphics2D)g;
Color c=game.getBackgroundColor(); if(c!=null){ g2d.setColor(c); g2d.fillRect(0,0,getWidth(), getHeight()); g2d.setColor(Color.RED); g2d.drawRect(0,0,getWidth()-1,getHeight()-1); } game.paint(g); long estimatedTime = System.nanoTime() - startTime;
sleepTimeMs=(int)(frameTime-estimatedTime)/1000000; if (sleepTime<1){sleepTime=1;} }
.................
public void run() { while(true){ long startTime1 = System.nanoTime(); if(!gp.isPaused()){ gp.repaint(); } try{ sleep(sleepTime); } catch (Exception e){ e.printStackTrace(System.err); }
long estimatedTime1 = System.nanoTime() - startTime1; Sparxx.fps=(1000000000/estimatedTime1);
}
...................
|
|
|
|
CommanderKeith
JGO Wizard     Posts: 1447 Medals: 9
|
 |
«
Reply #26 on:
2008-02-05 02:00:20 » |
|
Thread.sleep(x) will not reliably sleep x millis, maybe that is causing the trouble? For example, I've found that on some windows computers, calling sleep(1) actually sleeps for 20ms.
Some people just always do sleep(1) between frames and use variable time-step updates, others do Thread.yield() or Thread.sleep(0) in a loop until the current time is greater than whatever delay they want.
Hope that helps. Keith
|
|
|
|
j_jerrik
JGO n00b  Posts: 21
|
 |
«
Reply #27 on:
2008-02-08 12:17:18 » |
|
Thread.sleep(x) will not reliably sleep x millis, maybe that is causing the trouble? For example, I've found that on some windows computers, calling sleep(1) actually sleeps for 20ms.
Some people just always do sleep(1) between frames and use variable time-step updates, others do Thread.yield() or Thread.sleep(0) in a loop until the current time is greater than whatever delay they want.
Hope that helps. Keith
Thanks alot keith, you just saved my day  That solved my timing problems, and the slowdowns. Jacob
|
|
|
|
ragatol
JGO n00b  Posts: 3
|
 |
«
Reply #28 on:
2008-02-08 12:46:25 » |
|
Looking good!  You should avoid spawing enemies near/over the player. Every time I died, I died that way. 
|
|
|
|
|
gouessej
JGO Kernel      Posts: 3433 Medals: 26
TUER
|
 |
«
Reply #29 on:
2008-05-23 15:37:03 » |
|
Please could you provide an URL to a screenshot? I need it to put your game into the Java(tm) Game Tome.
|
Julien Gouesse
|
|
|
|