home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Action 54
/
cdactioncoverdisc54.iso
/
Bonus
/
c.exe
/
CAut
/
caut.cpp
next >
Wrap
C/C++ Source or Header
|
2000-09-07
|
1KB
|
71 lines
# include <stdio.h>
# include <allegro.h>
# include <math.h>
int x = 320, y = 200;
int azymut = 1; // 0 = N , 1 = NE, 2 = E, 3 = SE
// 4 = S , 5 = SW, 6 = W, 7 = NW
int ta[256][8]; // tablica azymutow
BITMAP* bufor_e;
void cInit()
{
int i,j;
for (i=0; i<256; i++)
for (j=0; j<8; j++)
ta[i][j]=rand()%8;
// ta[i][j]=(255*(int)sqrt(i+j))%8;
}
void cAut()
{
int i, r, nr;
char buf[80];
clear(bufor_e);
r=0;
while (!kbhit())
{
switch(azymut) {
case 0 : y-=1;break;
case 4 : y-=1;x+=1;break;
case 1 : x+=1;break;
case 5 : x+=1;y+=1;break;
case 2 : y+=1;break;
case 6 : y+=1;x-=1;break;
case 3 : x-=1;break;
case 7 : x-=1;y-=1;break;
}
if (x<0) x=639;
if (x>639) x=0;
if (y<0) y=479;
if (y>479) y=0;
r=getr32( ((int *)bufor_e->line[y])[x] );
azymut = ta[r][azymut];
((int *)bufor_e->line[y])[x] = makecol32(r+1, r+1, r+1);
blit(bufor_e, screen, x, y, x, y, 1, 1);
}
}
int main()
{
allegro_init();
set_color_depth(32);
bufor_e = create_bitmap(640, 480);
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
cInit();
cAut();
destroy_bitmap(bufor_e);
text_mode(0);
}