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