Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  [done!] MEG4kMAN, Mega Man in 4kb  (Read 17516 times)
0 Members and 1 Guest are viewing this topic.
Offline Markus_Persson

JGO Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Posted 2009-01-05 01: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 Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #1 - Posted 2009-01-21 22: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

Senior Member


Medals: 3
Projects: 1


Java games rock!


« Reply #2 - Posted 2009-01-21 22:26:23 »

Seriously? ... I just wrote I thought about entering. Now that I see this, - maybe not Tongue
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 284
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2009-01-21 23:24:39 »

<blasphemous exclamation>!

We're just not bloody worthy.

Cas Smiley

Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2


Make it work; make it better.


« Reply #4 - Posted 2009-01-21 23: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


Medals: 49
Projects: 5


I always win!


« Reply #5 - Posted 2009-01-21 23: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 Coder


Medals: 10


falling into the abyss of reality


« Reply #6 - Posted 2009-01-21 23:51:31 »

Never played the original or any of its variants so can't comment on the authenticity, but it looks good =>

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Matzon

JGO Knight


Medals: 19
Projects: 2


I'm gonna wring your pants!


« Reply #7 - Posted 2009-01-22 00:17:41 »

bah, completed it in like 30 seconds  Roll Eyes

seriously - very nice job!!!!

Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #8 - Posted 2009-01-22 02: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

Junior Member




...


« Reply #9 - Posted 2009-01-22 03: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SquashMonster

Senior Member


Medals: 1
Projects: 2



« Reply #10 - Posted 2009-01-22 04: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 Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #11 - Posted 2009-01-22 07: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 Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #12 - Posted 2009-01-22 08: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
« Reply #13 - Posted 2009-01-22 09: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 Knight


Medals: 11
Projects: 5
Exp: 10 years


Java games rock!


« Reply #14 - Posted 2009-01-23 00: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 Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #15 - Posted 2009-01-23 23:32:15 »

Will that work in an applet as well?

Play Minecraft!
Offline moogie

JGO Knight


Medals: 11
Projects: 5
Exp: 10 years


Java games rock!


« Reply #16 - Posted 2009-01-24 03:33:29 »

hmm... dont see why not... the class file is just another resource from the JAR.
Offline pjt33
« Reply #17 - Posted 2009-01-24 09: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

Junior Member


Projects: 2



« Reply #18 - Posted 2009-01-24 11: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 Knight


Medals: 11
Projects: 5
Exp: 10 years


Java games rock!


« Reply #19 - Posted 2009-01-24 11: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #20 - Posted 2009-01-24 13: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

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #21 - Posted 2009-01-25 11: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
Offline h3ckboy
« Reply #22 - Posted 2009-01-25 15: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 Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #23 - Posted 2009-01-28 00: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

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #24 - Posted 2009-01-28 06:10:41 »

AGGH!!! Spikes!!!

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

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #25 - Posted 2009-01-28 09:19:59 »

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

However, this is a marked achievement.

See my work:
OTC Software
Offline Markus_Persson

JGO Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #26 - Posted 2009-01-28 09: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 Knight


Medals: 10
Projects: 6


David Aaron Muhar


« Reply #27 - Posted 2009-01-28 10: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

Junior Member





« Reply #28 - Posted 2009-01-28 10: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 Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #29 - Posted 2009-01-28 11: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
  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.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!