Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  Print  
  [done!] MEG4kMAN, Mega Man in 4kb  (Read 11166 times)
0 Members and 3 Guests are viewing this topic.
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« on: 2009-01-04 19:40:35 »

Tomorrow I go to cuba for two weeks. I'm bringing my brand new Eee 901 to possibly get some coding done on the flight.. and I'm working on this:

MEG4kMAN, an extremely tiny version of Mega Man.
It's 1612 bytes so far, and that includes a spectrum graphics like renderer with a single 8x8 1 bit bitmap per tile, with a 5 bit color (r, g, b, intensity, x flip) per tile.

Here's the raw sheet before processing:

Play Minecraft!
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #1 on: 2009-01-21 16:21:46 »

Updated, and almost playable!



Just needs some health pickups, a death/game over animation and some more screens. Cheesy

Play Minecraft!
Offline Addictman

Full Member
**

Posts: 204
Medals: 5


Java games rock!


« Reply #2 on: 2009-01-21 16:26:23 »

Seriously? ... I just wrote I thought about entering. Now that I see this, - maybe not Tongue
Games published by our own members! Go get 'em!
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #3 on: 2009-01-21 17:24:39 »

<blasphemous exclamation>!

We're just not bloody worthy.

Cas Smiley

Offline CaptainJester

JGO Neuromancer
****

Posts: 1138
Medals: 8


Make it work; make it better.


« Reply #4 on: 2009-01-21 17:35:29 »

On the first screen if you die while holding the jump key you end up jumping through the top of the screen when you spawn.  Here's the exception.
1  
2  
3  
4  
Exception in thread "Thread-10" java.lang.StringIndexOutOfBoundsException: String index out of range: -300
   at java.lang.String.charAt(Unknown Source)
   at S.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Offline appel

JGO Wizard
****

Posts: 1477
Medals: 23


I always win!


« Reply #5 on: 2009-01-21 17:45:40 »

I got the same error.

1  
2  
3  
4  
Exception in thread "Thread-10" java.lang.StringIndexOutOfBoundsException: String index out of range: -300
   at java.lang.String.charAt(Unknown Source)
   at S.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


What is this, can't you make proper games?  Wink ... joking

Wow.... just wow.... hm... and WOW!

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline Abuse

JGO Kernel
*****

Posts: 1866
Medals: 5


falling into the abyss of reality


« Reply #6 on: 2009-01-21 17:51:31 »

Never played the original or any of its variants so can't comment on the authenticity, but it looks good =>
Offline Matzon
« League of Dukes »

JGO Kernel
*****

Posts: 1805
Medals: 8


I'm gonna wring your pants!


« Reply #7 on: 2009-01-21 18:17:41 »

bah, completed it in like 30 seconds  Roll Eyes

seriously - very nice job!!!!

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
Offline rdcarvallo

Sr. Member
**

Posts: 300


2D Java games forever!


« Reply #8 on: 2009-01-21 20:34:28 »

Awesome!!!

As a rockman fan I am impressed, you even added 4 different enemies with the right logic.

I'll wait for the final version.
Offline Renoria

Full Member
**

Posts: 209


...


« Reply #9 on: 2009-01-21 21:27:23 »


Exception in thread "Thread-7" java.lang.StringIndexOutOfBoundsException: String index out of range: -300
   at java.lang.String.charAt(Unknown Source)
   at S.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Games published by our own members! Go get 'em!
Offline SquashMonster

Jr. Member
**

Posts: 67
Medals: 1



« Reply #10 on: 2009-01-21 22:48:53 »

Very impressive, but short.  How much space does a screen take you?  If it's a lot you could use some procedural levels to cut size and make it a lot longer.

If you're interested in trying that, the obvious algorithm is to just make a row of platforms at random heights, with none raising higher than the character can jump.  This can be done in a really simple loop (for x, if x > width: width+=random, for y, if y > height: fill) so it should be pretty small.  Put an enemy every few platforms and whatnot.  But that's the most boring algorithm you could use, as well.

I feel that your most interesting screens are the 2nd and 3rd ones.  There's an old roguelike algorithm that you should be able to modify to come up with something like these.  In it, you divide the screen randomly, adding a door between the halves, then divide the halves each randomly, adding a door, and so forth.  I'm not sure how you'd modify this to be non-recursive, mind you, so fitting it in the space could be tough.

Either way, this is a very impressive game.  Great job!
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #11 on: 2009-01-22 01:55:59 »

Right now, the game is at just over 3kb, and each screen I add is another 300 bytes of raw data that seems to compress down to about 30 bytes per screen. With some additional trickery, I should be able to get the levels down to about 90 raw bytes per screen, but I'm not sure that would compress any better.
I figure I can get about 30 screens of hard coded levels in there. I'm shooting for a Mega Man 9 type experience where the game is bloody hard but speed run friendly.

Since I'm going pretty much the opposite direction of my normal design here (no procedural content, and making a demake of an existing game), I'm tempted not to do any randomly generated levels in this one. =D


Highest priority right now is adding a satisfying death animation in as few bytes as possible. Any ideas?

Play Minecraft!
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #12 on: 2009-01-22 02:03:00 »

Some more details:

The graphics are 1 bit per pixel graphics, made up of 8x8 pixel blocks that each have a color (0-15, think EGA) and a x flip bit. Each 8x8 pixel chunk of graphics takes up 8 bytes of raw data, and the sprite sheet is 9x7 tiles, for a total of 504 bytes of raw data (not counting extra bytes used in UTF-8 encoding).

Whenever you leave a screen to the right or down, you move to the next screen, whenever you leave up or left, you move to the previous. That's why it crashes when you jump after dying (I need to remember to set onGround to false), it tries to change to screen -1.

Each tile in a level contains 2x2 tiles of graphics, and the mega man character is usually 3x4 tiles of graphics (more when jumping or hurt).

Play Minecraft!
Offline pjt33

JGO Strike Force
***

Posts: 913
Medals: 17



« Reply #13 on: 2009-01-22 03:47:00 »

Right now, the game is at just over 3kb, and each screen I add is another 300 bytes of raw data that seems to compress down to about 30 bytes per screen. With some additional trickery, I should be able to get the levels down to about 90 raw bytes per screen, but I'm not sure that would compress any better.
I figure I can get about 30 screens of hard coded levels in there. I'm shooting for a Mega Man 9 type experience where the game is bloody hard but speed run friendly.

Since I'm going pretty much the opposite direction of my normal design here (no procedural content, and making a demake of an existing game), I'm tempted not to do any randomly generated levels in this one. =D


Highest priority right now is adding a satisfying death animation in as few bytes as possible. Any ideas?
Shift (on Kongregate, in the Puzzles section) has a death animation which wouldn't take many bytes, but it doesn't really fit your graphical style.
Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #14 on: 2009-01-22 18:34:09 »

Quote
(not counting extra bytes used in UTF-8 encoding).

perhaps you would make a decent space saving by directly embedding the byte data into the class file as an Attribute post proguard/etc optimisation?

It had saved me a significant amount of space with my 2007 entry SubPar.

you can use the undocumented "-addData <file>" of the 4KJO tool's command line options to insert the data file into the class file. Have a look at the source of my entry as to how i read in the embedded data. (My data did have a unique magic number sequence at the beginning of two bytes equal to "||".

Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #15 on: 2009-01-23 17:32:15 »

Will that work in an applet as well?

Play Minecraft!
Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #16 on: 2009-01-23 21:33:29 »

hmm... dont see why not... the class file is just another resource from the JAR.
Offline pjt33

JGO Strike Force
***

Posts: 913
Medals: 17



« Reply #17 on: 2009-01-24 03:18:34 »

Mookie, did you compare doing it that way with just having the file as a separate entry in the .jar? I find it slightly surprising that the extra bytes required to put "a.class" in the constant pool (vs using "a", which is already in the constant pool), skip past everything you don't want, and label the attribute don't more than cancel out the extra bytes required for a second zip entry.
Offline timfoden

Jr. Member
**

Posts: 95



« Reply #18 on: 2009-01-24 05:22:22 »

I found in my Kart game that it took up less space to insert the data in a string than to inject it.

My data though was a delta encoded bitmap, with the deltas starting from 1 (not 0) so that the string encoding was as efficient as the data injection.

The major space saving was in not having to scan through the class file to extract the data.

Try Pipe Extreme -- can you get to the end of the pipe?
Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #19 on: 2009-01-24 05:46:40 »

Mookie, did you compare doing it that way with just having the file as a separate entry in the .jar? I find it slightly surprising that the extra bytes required to put "a.class" in the constant pool (vs using "a", which is already in the constant pool), skip past everything you don't want, and label the attribute don't more than cancel out the extra bytes required for a second zip entry.

For my game i compared it against a separate entry in the JAR and against encoding the data in a string.

It saved about 80 bytes if i recall correctly when compared against a separate entry.

Of course may not give benefit with different circumstances. Smiley

Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #20 on: 2009-01-24 07:45:23 »

Cool game, feels a bit wierd to control though. Amazing amount of graphics though!

Had one of these randomly:

1  
2  
3  
4  
Exception in thread "Thread-6" java.lang.StringIndexOutOfBoundsException: String index out of range: -300
   at java.lang.String.charAt(Unknown Source)
   at S.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


Kev

Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3573
Medals: 44


Game Engineer


« Reply #21 on: 2009-01-25 05:05:13 »

Worked fine here. I also beat it in about 30 seconds, but I understand it's not done yet.

PS - you're too good at the 4k game thing.

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Offline h3ckboy

JGO Kernel
*****

Posts: 1645
Medals: 4



« Reply #22 on: 2009-01-25 09:04:53 »

I liked it a lot. one thing i dont get is how the heck did you make it only 3kb I have an asteroid field game that is a lot simpler and it is over 12! only reason I didnt beat it in 30 seconds was cause of the whole jumpingwhen you die thing. and there are a lot of spikes Smiley
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #23 on: 2009-01-27 18:27:54 »

And it's done! =D

25 screens of mega man goodness, and it displays your completion time when you beat it! Woop!

Play Minecraft!
Offline rdcarvallo

Sr. Member
**

Posts: 300


2D Java games forever!


« Reply #24 on: 2009-01-28 00:10:41 »

AGGH!!! Spikes!!!

Got to the spiked fall.. tomorrow 'll try again.

Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3573
Medals: 44


Game Engineer


« Reply #25 on: 2009-01-28 03:19:59 »

Too hard for me, it was just making me angry.

However, this is a marked achievement.

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #26 on: 2009-01-28 03:36:23 »

Hehe, yeah, it's freakishly hard.

It's also designed to be speedrunnable, we'll see if it ever gets popular enough for someone to post a speed run on youtube.

Play Minecraft!
Offline bobjob

JGO Ninja
***

Posts: 646
Medals: 14


David Aaron Muhar


« Reply #27 on: 2009-01-28 04:32:52 »

Hehe, yeah, it's freakishly hard.

It's also designed to be speedrunnable, we'll see if it ever gets popular enough for someone to post a speed run on youtube.

yeah, I was thinking the same thing. Would be really cool if there was a timer printed in the corner, or after you die.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline irreversible_kev

Full Member
**

Posts: 174



« Reply #28 on: 2009-01-28 04:49:29 »

WIN!
01 03 (That wont be a good time at all, I had many many restarts)

Some screens I just had to brute force it and loose HP just to get to the next screen.
Like on the last screen, I don't see how you can't loose at least 3HP.

Really awesome game!
Offline Markus_Persson

JGO Kernel
*****

Posts: 2092
Medals: 10


Mojang Specifications


« Reply #29 on: 2009-01-28 05:34:56 »

Nice time! My best is about 1:20.

For the last two screens, i usually run through the second last screen, taking about four hits worth of damage, then shoot my way through the last screen.
The other way around might be faster, though..

Play Minecraft!
Pages: [1] 2
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.18 seconds with 21 queries.