Go Back   KLNetBB > DIỄN ĐÀN CÁC LĨNH VỰC > Kimlien Clubs > KITC - Góc Công Nghệ

 

icon10 Super Mario in 14kB Javascript,không thể đỡ được
Old 11-04-2008, 16:58  

Manager
 
Join Date: 19-09-2005
Posts: 1.650
KL$: 1.570
Awarded 170 time(s)
Sent 678 thank(s)
Received 518 thank(s)
School: PTTH Kim Liên
Class: A7 (2008-2011)
Location: Somewhere in Hell!




Here's an experiment in keeping things small and confined to one Javascript file. There are no external image files or anything, everything is rendered with Javascript using either canvas elements or old fashioned div-making tactics (for IE). The sprites are stored in custom encoded strings in a format that only allows 4 colors for each sprite but in turn only takes up around 40-60 bytes per sprite.

We also have MIDI music embedded as base64-encoded data: URI's. No music for IE, though, and it seems all the other browsers each have different, minor problems with it, but it sort of works.

It is by no means a complete clone or anything, it's not even an entire level and several key things are missing, such as mushrooms, Koopas and stuff. It was merely done as a sort of proof-of-concept and to see how small it could get.

Performance varies somewhat between the different browsers, but Firefox, Opera, Safari and IE are all playable. The latest WebKit nightly seems to give Safari a speed boost.

Be sure to click the mouse on the game if Mario won't move. When you die, you have to reload the page to start over. And yes, you can move left. Sorry.


Regular version: no music or with music

Double size: no music or with music


The script has been compressed to 14kb with the YUI compressor.
Here's the uncompressed script (35kb), if anyone is interested. The structure may look a bit weird, a lot things have been moved around to get better compression.

Edit 2: Also, those of you complaining about the faithfulness of this implementation or how it's not complete are really missing the point of this excersize.

Edit 3: Added an encoding declaration and fixed the death music.


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Đặt câu hỏi là làm cái nì zư lào ,công nhận thèng làm cũng ngộ thiệt



------------------------------
robin is offline  

Re: Super Mario in 14kB Javascript,không thể đỡ được
Old 11-04-2008, 17:41  

V.I.P
 
Join Date: 23-08-2005
Posts: 2.707
KL$: 854
Awarded 46 time(s)
Sent 489 thank(s)
Received 558 thank(s)
School: PTTH Kim Liên
Class: A7 (2005-2008)
Location: Hà Nội iu wí

Ngưỡng mộ quá!
Confirm là ko dùng ảnh thật vì trên máy nhà hiện rất rõ và đẹp!



------------------------------
Click here: Show ảnh người yêu của mọi người (Câu thank )
MrPaint is offline  

Re: Super Mario in 14kB Javascript,không thể đỡ được
Old 11-04-2008, 18:01  

Manager
 
Join Date: 19-09-2005
Posts: 1.650
KL$: 1.570
Awarded 170 time(s)
Sent 678 thank(s)
Received 518 thank(s)
School: PTTH Kim Liên
Class: A7 (2008-2011)
Location: Somewhere in Hell!

Quote:
Originally Posted by MrPaint View Post
Ngưỡng mộ quá!
Confirm là ko dùng ảnh thật vì trên máy nhà hiện rất rõ và đẹp!
Ngại up lên host lém ,hết band cúa host roài



------------------------------
robin is offline  
 

KLNetBB - Member of Kimlien Network
Copyright © 2002-2009 by dcuongtran
Skin designed by Kusanagi - Banner designed by FunkyJan
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.