Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

After spending an hour cloning your game to see if was able to make it under 1k, I ended up with a .jar file of about 3.5kb, with a bit more of compression I think I can make it 3kb. Then I realized I could actually download your code. I only have one thing to say, what the hell dude? Are you the God of Compression? 

(1 edit) (+1)

Here is the code BTW,


import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.JFrame;
public class A extends Canvas implements Runnable {
byte[]bb={1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1};byte[]sh={1,0,0,0,1,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,1,0,0,0,1};byte[]as={1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0};byte[]fo={1,1,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,1,1,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,1,1,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,0,1,1,1,1,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,1,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,0,1};
Random r=new Random();JFrame f;float x,bx=-5,by;BufferedImage bi;int[]p;int m=64,l=m*m,s,bs,ti=3;List aa=new ArrayList();int[]k=new int[3];boolean t=true,z=false;public static void main(String args[]){new A();}A() {x=32-5/2;f=new JFrame("Space");this.setFocusable(true);this.requestFocus();f.setDefaultCloseOperation(3);f.setSize(512,512);f.setLocationRelativeTo(null);f.setResizable(z);bi=new BufferedImage(m,m,1);p=((DataBufferInt)bi.getRaster().getDataBuffer()).getData();this.addKeyListener(new KeyListener(){public void keyTyped(KeyEvent e){}public void keyReleased(KeyEvent e){if(e.getKeyCode()==39)k[0]=0;if(e.getKeyCode()==37)k[1]=0;if(e.getKeyCode()==32)k[2]=0;} public void keyPressed(KeyEvent e){if(e.getKeyCode()==39)k[0]=1;if(e.getKeyCode()==37)k[1]=1;if(e.getKeyCode()==32)k[2]=1;}});f.add(this);f.setVisible(t);new Thread(this).start();}
void u(){ti-=1;if(ti<0){ti=3;aa.add(new B());}if(k[0]==1){x+=.25f*5;if(x+5>=m)x=m-5;}if(k[1]==1){x-=.25f*5;if(x<0)x=0;}if(k[2]==1&&(by+5<-15)){bx=x;by=m-10-5;}by-=.25*8;for(int i=0;i<aa.size();i++){B e=(B)aa.get(i);e.y+=.25f*8*1.14191564f;if(e.y>=64){s++;e.d=t;}else if(c(x,m-10,e.x,e.y))l();else if(c(bx,by,e.x,e.y)&&bx>-5){s++;bx=-5;e.d=t;}}for(int i=0;i<l;i++)p[i]=0;for(int i=0;i<aa.size();i++){if(((B)aa.get(i)).d)aa.remove(i);}for(int i=0;i<aa.size();i++){B e=(B)aa.get(i);ds((int)e.x,(int)e.y,as);}ds((int)x,m-10,sh); ds((int)bx,(int)by,bb);String ss=vs(s);for(int i=0;i<ss.length();i++)df(i*5,0,vi(ss.charAt(i)));ss=vs(bs);for(int i=0;i<ss.length();i++)df(32+i*5,0,vi(ss.charAt(i)));}
void l(){if(s>bs)bs=s;s=0;aa.clear();bx=-5;x=32-5/2;}
String vs(int a){return String.valueOf(a);}
int vi(char a){return Integer.parseInt(String.valueOf(a));}
boolean c(float a,float b,float c, float d){if(a+5>=c&&a<=c+5&&b+5>=d&&b<=d+5)return t;return z;}
void ds(int x,int y,byte[] d){for(int j=0;j<5;j++){if(j+y<0||j+y>=m)continue;for(int i=0;i<5;i++){if(i+x<0||i+x>=m)continue;p[(i+x)+(j+y)*m]=d[i+j*5]*0xFFFFFF;}}}
void df(int x,int y,int in){for(int j=0;j<5;j++){if(j+y<0||j+y>=m)continue;for(int i=0;i<4;i++){if(i+x<0||i+x>=m)continue;p[(i+x)+(j+y)*m]=fo[i+j*4+20*in]*0xFFFFFF;}}}
void d(){BufferStrategy bs=getBufferStrategy();if(bs==null){createBufferStrategy(3);return;}Graphics g=bs.getDrawGraphics();u();g.drawImage(bi,0,0,getWidth(),getHeight(),null);g.dispose();bs.show();}
public void run(){long n=System.nanoTime();double f=1000000000.0/30.0;double d=0;while(t){long a=System.nanoTime();d+=(a-n)/f;n=a;if(d>=1){d-=1;d();}try{Thread.sleep(2);}catch(InterruptedException e){}}}
class B{float x,y;boolean d;B(){x=r.nextInt(12)*5+1;y=-5;}}}

(+1)

Happy people are downloading it and attempting the same in other languages! In Java it's a bit more difficult... But you can make code really short when you compress it by hand!

(2 edits)

It's really hard to do what you did in java. Just the code for the window and keyboard input will probably consume about 512bytes. I remember there was a contest before, called java4k, although it's pretty much dead now, I tried to get some source codes of the games they used to create for that contest and I found 1 guy from who I learnt about "pack200". So using proguard + pack200 I managed to make 1.99 KB.

What is interesting is that Notch (creator of minecraft) managed to do Meg4kman in under 4KB. I don't know how he did it considering that it has enemies and 25 levels, it's pretty much a bigger project than this one. It's amazing!