Is using only the standard libraries okay?
Here's mine. The code fits in the window allowed, but that's because it's actually designed to be <1k, which it is sans the comments. However game relies on running in a 80x24 console to format the output as it scrolls to clear the screen. It's a game that most people know as "Doctor Who", but I call Robot Escape. An expanded version that is a little less restrictive (and includes borders) was one of the first games I chose to
feature on my site. But when I write that version I thought of the
IOCCC and some cool entries I saw there, so I decided to give this a go.
(From the
notes I typed up a while back) RobotEscape1k is played using the number key pad (be sure num-lock is on). 8 is up, 2 is down, 4 and 6 are left and right respectively, and 7, 9, 1, and 3 are diagonals. Use 5 to stand still for a turn. If you are in a safe spot and want to just wait to the end of the level use the period (.) key. 0 activates your teleport-a-matic but remember that it might teleport you into your enemies. Use it with caution.
#define q(a)(a)*(a) /* RobotEscape in 1K by Joe Larson*/
#define f(u,v) if((p[n]->l u 79)v(l->l u 79))p[n]->l /* www.cymonsgames.com */
typedef struct{int l,t;}z;z*p[99];int y;k(){int a=0,b,c=0,d=0;z*e;for(;a<=y;a++
){for(b=y;a<y&&b>a;b--)if(p[b]->l<p[b-1]->l){e=p[b];p[b]=p[b-1];p[b-1]=e;}if(a)
{if(p[a]->l==p[a-1]->l)p[a]->t=p[a-1]->t=3;else do{if(!(c%79))puts("");putchar(
" O+#"[(p[a-1]->l==c)?p[a-1]->t:0]);}while(++c<p[a]->l&&c<=1817);d+=(p[a-1]->t
==2);}}return d;}main(){int n=0,m,w,e=0,d[9],i;z*l;srand(time(0));for(;n<99;n++
){if(n<9)d[n]=79*(1-n/3)+(n%3-1);p[n]=malloc(sizeof(z));p[n]->l=1976;}do{y=m=7+
++e*4;n=rand()%m;w=1817;while(m-->0){p[m]->l=w-=rand()%(w/(m+1))+1;p[m]->t=(n!=
m)+1;}l=p[n];printf("\nLevel %d",e);m=k();do{if(m){do i=getche ();while(iscntrl
(i));if(i=='.')m=0;else if(!(i-'0'))l->l=rand()%1817;else if(i>'0'&&i<='9'){n=l
->l + d[i-'1'];if(q((n%79)-(l->l%79))<2&&n<1817&&n>=0)l->l=n;}}for(n=0;n<y;n++)
if(p[n]->t==2){f(%,>)-=1;else f(%,<)+=1;f(/,>)-=79;else f(/,<)+=79;}w=k();}
while(w&&l->t==1);}while(!w);if(w)printf("Ended on %d\n",e);}
Code monkeys may be amused to discover that this uses a modified bubble sort to handle collision detection and screen drawing. Since the bubble sort insures that you can, as you're sorting, keep the next one on top, after each loop through the sort I can take a second to do the housekeeping and output.
Executable Here.
And since I'm only using the standard library I'll spruce up your expectations with an illustration: