annotate test/putenemy.c @ 673:442e90958386 ppc-almost-done

PS3 PPc almot done...
author kono
date Sat, 05 May 2007 08:10:56 +0900
parents 528fed826f17
children 68d70527b0c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
1 #include <math.h>
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
2
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
3 // for rand
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
4 #include <stdlib.h>
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
5
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
6 extern int printf(char *,...);
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
7 #define SANKAKU 100000
673
442e90958386 PS3 PPc almot done...
kono
parents: 558
diff changeset
8 #ifndef M_PI
442e90958386 PS3 PPc almot done...
kono
parents: 558
diff changeset
9 #define M_PI 3.1415962
442e90958386 PS3 PPc almot done...
kono
parents: 558
diff changeset
10 #endif
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
11
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
12 static const double pi2 = M_PI * 2.0;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
13
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
14 int mysin[181];
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
15 int mycos[181];
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
16
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
17 void sankakuf()
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
18 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
19 int i;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
20 for(i=0;i<181;i++)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
21 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
22 mysin[i]=sin(i /360.0*pi2)*SANKAKU;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
23 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
24 for(i=0;i<181;i++)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
25 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
26 mycos[i]=cos(i /360.0*pi2)*SANKAKU;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
27 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
28 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
29
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
30 int Mycos(int c)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
31 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
32 c%=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
33 if(c<0) c+=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
34 if((c<=180))
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
35 return(mycos[c]);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
36 if(c>180)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
37 return(mycos[180-(c-180)]);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
38 return(0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
39 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
40
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
41 int Mysin(int c)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
42 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
43 c%=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
44 if(c<0) c+=360;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
45 if(c<=180)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
46 return(mysin[c]);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
47 if(c>180)
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
48 return(mysin[180-(c-180)]*-1);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
49 return(0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
50 }
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
51
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
52 void
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
53 Putenemy(int charno,float x,float y,float sx,float sy,int move) {
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
54 if(x)
558
528fed826f17 const value switch statement prune.
kono
parents: 556
diff changeset
55 printf("#0051:%d %f %f %f %f %d\n",charno,x,y,sx,sy,move);
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
56 else
558
528fed826f17 const value switch statement prune.
kono
parents: 556
diff changeset
57 printf("#0053:check\n");
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
58 }
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
59 int
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
60 main()
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
61 {
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
62 int ix=32,iy=32; float fx=32,fy=32;
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
63 sankakuf();
558
528fed826f17 const value switch statement prune.
kono
parents: 556
diff changeset
64 printf("#0060:%d %d\n", Mysin(45),Mycos(-30));
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
65 {
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
66 float x=10,y=20;
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
67 Putenemy(3,x,y,(float) Mysin(15)*2/SANKAKU,(float)Mycos(15)*2/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
68 //Putenemy(3,x,y,(float) Mysin(15)*2.0/SANKAKU,(float)Mycos(15)*2.0/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
69 Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2/SANKAKU,(float)Mycos(rand()%15*-1)*2/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
70 // Putenemy(3,x,y,(float) Mysin(rand()%15*-1)*2.0/SANKAKU,(float)Mycos(rand()%15*-1)*2.0/SANKAKU,0);
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
71 }
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
72 Putenemy(0,ix,iy,1,0,10);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
73 Putenemy(1,(float)ix,(float)iy,1,0,10);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
74 Putenemy(2,(float)ix,(float)iy,(float)ix,(float)iy,ix);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
75 Putenemy(3,(float)ix,(float)iy,(float)ix,0,ix);
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
76 Putenemy(4,fx,fy,1,0,10);
556
ef225b589888 s-dandy fix
kono
parents: 496
diff changeset
77 return(0);
492
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
78 }
cc1a5f764782 *** empty log message ***
kono
parents:
diff changeset
79