Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Putting things into perspective  (Read 7456 times)
0 Members and 1 Guest are viewing this topic.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Posted 2006-02-14 17:18:58 »

Next time you need to explain to someone just how small 4 kilobytes really is, put it this way:

360 games can fit on a single floppy disk.

That's enough to include every 4K game produced in the last 4 years of competition, and still have nearly half the space left over. If floppy drives were still popular, I'd be tempted to produce a "Java 4K Contest Special Edition Floppy" just to drive the point home.

So remember, guys. The stuff we're doing here really is incredible. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #1 - Posted 2006-02-14 17:26:28 »

368 games can fit on a single floppy disk.
...or roughly 175 000 on a single CD  Grin

Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #2 - Posted 2006-02-14 17:49:53 »

yeah, put all the games on one floppy........ and the JRE on the other 12 =)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rick

Junior Duke


Projects: 1


Java games rock!


« Reply #3 - Posted 2006-02-14 18:56:09 »

It's the size of a 64X64 pixel image.
Offline kevglass

JGO Kernel


Medals: 186
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2006-02-14 18:59:08 »

Oooo.. images from 4k jars.. good idea.. I wonder who has the coolest looking jar converted to an image ? Smiley

Kev

Offline cborders

Junior Duke





« Reply #5 - Posted 2006-02-14 19:03:09 »

I would LOVE to see these!!   Grin
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #6 - Posted 2006-02-14 19:28:19 »

Your wish is my command:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
import java.awt.*;
import java.awt.image.*;
import java.io.*;

import javax.imageio.*;

public class ImageMaker4K
{
    public static void main(String[] args) throws Exception
    {
        int[] buffer = new int[4096];
        BufferedImage image;
        FileInputStream in;
        int data;
        int index;

        if(args.length < 2)
        {
            System.out.println("Usage: java 4kImageMaker <input> <output>.png");
            return;
        }

        in = new FileInputStream(args[0]);
        index = 0;

        while((data = in.read()) >= 0 && index < buffer.length)
        {
            buffer[index] = (data << 16) | (data << 8) | data;
            index++;
        }

        image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB);
        image.setRGB(0, 0, 64, 64, buffer, 0, 64);
        ImageIO.write(image, "PNG", new File(args[1]+".png"));
    }
}


I love Java.  Grin

See the attachments for a few examples. (Sorry if your favorite game is missing, but a LOT of people need to fix or remove their JAR links.)


Java Game Console Project
Last Journal Entry: 12/17/04
Offline cborders

Junior Duke





« Reply #7 - Posted 2006-02-14 19:34:45 »

HAHA very cool! 
Offline kevglass

JGO Kernel


Medals: 186
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #8 - Posted 2006-02-14 19:37:23 »

Daftest - tool - ever.

Kev

PS. Way cool Smiley

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #9 - Posted 2006-02-14 19:41:46 »

What's interesting is that you can see massive amounts of wasted space in Warpstar4K, and reasonably good sized chunks of wasted space in W4K. You see that white wave in Xero? That means that the data is nearly all binary 1's. I'm guessing that this area could be slightly better compressed, but there is some variation in the white, which would make it more difficult for the compressor.

BTW, if you want black to represent data and white to represent the lack of data, change the loop to this:

1  
2  
3  
            data = 0xFF - data;
            buffer[index] = (data << 16) | (data << 8) | data;
            index++;

Java Game Console Project
Last Journal Entry: 12/17/04
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #10 - Posted 2006-02-14 20:00:19 »

Same in argb Wink
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
public class Gen4kImage{
   public static void main(String[]args)throws IOException{
      byte []a=new byte[4096];
      File file=new File(args[0]);
      DataInputStream in=new DataInputStream(new FileInputStream(file));
      int read=0;
      do{
         int got=in.read(a,read,(int)file.length()-read);
         read+=got;
         if(got==-1){
            System.out.println("meh");
            return;
         }
      }while(read<file.length());
      in.close();
      System.out.println(read);
      int []ab=new int[1024];
      DataInputStream in2=new DataInputStream(new ByteArrayInputStream(a));
      for(int i=0;i<1024;i++)
         ab[i]=in2.readInt();
      BufferedImage i=new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB);
      i.setRGB(0,0,32,32,ab,0,32);
      ImageIO.write(i,"png",new File("out.png"));
   }
}


fuzetsu in technicolor:

弾幕 ☆ @mahonnaiseblog
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #11 - Posted 2006-02-14 20:05:21 »

Will you look at that? Here I was just about to post my wonderful color version, and oNyx beats me to it!

Oh well, mine's better anyway.  Grin

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
import java.awt.*;
import java.awt.image.*;
import java.io.*;

import javax.imageio.*;

public class ImageMaker4K
{
    public static void main(String[] args) throws Exception
    {
        int[] buffer = new int[4096];
        BufferedImage image;
        FileInputStream in;
        int data;
        int index;

        if(args.length < 2)
        {
            System.out.println("Usage: java 4kImageMaker <input> <output>.png");
            return;
        }

        in = new FileInputStream(args[0]);
        index = 0;

        while((data = in.read()) >= 0 && index < buffer.length)
        {
            int Y = ((data & 0xE0) >> 6);
            int U = ((data & 0x1C) >> 3);
            int V = (data & 0x03);

            double R = Math.abs(Y + 1.403 * V);
            double G = Math.abs(Y - 0.344 * U - 0.714 * V);
            double B = Math.abs(Y + 1.770 * U);

            buffer[index] = ((int)(R * 255) << 16) | ((int)(G * 255) << 8) | (int)(B * 255);
            index++;
        }

        image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB);
        image.setRGB(0, 0, 64, 64, buffer, 0, 64);
        ImageIO.write(image, "PNG", new File(args[1]+".png"));
    }
}


This version works by treating each 8 bit value as a YUV color. While I'm not so sure about my YUV to RGB color conversion, it does produce a 64x64 image that can easily be palletized. It also retains much of the analytical ability of the previous version, allowing you to see "dead spots" in your code.

See attachments for some examples.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #12 - Posted 2006-02-14 20:14:35 »

Speaking of analytical abilities, BTW, the new version makes several things more clear:

1. There is a lot more space in Warpstar4K, and bit more space in both Xero and W4K.
2. The previously visible white area in Xero is obviously more varied than previously visible.
3. Colors are prrreeeeeettty.  Tongue Grin

I have a theory about that space at the end, though. I'm thinking that may be the ZIP file metadata about where the files are in the archive. Since it doesn't have to store much (a directory and two files), it's probably got large amounts of empty space. Just a theory, anyway. I'd need to break out a hex editor to be sure. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #13 - Posted 2006-02-14 20:39:43 »

Speaking of analytical abilities, BTW, the new version makes several things more clear:

1. There is a lot more space in Warpstar4K, and bit more space in both Xero and W4K.
2. The previously visible white area in Xero is obviously more varied than previously visible.
3. Colors are prrreeeeeettty.  Tongue Grin

I have a theory about that space at the end, though. I'm thinking that may be the ZIP file metadata about where the files are in the archive. Since it doesn't have to store much (a directory and two files), it's probably got large amounts of empty space. Just a theory, anyway. I'd need to break out a hex editor to be sure. Smiley

If that were the case, wouldn't there be similar gaps in everyones jars?
Afterall pretty much everyone has the same number of files, and file names.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #14 - Posted 2006-02-14 20:50:34 »

If that were the case, wouldn't there be similar gaps in everyones jars?
Afterall pretty much everyone has the same number of files, and file names.

That would be correct. So far, this seems to be holding true. (A few more game images are attached.)

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #15 - Posted 2006-02-14 21:13:10 »

So, who is going to write a 64x64 image -> jar file converter =)

A Visual Editor of sorts Wink
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #16 - Posted 2006-02-14 21:41:49 »

Yeah, what we need is something to go back from the image to the game..  Then we can trade bitmaps Smiley

Offline woogley
« Reply #17 - Posted 2006-02-14 21:53:22 »

that would be insanely cool! you could technically compress the games further with pngout etc Wink
Offline kaffiene
« Reply #18 - Posted 2006-02-14 22:20:03 »

That is insanely geeky.

Well done!
Offline Morre

JGO Knight


Medals: 2
Projects: 10


I'm Dragonene on IRC.


« Reply #19 - Posted 2006-02-14 22:24:54 »

This is fantastic! Awesome indeed! Cheesy
Posting Icejump4k and FreefallFour4k.

EDIT: Also, I too would love it if you could create a tool that'd reverse the process. Color wouldn't be neccessary, just b&w Smiley
Not necessarily one that works with recompressed images using visual editors, just one that could re-jar the original from-jar image.

EDIT2: I took the liberty of creating an anti-jar (going backwards?), ehm, I mean, inverted image. Also, for your pleasure... a fake!

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #20 - Posted 2006-02-14 22:42:40 »

You guys do understand that modifying the image is pointless, right? It's just a visual representation of a ZIP data stream. Any attempts to modify it would corrupt the JAR file, guaranteed.

Creating a program to reverse the process would work for the black and white images. (Not that I can figure out anything useful for it.) However, the conversion between RGB and YUV is fraught with rounding errors and would probably screw up the data.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #21 - Posted 2006-02-14 23:48:28 »

wow this is amazing now i can look at the 4k games in a totally different way  Grin

making a height map out of them would also be cool, as in 3d terrain

hint* please someone do that  Grin *hint
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #22 - Posted 2006-02-15 01:36:40 »

Creating a program to reverse the process would work for the black and white images. (Not that I can figure out anything useful for it.) However, the conversion between RGB and YUV is fraught with rounding errors and would probably screw up the data.

I don't think any colour space conversion applies in this case.  PNG is a lossless format and it typically uses RGB.

Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #23 - Posted 2006-02-15 02:10:07 »

I believe jbanes is refering to his own code for generating the colorized versions.

1  
2  
3  
4  
5  
6  
7  
int Y = ((data & 0xE0) >> 6);
            int U = ((data & 0x1C) >> 3);
            int V = (data & 0x03);

            double R = Math.abs(Y + 1.403 * V);
            double G = Math.abs(Y - 0.344 * U - 0.714 * V);
            double B = Math.abs(Y + 1.770 * U);


There is certainly rounding error in there =)
Offline Morre

JGO Knight


Medals: 2
Projects: 10


I'm Dragonene on IRC.


« Reply #24 - Posted 2006-02-15 09:20:20 »

I do know that it is pointless, and I realized it'd work better with b&w, that's why I suggested using those. I just tnink it'd be interesting to see, letting you convert to images and back (here's my java source, encrypted. Decompile this: (sending png)). :>

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #25 - Posted 2006-02-15 10:24:52 »

>and I realized it'd work better with b&w

My ARGB version is just fine. Each pixel contains 4 bytes of information and its lossless. You can also embedd some meta information in png files. So, you could write some loader which hooks such a png into the classpath and runs the main class specified in the tEXT chunk.

弾幕 ☆ @mahonnaiseblog
Offline DonaldEKnuth

Junior Duke





« Reply #26 - Posted 2006-02-15 12:35:24 »

Nice to see my entry (Sokoban4k) used for something! ;-) And this is a crazy idea! :-)

My 4k 2006 Entry: Sokoban4k
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #27 - Posted 2006-02-15 19:31:03 »

I do know that it is pointless, and I realized it'd work better with b&w, that's why I suggested using those. I just tnink it'd be interesting to see, letting you convert to images and back (here's my java source, encrypted. Decompile this: (sending png)). :>

There had better be some serious geek cred in this. Here you go:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.jar.*;
import java.util.zip.*;

import javax.imageio.*;

public class ImageRunner4K
{
    public static void main(String[] args) throws Exception
    {
        int[] buffer = new int[4096];
        byte[] array = new byte[4096];

        BufferedImage image;
        ZipInputStream jarin;
        ZipOutputStream jarout;
        ZipEntry entry;

        int data;
        int index;

        if(args.length < 1)
        {
            System.out.println("Usage: java ImageRunner4K <input>\n\nDo not pass the PNG extension.");
            return;
        }

        image = ImageIO.read(new File(args[0]+".png"));
        image.getRGB(0, 0, 64, 64, buffer, 0, 64);

        for(int i=0; i<buffer.length; i++) array[i] |= (buffer[i] & 0xFF);

        jarin = new ZipInputStream(new ByteArrayInputStream(array));
        jarout = new ZipOutputStream(new FileOutputStream(args[0]+".jar"));
   

        while(jarin.available() > 0)
        {
            index = 0;
            entry = jarin.getNextEntry();

            if(entry == null) break;

            array = new byte[(int)entry.getSize()];

            while(index < array.length) index += jarin.read(array, index, array.length-index);

            jarout.putNextEntry(new ZipEntry(entry.getName()));
            jarout.write(array, 0, array.length);
            jarout.closeEntry();
        }

        jarout.close();
        jarin.close();

        URLClassLoader loader = new URLClassLoader(new URL[]{new File(args[0]+".jar").toURL()});
        Manifest manifest = new Manifest(loader.findResource("META-INF/MANIFEST.MF").openStream());
        Attributes attributes = manifest.getMainAttributes();
        String className = attributes.getValue("Main-Class");

        Class gameClass = loader.loadClass(className);
        Method method = gameClass.getMethod("main", new Class[]{String[].class});

        method.invoke(null, new Object[]{new String[0]});
    }
}


It only works on the Grayscale images. You use it by running "java ImageRunner4K <name>" where "name" is the name of the PNG file without the extension. Don't run this in the same directory where you have your master JAR files or you may be in for a nasty surprise.

Edit: There are test files you can use in this post.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline cborders

Junior Duke





« Reply #28 - Posted 2006-02-15 20:03:29 »

I'm not worthy!  You are awesome!!
Offline Morre

JGO Knight


Medals: 2
Projects: 10


I'm Dragonene on IRC.


« Reply #29 - Posted 2006-02-15 20:34:25 »

Awesome. You have all the cred you want Cheesy

EDIT: Can't get it to work though. Crashes with:
1  
2  
Exception in thread "main" java.lang.NegativeArraySizeException
        at ImageRunner4K.main(ImageRunner4K.java:48)

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (34 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!