Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 7373 times)
0 Members and 1 Guest are viewing this topic.
Offline jbanes

JGO Coder


Projects: 1


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


« Reply #30 - Posted 2006-02-16 01:41:50 »

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)

Can you attach the image you're using to a post? (Click on "Additional Options" below the text area to find the upload options.)

Edit: Never mind. I've reproduced it with IceJump4K. It looks like the size data is being stored improperly. I'll try to find a workaround.

Edit 2: Okay, good news/bad news. I can work around the problem with the ZIP format, but you didn't mark your class file as public.(Why not?)  I'm going to have to muck with the security manager to see if I can forcably grant access.

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

JGO Coder


Projects: 1


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


« Reply #31 - Posted 2006-02-16 04:45:45 »

I'm still working on the security issue (my memory is a bit rusty on working with Policies), but in the meantime, here's a version that handles badly formed ZIP files:

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  
71  
72  
73  
74  
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"));
        entry = jarin.getNextEntry();

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

            if(entry == null) break;

            jarout.putNextEntry(new ZipEntry(entry.getName()));

            while((data = jarin.read()) >= 0)
            {
                jarout.write(data);
                index++;
            }

            jarout.closeEntry();

            entry = jarin.getNextEntry();
        }

        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.setAccessible(true);
        method.invoke(null, new Object[]{new String[0]});
    }
}

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

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #32 - Posted 2006-02-16 07:47:38 »

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

How about a 3D 4k game that uses it's own jar as a heightmap.  Naw, it's just too silly.

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Markus_Persson

JGO Wizard


Medals: 15
Projects: 19


Mojang Specifications


« Reply #33 - Posted 2006-02-16 09:06:15 »

hahaha


That IS pretty silly. Grin

Play Minecraft!
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #34 - Posted 2006-02-16 13:26:07 »

lol thats a nice idea Smiley
Offline jbanes

JGO Coder


Projects: 1


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


« Reply #35 - Posted 2006-02-16 18:09:01 »

Ok, the security issue is fixed. I've patched the code in my post above (added "method.setAccessible(true);") and that grants access to the otherwise protected class.

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

Senior Member




Go Go Gadget Arms


« Reply #36 - Posted 2006-02-17 02:53:37 »

Quote
How about a 3D 4k game that uses it's own jar as a heightmap.  Naw, it's just too silly.

Youd have to code for heightmap beutification, as well as the 4k limit, as well as performance, as well as multiplatform! Craaazy!

* darkprophet goes off to try!

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!