ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
on:
2005-01-25 14:37:32 » |
|
Well, I'm still a little over the 4k limit, but I haven't started doing the optimisation of my code, I'm currently at 6526 bytes, but should make 4k by the end of Feb. Anyway here it is Super Sprint 4k *cough* 7k ;-) Super Sprint 4kInstructions and source code are available on my site, I'm sure a few people here will wince horribly when they see the code. A few outstanding issuse still to be finished, e.g. car animation, better collision detection etc. Be kind, Andy.
|
|
|
|
Malohkan
JGO Neuromancer     Posts: 1108 Medals: 1
while (true) System.out.println("WOO!!!!");
|
 |
«
Reply #1 on:
2005-01-25 14:44:00 » |
|
Interesting start  Reverse and restart features would be nice
|
|
|
|
jbanes
JGO Neuromancer     Posts: 1178
"Java Games? Incredible! Mr. Incredible, that is!"
|
 |
«
Reply #2 on:
2005-01-25 14:50:11 » |
|
I can't play it because my Mac doesn't have Java 1.5, but you may find this first year entry very interesting... http://www.pkl.net/~rsc/4KApplet/4KApplet.html
|
|
|
|
Games published by our own members! Go get 'em!
|
|
Malohkan
JGO Neuromancer     Posts: 1108 Medals: 1
while (true) System.out.println("WOO!!!!");
|
 |
«
Reply #3 on:
2005-01-25 14:56:13 » |
|
I managed to get all of Abuse's cars in a jam in a corner 
|
|
|
|
jbanes
JGO Neuromancer     Posts: 1178
"Java Games? Incredible! Mr. Incredible, that is!"
|
 |
«
Reply #4 on:
2005-01-25 15:03:41 » |
|
Whoa. Time-out! I just looked through the code, and there's some serious optimizing that can be done: 1. Replace the three parameter constructors of Color (i.e. new Color(240, 160, 0)) with the Hex equivalents (e.g. new Color(0xF0A000)). 2. Move as many of those static entries into the main method as possible! You don't pay extra for method variables (they're all on the stack), but you do pay for fields and methods! 3. Get rid of unnecessary class references. Being able to use "Point" is nice, but for what it costs, you should stick to a 2D array. 4. Nice fonts are, well, nice, but configuring them costs some serious class space. Ditch 'em and use whatever the default is. 5. Move all that INT data to a file. I know you think you're saving space by using an embedded array, but what you're actually doing is generating a constant pool entry plus a stack push operation for each array item! If you want to embed the data, encode it as a string and decode it at runtime. 6. This: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| JPanel panel = (JPanel) container.getContentPane(); panel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); panel.setLayout(null); setBounds(0, 0, WIDTH, HEIGHT); panel.add(this); setIgnoreRepaint(true); container.pack(); container.setResizable(false); container.setVisible(true); |
Can be more succinctly stated as: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| JPanel panel = (JPanel) container.getContentPane(); setBounds(0, 0, WIDTH, HEIGHT); panel.add(this); setIgnoreRepaint(true); container.setResizable(false); container.setVisible(true); |
7. Inline those methods! In short, you've got a lots of opportunities to fit this in 4K. :-)
|
|
|
|
ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
Reply #5 on:
2005-01-25 15:46:56 » |
|
Thanks for the quick responses, having tried a few quick optimisations I've knocked another 900bytes off the total, and that was just by inlining most of my methods!
jbanes, thanks for the links and tips, I'll be sure to check them out.
I don't use any Java 1.5 features, so I've changed the jnlp file so that everyone can play.
Feeback is such a wonderful boost to the ego, I really must get this finished now.
Thanks,
Andy.
|
|
|
|
jojoh
JGO Ninja    Posts: 554 Medals: 6
games4j.com
|
 |
«
Reply #6 on:
2005-01-26 02:33:54 » |
|
Looks very interesting. Tried to run it on a Java 1.4 machine, but got this from the downloaded jar 1 2 3 4 5 6 7 8 9 10 11 12 13
| Exception in thread "main" java.lang.UnsupportedClassVersionError: SS (Unsupported major.minor version 49.0) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:539) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:251) at java.net.URLClassLoader.access$100(URLClassLoader.java:55) at java.net.URLClassLoader$1.run(URLClassLoader.java:194) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) |
Think this is because it is still compiled to a Java 1.5 class. The nice feedback from the webstart is that the splash screen just sits there, and then nothing happens. Would have been nice from sun, to give some sort info on what went wrong Anyway, it should be enough to change the "compile level" or something like that to 1.4 or lower.
|
|
|
|
ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
Reply #7 on:
2005-01-26 05:22:22 » |
|
I'll change the target to 1.2 on the compiler for the next release. I forgot to do this when I changed the jnlp to reference 1.2 as well.
Check back in 18hrs for an update.
Andy.
PS: Happy Australia Day to all our Australian community members.
|
|
|
|
darkprophet
JGO Neuromancer     Posts: 1171
Go Go Gadget Arms
|
 |
«
Reply #8 on:
2005-01-26 11:36:18 » |
|
hehehe, v. fun game!  Im the only one left!  DP
|
|
|
|
Malohkan
JGO Neuromancer     Posts: 1108 Medals: 1
while (true) System.out.println("WOO!!!!");
|
 |
«
Reply #9 on:
2005-01-26 14:42:41 » |
|
That's the traffic jam I was talkin about! 
|
|
|
|
Games published by our own members! Go get 'em!
|
|
Abuse
JGO Kernel      Posts: 1866 Medals: 5
falling into the abyss of reality
|
 |
«
Reply #10 on:
2005-01-26 16:24:13 » |
|
hehe, yeah that game was sooooo primitive =)
|
|
|
|
|
jbanes
JGO Neuromancer     Posts: 1178
"Java Games? Incredible! Mr. Incredible, that is!"
|
 |
«
Reply #11 on:
2005-01-26 16:55:19 » |
|
hehe, yeah that game was sooooo primitive =) I seem to remember that was the time when you were certain that nothing useful would fit in 4k. ;-) But you are correct. These days you'd have fit fullscreen, scrolling, and powerups into it! 
|
|
|
|
ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
Reply #12 on:
2005-01-27 04:09:12 » |
|
I've re-compiled the code with the target=1.2 flag, which has saved me another 100bytes, as well as allowing Mac users to finally play the game.
I'm in the progress of adding Mac support to my tutorials sections as well, so look out for those updates in the next day or two.
Regards,
Andy.
|
|
|
|
darkprophet
JGO Neuromancer     Posts: 1171
Go Go Gadget Arms
|
 |
«
Reply #13 on:
2005-01-27 06:24:21 » |
|
it still wont run on 1.4  Update the jar please! Im dyin to play this game!  DP
|
|
|
|
ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
Reply #14 on:
2005-01-27 12:33:03 » |
|
Updated.
Never code when drunk, it doesn't always go as planned.
Andy.
|
|
|
|
darkprophet
JGO Neuromancer     Posts: 1171
Go Go Gadget Arms
|
 |
«
Reply #15 on:
2005-01-27 13:51:38 » |
|
What ever happened to rotation?  If you make em top down, and add rotation, it would be super!
|
|
|
|
ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
Reply #16 on:
2005-01-27 14:56:46 » |
|
Rotation is one of the few things left on my to-do list, along with lap counter for your car and better collision detection.
I should be able to post an update on Sunday night that contains some/all of these updates.
I was concentrating this week on reducing the size (still over the limit) and making sure I compiled everything with 1.2 so our Mac friends can play along.
Andy.
|
|
|
|
oNyx
JGO Kernel      Posts: 2943 Medals: 5
pixels! :x
|
 |
«
Reply #17 on:
2005-01-27 15:08:46 » |
|
Mac-compatibility means right now 1.4 and not 1.2 
|
|
|
|
Virum
Full Member   Posts: 115
Like a leaf in an icy world, memories will fade
|
 |
«
Reply #18 on:
2005-01-27 19:29:18 » |
|
hehe, yeah that game was sooooo primitive =) I seem to remember everyone being blown away by it. 
|
It's time to prove to your friends that your worth a damn. Sometimes that means dying; sometimes that means killing a whole lotta people.Blog
|
|
|
ap_kelly
Full Member   Posts: 194
Java rocks!
|
 |
«
Reply #19 on:
2005-01-27 22:16:38 » |
|
Mac-compatibility means right now 1.4 and not 1.2  So does this mean it needs to be re-compiled with 1.4? I would have thought that the 1.4 JVM could run 1.2 code, correct? Andy.
|
|
|
|
|