[ create a new paste ] login | about

Link: http://codepad.org/kfYsZLj9    [ raw code | fork ]

C, pasted on Jun 1:
#include "blike.h"

static void control(int* d)
{
	static int move_d = 0;
	int a = 0;

	while(1) {
		int tmp = bl_inkey(BL_GETKEY);
		
		if(tmp == 4095) {
			a = 4095;
			bl_inkey(BL_CLEARREP);

			break;
		}

		if(tmp == 0) {
			break;
		}
		else {
			a = tmp;
		}
	}

	switch(a) {
	case 333:	case 6:		move_d = +2;	break;
	case 331:	case 4:		move_d = -2;	break;
	case 4095:			move_d = 0;	break;
	}
     
	*d += move_d;

	if(*d < 1) {
		*d = 1;
	}
	
	if(*d > 73) {
		*d = 73;
	} 
}

blMain()
{
	int b, c, bb, cc, d;
	cls();
	b = 39; c = 11;
	bb = 1; cc = -1;
	d = 37;
	for (;;) {
		locate(b, c ); printf("O");
		locate(d, 23); printf("#####");
		if (c == 23) { break; }
		wait(100);
		locate(b, c ); printf(" ");
		locate(d, 23); printf("     ");
		if (b ==  0) { bb =  1; }
		if (b == 78) { bb = -1; }
		if (c ==  0) { cc =  1; }
		if (c == 22) {
		if (d - 1 <= b && b <= d + 5) { cc = -1; }
		}
		b += bb; c += cc;

		control(&d);	
	}
		wait(-1);
}


Create a new paste based on this one


Comments: