A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: [Disc] 1kb Games

  1. #1
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581

    [Disc] 1kb Games

    1kb Blackjack
    1KB Tetris
    1KB Pong
    1KB Snake

    I've been working on a 1kb Space Invaders game. Its 1060 bytes now, and the enemies can't fire. It has multiple levels of increasing difficulty though.

    Anyways:
    Code:
    //Basic shapes and positions
    a = [[-20, 5, 20, 5, 0, -5, 160, 220], [0, 10, 0, 0, 1, -25], [-8, -8, 8, -8, 0, 0, 310, -20], [-5, -5, 5, -5, 5, 5, -5, 5, 40, 180]];
    c = _root;
    //Enemy x position
    x = 1;
    //s=Score
    //k=Init count
    //n=Timer
    //y=Enemy y Position
    //d=Timer Starting Value
    s = k=n=y=d=0;
    createTextField("st", -1, 200, 220, 120, 20);
    //Enemy Speed
    e = 5;
    _root.lineTo(320, 0);
    _root.onEnterFrame = function() {
    	//New Level
    	if (k<78) {
    		//Draw Prototypes
    		//for (k=0; k<78; k++) {
    		if (k<4) {
    			//b = a[j].split(",");
    			b = a[k];
    			t = c.createEmptyMovieClip("h"+k, k);
    			t.lineStyle(0, 0x000);
    			l = b.length-2;
    			t.moveTo(b[l-2], b[l-1]);
    			for (i=0; i<l; i += 2) {
    				t.lineTo(b[i], b[i+1]);
    			}
    			t._x = b[l];
    			t._y = b[l+1];
    		} else if (k<27) {
    			//Walls
    			//for (k=4; k<27; k++) {
    			t = h3.duplicateMovieClip("h"+k, k);
    			t._x = (k+1)*10;
    			if ((k-1)%5 == 0) {
    				k++;
    			}
    			//}         
    		} else {
    			//Enemies
    			//for (k=27, m=1; k<77; k++, m++) {
    			t = h2.duplicateMovieClip("h"+k, k);
    			t._x = x*25+25;
    			t._y = 20+y*15;
    			//ens[m-2][m] = t;
    			if (x>=10) {
    				y++;
    				//ens[j] = new Array();
    				x = 0;
    			}
    			x++;
    		}
    		//}
    		k++;
    		return;
    	}
    	//Move Hero                     
    	h0._x -= 5*(Key.isDown(37)-Key.isDown(39))*(h0._x-Key.isDown(37)*5>25 && h0._x+Key.isDown(39)*5<295);
    	//Fire
    	if (Key.isDown(32)) {
    		if (h1._y<-20) {
    			h1._x = h0._x;
    			h1._y = 200;
    		}
    	}
    	//Bullet Check                                 
    	e *= z ? -1 : 1;
    	if (h1._y>-25) {
    		h1._y -= 5;
    	}
    	for (i=3; i<78; i++) {
    		t = c["h"+i];
    		if (i>27) {
    			if (z) {
    				t._x += n>30 ? e : 0;
    				t._y += 5;
    			}
    			if (t._y>200) {
    				_root.onEnterFrame = null;
    				_root.st = "Game Over";
    			}
    		}
    		if (t.hitTest(h1)) {
    			if (i>27) {
    				//Hit enemy
    				t.removeMovieClip();
    				s++;
    			} else {
    				//Hit Wall
    				t._xscale = t._yscale -= 25;
    				if (t._xscale == 0) {
    					t.removeMovieClip();
    				}
    			}
    			h1._y = -25;
    		}
    	}
    	//End level
    	if (s%50 == 0) {
    		if (s>0) {
    			s += 50;
    			d += 4;
    			k = 0;
    		}
    	}
    	z = false;
    	if (n>30) {
    		//Change direction     
    		z = _root._width>321;
    		d += 2*z;
    		n = d;
    	}
    	n++;
    	st.text = "Score: "+s;
    };

  2. #2
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,361
    It is missing a preloader.

  3. #3
    Flash / Php game designer
    Join Date
    Mar 2005
    Location
    UK
    Posts
    253
    Hardcore, i'll see if i can make something similar :-)

    Btw, lol@UnknownGuy

  4. #4
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    ok, found out that defining many variables at the same time is not a good idea:
    1055bytes
    Code:
    //Enemy x position
    x = 1;
    //s=Score
    //k=Init count
    //n=Timer
    //y=Enemy y Position
    //d=Timer Starting Value
    s = 0;
    k = 0;
    n = 0;
    y = 0;
    d = 0;

  5. #5
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Maybe your comments are adding to the size

  6. #6
    Senior Member walnoot's Avatar
    Join Date
    Apr 2005
    Posts
    751
    comments aren't compiled, I think.

    cool experiment!

  7. #7
    Flash / Php game designer
    Join Date
    Mar 2005
    Location
    UK
    Posts
    253
    x = 1,s = 0,k = 0,n = 0,y = 0,d = 0;

    is this not better?

  8. #8
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Quote Originally Posted by Aldarn
    x = 1,s = 0,k = 0,n = 0,y = 0,d = 0;

    is this not better?
    Even shorter is:

    x = 1, s = k = n = y = d = 0;

    (though I doubt it compiles to be smaller)

  9. #9
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i imagine using characters (say from the symbol) character set instead of drawing the shapes may make it smaller
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  10. #10
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    Quote Originally Posted by Ray Beez
    Even shorter is:

    x = 1, s = k = n = y = d = 0;

    (though I doubt it compiles to be smaller)
    The weird thing is, its not. I got 5 bytes off by splitting it into seperate lines. If's are the same, a new if is much better than an &&.
    i imagine using characters (say from the symbol) character set instead of drawing the shapes may make it smaller
    Tested that too, and no, its not. Its slightly heavier than the coding.

  11. #11
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    You don't need any of the _root's in the script. Get rid of the c variable and all the _root stuff, and change c["h"+i]; to _root["h"+i];
    http://www.birchlabs.co.uk/
    You know you want to.

  12. #12
    Senior Member X-Tender's Avatar
    Join Date
    Jun 2003
    Location
    Germany
    Posts
    507
    Funny, i'am working currently on a 1kb Asteroids ..

  13. #13
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    I'm working on a 1kb doom

  14. #14
    Senior Member zervell's Avatar
    Join Date
    May 2004
    Posts
    259
    Quote Originally Posted by UnknownGuy
    It is missing a preloader.
    I want to know how slow does your isp have to be to need a preloader on a 1kb file? chuckle chuckle
    CEO OF

  15. #15
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    Strille, where are you?

  16. #16
    Senior Member walnoot's Avatar
    Join Date
    Apr 2005
    Posts
    751
    Quote Originally Posted by lesli_felix
    I'm working on a 1kb doom
    Everbody has seen this I assume?

  17. #17
    CostomJunky Xploder's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    635
    After this post I started work on a 1kb fully dynamic IK Snakes game reduced form an original 1.5 kb size, now down to 815bytes <- snake generation and movement only though. Nice work on space invaders. One of the few things I've found is removeMovieClip(m); is better than m.removeMovieClip(); and if you get rid of _root. in some places. That and maybe some type casting will get it down to under 1kb.
    Last edited by Xploder; 12-10-2006 at 08:37 PM.

  18. #18
    CostomJunky Xploder's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    635
    Here's the 1kb IK Snakes game http://www.devkiwi.com/project/1kbik...biksnakes.html I've been working on. Currently its 1100bytes

  19. #19
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    seems like you need to aim very precicely in order to eat & grow- missed it many times beacuse I thought it would go fine

    btw. that snake looks like a condom to me :|

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center