view test/putenemy.c @ 585:a5b902b20300 ia32-no-rname

ia32 reconfigure end (correct?)
author kono
date Wed, 18 Jan 2006 12:26:48 +0900
parents 528fed826f17
children 442e90958386
line wrap: on
line source

#include <math.h>

// for rand
#include <stdlib.h>

extern int printf(char *,...);
#define SANKAKU 100000

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 Mycos(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 Mysin(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);
}

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;
     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);
}