Mercurial > hg > CbC > old > device
annotate test/putenemy.c @ 868:c55337499f96
remove warnings and error from test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 01 Apr 2014 02:42:22 +0900 |
parents | c2c709727221 |
children |
rev | line source |
---|---|
556 | 1 #include <math.h> |
2 | |
3 // for rand | |
4 #include <stdlib.h> | |
5 | |
868
c55337499f96
remove warnings and error from test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
6 extern int printf(const 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) { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
674
diff
changeset
|
42 printf("#0041:Mycos %d=%d\n",c,Mycos0(c)); |
674 | 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) { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
674
diff
changeset
|
58 printf("#0057:Mysin %d=%d\n",c,Mysin0(c)); |
674 | 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) | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
674
diff
changeset
|
65 printf("#0064:%d %f %f %f %f %d\n",charno,x,y,sx,sy,move); |
492 | 66 else |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
674
diff
changeset
|
67 printf("#0066: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(); |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
674
diff
changeset
|
75 printf("#0074:%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 |