How about some help, guys?

http://wiki.java.net/bin/view/Games/4KGamesDesign

I’ve got a few thoughts down already. This document has a LOOOOOOOooooooooonnnnnnggg way to go, however. I think I could write a book about this subject. :slight_smile:

heres some i’ve got

  1. Avoid initiating variables (e.g. int, double, float, etc) if they are gonna be 0 any way, saves about 9 bytes
  2. don’t initiate boolean as its false by default, use that instead, saves about 9 bytes
  3. avoid creating methods as they are expensive on the bytes, even if you need to repeat stuff (repatition is caught when jaring & zipping)
  4. if you need to catch exceptions, don’t do it in side the method as it takes up quiet a bit of space to add the try{}catch{} part, instead add throw Exception to the methods
public static void main(String argv[]) throws Exception
  1. also using a few old depreciated methods some times saves a bit of space too like for a JFrame instead of “setVisible(true);” you can use “show();”
  2. where possible avoid double, instead try use int instead if thats not possible then go for float, however only sometimes float help other times it becomes more expensive as it requires more casting
  3. same thing for long, try use int instead

Don’t tell me, tell the Wiki! :wink:

That’s the second tip under the “general tips” section. :slight_smile:

oh quick reply, sorry was still adding more to the reply above.

ah sorry can’t seem to be find the edit option ;D besides i don’t wanna mess it up.

Updates! Cool beans. :slight_smile:

Most of the updates would be good to add to the Wiki. It would be nice if you could demystify a few of them (e.g. The use of deprecated methods aren’t what saves space, it’s the length of the method signature), but don’t worry about getting it perfect. Being a Wiki, anyone can come around and correct you at any time. Feel free to correct my stuff as well, in case you spot any mistakes.

Edit:

[quote]ah sorry can’t seem to be find the edit option
[/quote]
The Edit link is at the bottom of the article, to the left of the list of versions. However, I think you need to be logged in to see it.

[quote]besides i don’t wanna mess it up.
[/quote]
It’s a Wiki. What’s to mess up? Easy to change, easy to fix. :wink: (Though I do wish we had MediaWiki instead of the CollabNet stuff.)

Very useful post for anyone with less programming experience, including myself. While some of the ideas are fairly obvious and/or self-explanatory, some of them really help. Thanks :smiley:

Great resource!

a bit late for me, one game “finished”… i’ll have to try another!! agh! my exams and my sleeping hours are gone!!!

this is excellent! a definite link to be added to java unlimited

OnYx wrote this in my thread:

Some of these are not in the Wiki yet, I thought I would paste them in at first but changed my mind and wanted to run them by you guys (so that one of you can put those in that you agree on).

One thing which would be great on the wiki would be if there were a pointer to the smallest way of creating a sound (procedurally, feeding some function a waveform I would guess) and playing it.

There is no “smallest way”. Like with all engineering, there are only tradeoffs. With MIDI, you can save gobs of space, but you are at the whims of the MIDI harware/software/soundbank. With procedural synthesis you can replicate more realistic sounds. However, the more realistic the function, the more space it takes. QED.

I wrote:

“look around in the lib for stuff you can (ab)use”

I used Rectangle.Float objects in fuzetsu for tracking the particle/bullet positions (x and y fields) and velocities (width and height fields). Worked a lot bettern than expected. :slight_smile:

edit: In jm4k I used arrays, which was a) a pain b) horrible inefficient and c) most likely not smaller at all.

Wiki sucks, sometimes…

I added 8 tips! 5 of them got removed by somebody…

What a bunch of crap.

Maybe they sucked? ;D

…kidding

double post them, here and on the wiki.

maybe a sticky with the most valuable hints?

Riven, none of them got removed. I moved them up to the “General Tips” area and did a bit of rewording to be consistent with the rest of the tips. Check for yourself. The tips should look very familiar.

Cooperation in improving the document is how Wikis are supposed to work. (Though it is a bit weird at first.) If it looks like something has been removed, use the DIFF tool to figure out if it hasn’t just been shuffled around a bit. :slight_smile:

Edit: sigh I wish you hadn’t gone and deleted the tips in the Misc area. This Wiki doesn’t show the original formatting, meaning that I’m going to have to spend some time recreating it. Again, your other tips weren’t deleted. They were promoted.

Whoops… ::slight_smile:

I did a very quick search to find my tips elsewhere but could not find it.

I’ll dig the other tips out of rivision-history then.

This was my first encounter with Wikis, so please bare with me… kuch

Err, I meant:I didn’t find it the first time, but ofcourse I found them when you told me where to look.

Anyway, I clearified the lined marked by a (?) and I hope it’s clear now.

That’s all for today…

Excellent! Good job Riven! :slight_smile: Now if we could just get a few more people following your lead… :wink:

Great! very helpful. how abt a “Links” section?

found this useful for procedural sound -> http://fivedots.coe.psu.ac.th/~ad/jg/ch05/index.html

EDIT: This post is wrong. After compression, the first way is smaller.

It requires me to log in to edit, and I’m far too lazy to sign up, but:

public void main(String[] args) 
{
    int[] badguy_x = new int[256];
    int[] badguy_y = new int[256];
    int[] badguy_type = new int[256];
    
    draw(badguy_x[0], badguy_y[0], badguy_type[0]);
}

takes more space than

public void main(String[] args) 
{
    int[][] badguy = new int[256][3];

    draw(badguy[0][0], badguy[0][1], badguy[0][2]);
}