Mercurial > hg > CbC > old > device
view test/putenemy.c @ 691:25115b50d033
*** empty log message ***
author | kono |
---|---|
date | Wed, 10 Oct 2007 17:58:15 +0900 |
parents | 68d70527b0c0 |
children | c2c709727221 |
line wrap: on
line source
#include <math.h> // for rand #include <stdlib.h> extern int printf(char *,...); #define SANKAKU 100000 #ifndef M_PI #define M_PI 3.1415962 #endif static const double pi2 = M_PI * 2.0; int mysin[181]; int mycos[181]; void sankakuf() { int i; for(i=0;i<181;i++) { mysin[i]=sin(i /360.0*pi2)*SANKAKU; } for(i=0;i<181;i++) { mycos[i]=cos(i /360.0*pi2)*SANKAKU; } } int Mycos0(int c) { c%=360; if(c<0) c+=360; if((c<=180)) return(mycos[c]); if(c>180) return(mycos[180-(c-180)]); return(0); } int Mycos(int c) { printf("Mycos %d=%d\n",c,Mycos0(c)); return Mycos0(c); } int Mysin0(int c) { c%=360; if(c<0) c+=360; if(c<=180) return(mysin[c]); if(c>180) return(mysin[180-(c-180)]*-1); return(0); } int Mysin(int c) { printf("Mysin %d=%d\n",c,Mysin0(c)); return Mysin0(c); } void Putenemy(int charno,float x,float y,float sx,float sy,int move) { if(x) printf("#0051:%d %f %f %f %f %d\n",charno,x,y,sx,sy,move); else printf("#0053:check\n"); } int main() { int ix=32,iy=32; float fx=32,fy=32; srand(55555); sankakuf(); printf("#0060:%d %d\n", Mysin(45),Mycos(-30)); { float x=10,y=20; Putenemy(3,x,y,(float) Mysin(15)*2/SANKAKU,(float)Mycos(15)*2/SANKAKU,0); //Putenemy(3,x,y,(float) Mysin(15)*2.0/SANKAKU,(float)Mycos(15)*2.0/SANKAKU,0); Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2/SANKAKU,(float)Mycos(rand()%15*-1)*2/SANKAKU,0); // Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2.0/SANKAKU,(float)Mycos(rand()%15*-1)*2.0/SANKAKU,0); } Putenemy(0,ix,iy,1,0,10); Putenemy(1,(float)ix,(float)iy,1,0,10); Putenemy(2,(float)ix,(float)iy,(float)ix,(float)iy,ix); Putenemy(3,(float)ix,(float)iy,(float)ix,0,ix); Putenemy(4,fx,fy,1,0,10); return(0); }