556
|
1 #include <math.h>
|
|
2
|
|
3 // for rand
|
|
4 #include <stdlib.h>
|
|
5
|
492
|
6 extern int printf(char *,...);
|
556
|
7 #define SANKAKU 100000
|
|
8
|
|
9 static const double pi2 = M_PI * 2.0;
|
|
10
|
|
11 int mysin[181];
|
|
12 int mycos[181];
|
|
13
|
|
14 void sankakuf()
|
|
15 {
|
|
16 int i;
|
|
17 for(i=0;i<181;i++)
|
|
18 {
|
|
19 mysin[i]=sin(i /360.0*pi2)*SANKAKU;
|
|
20 }
|
|
21 for(i=0;i<181;i++)
|
|
22 {
|
|
23 mycos[i]=cos(i /360.0*pi2)*SANKAKU;
|
|
24 }
|
|
25 }
|
|
26
|
|
27 int Mycos(int c)
|
|
28 {
|
|
29 c%=360;
|
|
30 if(c<0) c+=360;
|
|
31 if((c<=180))
|
|
32 return(mycos[c]);
|
|
33 if(c>180)
|
|
34 return(mycos[180-(c-180)]);
|
|
35 return(0);
|
|
36 }
|
|
37
|
|
38 int Mysin(int c)
|
|
39 {
|
|
40 c%=360;
|
|
41 if(c<0) c+=360;
|
|
42 if(c<=180)
|
|
43 return(mysin[c]);
|
|
44 if(c>180)
|
|
45 return(mysin[180-(c-180)]*-1);
|
|
46 return(0);
|
|
47 }
|
|
48
|
492
|
49 void
|
|
50 Putenemy(int charno,float x,float y,float sx,float sy,int move) {
|
|
51 if(x)
|
558
|
52 printf("#0051:%d %f %f %f %f %d\n",charno,x,y,sx,sy,move);
|
492
|
53 else
|
558
|
54 printf("#0053:check\n");
|
492
|
55 }
|
|
56 int
|
|
57 main()
|
|
58 {
|
|
59 int ix=32,iy=32; float fx=32,fy=32;
|
556
|
60 sankakuf();
|
558
|
61 printf("#0060:%d %d\n", Mysin(45),Mycos(-30));
|
556
|
62 {
|
|
63 float x=10,y=20;
|
|
64 Putenemy(3,x,y,(float) Mysin(15)*2/SANKAKU,(float)Mycos(15)*2/SANKAKU,0);
|
|
65 //Putenemy(3,x,y,(float) Mysin(15)*2.0/SANKAKU,(float)Mycos(15)*2.0/SANKAKU,0);
|
|
66 Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2/SANKAKU,(float)Mycos(rand()%15*-1)*2/SANKAKU,0);
|
|
67 // Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2.0/SANKAKU,(float)Mycos(rand()%15*-1)*2.0/SANKAKU,0);
|
|
68 }
|
492
|
69 Putenemy(0,ix,iy,1,0,10);
|
|
70 Putenemy(1,(float)ix,(float)iy,1,0,10);
|
|
71 Putenemy(2,(float)ix,(float)iy,(float)ix,(float)iy,ix);
|
|
72 Putenemy(3,(float)ix,(float)iy,(float)ix,0,ix);
|
|
73 Putenemy(4,fx,fy,1,0,10);
|
556
|
74 return(0);
|
492
|
75 }
|
|
76
|