home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 Mobile
/
Chip_Mobile_2001.iso
/
palm
/
spiele
/
teslabal
/
teslabal.exe
/
TeBaSource.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-22
|
4KB
|
188 lines
// TeslaBalls
// Version 1.0
int ix,iy; // Impulse
near(int a, int b, int a1, int b1)
{
int ret,r;
// return 1;
// r=10;
r=13; // para s=10
r=16; // para s=16
if(a>a1-r && a<a1+r && b>b1-r && b<b1+r) ret=1; else ret=0;
return ret;
}
evento(int f)
{ int ev; ev=event(f);
text(150,150,ev); return ev;
}
pause(int s)
{
int t;
t=ticks();
while(t+s<ticks());
}
//delta(int ev)
delta()
{ int tx,ty,c,e; c=8;
tx = penx();
ty = peny();
// beep(1);
e=0;
// while(e!=3 && e!=4) {e=event(0); }
while(e!=3 && e!=4 && c!=0)
{e=event(0); c--; }
ix=penx()-tx; iy=peny()-ty;
// text(0,150,"["+ix+"|"+iy+"]");
}
main()
{
float x,y,xd,yd,ox,oy,r;
float bx,by,obx,oby,bxd,byd;
float rx,ry;
string b1,b2;
int s,e,sco,tim,top;
int lo,olo;
b1 = "0a1e03f06f8dfcffcffcffc7f83f01e0" ; s=10;
//b2="0a1e03f07f8ffcffcffcfec7d83f01e0";
b2="0a1e03f0618cccdecdecccc6183f01e0";
s=16;
b1="1003c00ff01ff839fc73fe77feffffffffffffffff7ffe7ffe3ffc1ff80ff003c0";
b2="1003c00ff03ffc3ffc7ffe7dbef99ffffffffff99f7dbe7ffe3ffc3ffc0ff003c0";
b2="10c18382410000000003c007e04ff28ff18ff14ff207e003c0000000008241c183";
b2="0a1e03f06f8dfcffcffcffc7f83f01e0";
b1="0c0f03fc67e6fedfffffffffff7fe7fc3fc0f0"; s=12;
if(dbopen("TeslaBallsS")==0)
{ dbcreate("TeslaBallsS"); top=0; dbwrite(0); } else top=dbread('i');
dbclose();
graph_on(); rect(0,0,0,160,160,0);
frame(1,2,2,158,158,0);
text(80,144,"by Carlos Baquero");
textattr(2,1,0);
text(54,10,"TeslaBalls");
text(50,50,"Top: "+(top));
bitmap(63,100,b1);
bitmap(83,105,b2);
sleep(2000);
while(event(0)!=0); waitp();
//while(bstate()==0);
while(1) {
x=ox=2; y=oy=30; xd=3; yd=3;
bx=obx=10; by=oby=80; bxd=0.5; byd=2.5;
r=5;sco=20; tim=0;
rect(0,0,0,160,160,0);
textattr(1,2,0);
line(1,0,13,159,13);
line(1,0,14,159,14);
line(1,0,20,1,20);
line(1,0,30,1,30);
line(1,0,40,1,40);
line(1,158,20,159,20);
line(1,158,30,159,30);
line(1,158,40,159,40);
line(1,0,50,0,159);
line(1,1,51,1,158);
line(1,159,50,159,159);
line(1,158,51,158,158);
line(1,0,159,159,159);
line(1,1,158,158,158);
// line(1,0,68,108,68);
// lo=olo=((float) 16*log(sco));
lo=olo=sco/15;
rect(1,2,2,lo,11,0);
rect(1,130,1,158,12,0); // clean dig.
while(sco>0)
{
rect(0,ox,oy,ox+s,oy+s,0);
rect(0,obx,oby,obx+s,oby+s,0);
bitmap(x,y,b1);
bitmap(bx,by,b2);
text(132,1,tim);
// lo=((float) 16*log(sco));
lo=sco/15;
if(lo!=olo)
{ rect(0,2,2,129,11,0);
rect(1,2,2,lo,11,0); beep(7); }
olo=lo;
// pause(50);
ox=x; oy=y;
obx=bx; oby=by;
if(near(x,y,bx,by))
{ tone(8000,10);
// beep(1);
sco=sco+6;
// rx=rand()*r-r/2;
rx=rand()*r-r/2;
// xd=xd+rx*-1.1; bxd=bxd+rx;
// xd=xd+rx; bxd=bxd+rx*-1.3;
// xd=xd+rx;
bxd=bxd+rx;
// xd=xd-rx;
}
e=event(0);
if(e==2 || e==4)
// if(e==4)
{
// delta(e);
delta();
// xd=xd+(ix/1); yd=yd+(iy/1);
xd=xd+ix; yd=yd+iy;
// if(ix!=0 || iy!=0) { xd=ix/3; yd=iy/3; }
}
xd=xd*0.97; yd=yd*0.97; // slowit
if(bxd>1.5 || bxd<-1.5) bxd=bxd*0.96;
x=x+xd; y=y+yd;
bx=bx+bxd; by=by+byd;
// 150=160-s
if (bx>146 && by<40) {bx=2;}
if (bx<2 && by<40) {bx=146;}
if (x>146) {xd=xd*-1; x=146;}
if (bx>146) {bxd=bxd*-1; bx=146;}
if (x<2) {xd=xd*-1; x=2;}
if (bx<2) {bxd=bxd*-1; bx=2;}
// if (bx<0) {bx=150;}
if (y>146) {yd=yd*-1; y=146;}
if (by>146) {byd=byd*-1; by=146;}
if (y<15) {yd=yd*-1; y=15;}
if (by<15) {byd=byd*-1; by=15;}
// sco=sco-(tim/300); tim=tim+1;
sco=sco-(tim/200); tim=tim+1;
}
clearg(); rect(0,0,0,160,160,0);
frame(1,2,2,158,158,0);
textattr(2,1,0);
text(47,70,"Score: "+(tim));
bitmap(63,100,b1);
bitmap(83,105,b2);
if(tim>top)
{
dbcreate("TeslaBalls");
dbwrite(tim);
top=tim;
dbclose();
}
text(50,50,"Top: "+(top));
sleep(1000);
while(event(0)!=0); waitp();
// while(bstate()==0);
} }