|
-
Senior Member
[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;
};
-
Senior Member
It is missing a preloader.
-
Flash / Php game designer
Hardcore, i'll see if i can make something similar :-)
Btw, lol@UnknownGuy
-
Senior Member
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;
-
Senior Member
Maybe your comments are adding to the size
-
Senior Member
comments aren't compiled, I think.
cool experiment!
-
Flash / Php game designer
x = 1,s = 0,k = 0,n = 0,y = 0,d = 0;
is this not better?
-
Senior Member
 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)
-
ism
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
-
Senior Member
 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.
-
Script kiddie
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];
-
Senior Member
Funny, i'am working currently on a 1kb Asteroids ..
-
....he's amazing!!!
I'm working on a 1kb doom
-
Senior Member
 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
-
DOT-INVADER
Strille, where are you?
-
Senior Member
 Originally Posted by lesli_felix
I'm working on a 1kb doom 
Everbody has seen this I assume?
-
CostomJunky
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.
-
CostomJunky
Here's the 1kb IK Snakes game http://www.devkiwi.com/project/1kbik...biksnakes.html I've been working on. Currently its 1100bytes
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|