view src/Character_state.cc @ 4:bb2fbe78c7cd

moving title scene.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Tue, 07 Dec 2010 18:37:43 +0900
parents deb7e09824a4
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include "SDL_opengl.h"
#include "object.h"
#include "Character.h"
#include "Character_state.h"
#include "count.h"
#include "schedule.h"
#include "bom.h"
#include "sankaku.h"
#include "sgoex.h"
#include "collision.h"
#include "debug.h"
#include "tama.h"

SpriteTable *kyeenemyno;
SpriteTable *tekino0;
SpriteTable *enemy_part1;
SpriteTable *enemy_part2;
SpriteTable *enemy_part3;
SpriteTable *enemy_part4;
SpriteTable *enemy_part5;

//int tekino0;
int rinkx;
int rinky;
int rinkf1 = 0, rinkf2 = 0;
void*asteroiddt[200];
int asteroidi = 0;
int enemyfaste = 0;
int sf;
int amari;
int fastebos = 0;

void
noaction(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h){}

void
chara_state0(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
}

void
chara_state1(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] -= p->vx;
    node->xyz[1] -= p->vy;
}

void
chara_state2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->vy -= 0.25;
    node->xyz[1] += p->vy;
}

void
chara_state3(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    if((p->dt1 == 60) ||
       (p->dt1 == 90) ||
       (p->dt1 == 30))
    {
	Puttama(0, node->xyz[0], node->xyz[1]);
    }
    p->dt1++;
}

void
chara_state4(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[1] += p->vy;
    node->xyz[0] += p->vx;
    if(node->xyz[1] < jiki.y && node->xyz[1] + 16 > jiki.y)
    {
	p->vy = -2;
	p->vx = ((jiki.x > node->xyz[0]) ? 4 : -4);
	node->set_move_collision(chara_state7);
    }
}

void
chara_state5(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[1] += p->vy;
    node->xyz[0] += p->vx;
    if(node->xyz[1] + 96 < jiki.y 
       && node->xyz[1] + 128 > jiki.y)
    {
	p->vy = -2;
	p->vx = ((jiki.x > node->xyz[0]) ? 4 : -4);
	node->set_move_collision(chara_state0);
    }
}

void
chara_state6(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[1] += p->vy;
    node->xyz[0] += p->vx;
    if(node->xyz[1] + 96 < jiki.y
       && node->xyz[1] + 128 > jiki.y)
    {
	p->vy = 2;
	p->vx = ((jiki.x > node->xyz[0]) ? 4 : -4);
	node->set_move_collision(chara_state0);
    }
}

void
chara_state7(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    if((p->dt1 == 60) || (p->dt1 == 90)
       || (p->dt1 == 30))
    {
	Puttama(1, node->xyz[0], node->xyz[1]);
    }
    p->dt1++;
}

#if 0
// state1 boss patern
void
chara_state8(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(node->xyz[1] < 520)
    {
	tekino0 = p;
	kyeenemyno = p;
	node->xyz[1] += p->vy;
	count++;
	DefSpriteEx(p->charano, 16*4, 32*4);
	PutSpriteEx(p->charano, (node->xyz[0] * 4), (node->xyz[1] * 4), 0.2, 0.2, 1);
	p->dt1 = 512;
	p->s = 0.125;
    }

    node->set_move_collision(chara_state9);
}

void
chara_state9(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(p->s <= 2)
    {
	p->s += 0.05;
	node->xyz[1] -= 12;
	count++;
	DefSpriteEx(54, 16*4, 32*4);
	PutSpriteEx(54, (node->xyz[0] * 4), (node->xyz[1] * 4), p->s, p->s, 1);
    }

    count++;
    DefSpriteEx(54, 16, 32);
    PutSpriteEx(54, node->xyz[0], node->xyz[1], p->s, p->s, 1);
    rinkx = node->xyz[0];
    rinky = node->xyz[1];
    Putenemy(sgroot, root, 5, rinkx - 16, rinky - 16, 1, 0, chara_state10);
    Putenemy(sgroot, root, 5, rinkx - 16, rinky - 16, -1, 0, chara_state10);

    node->set_move_collision(chara_state11);
    p->dt1 = 8192;
}


void
chara_state10(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(p->dt1 < 48)
    {
	node->xyz[0] += p->vx;
	node->xyz[1] += p->vy;
	p->dt1++;
    }
    rinkf1 = 1;
    p->dt1 = rinkx;
    p->dt2 = rinky;
    node->set_move_collision(chara_state13);
}


void
chara_state11(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(rinkf1 == 0)
    {
	count++;
	DefSpriteEx(54, 16, 32);
	PutSpriteEx(54, node->xyz[0], node->xyz[1], p->s, p->s, 1);
	node->set_move_collision(chara_state11);
    }
    p->dt1 = 0;
    p->dt2 = 0;
    node->set_move_collision(chara_state12);
}

void
chara_state12(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(fastebos > 60*60)
    {
	if(node->xyz[1] > 240+32)
	{
	    p->state = delete_chara;
	}
	node->xyz[1] += 3;
	rinky += 3;
	count++;
	DefSpriteEx(54, 16, 32);
	PutSpriteEx(54, node->xyz[0], node->xyz[1], 2, 2, 1);
	node->set_move_collision(chara_state12);
    }
    if(p->dt1 <= 60)
    {
	if(jiki.x + 15 - rinkx < -5)
	{
	    p->vx = -0.8;
	}
	else if(jiki.x + 15 - rinkx > 5)
	{
	    p->vx = +0.8;
	}
	else p->vx = 0;
	rinkx = node->xyz[0];
	rinky = node->xyz[1];
    }
    if((p->dt1 > 60) && (p->dt1 <= 70))
    {
	if(p->dt1 % 2 == 1)
	{
	    Puttama(0, rinkx - 16, rinky);
	    Puttama(0, rinkx, rinky);
	    Puttama(0, rinkx + 16, rinky);
	}
    }
    if((p->dt1 > 180) && (p->dt1 <= 240))
    {
	if(p->dt1 % 2 == 1)
	{
	    rinkf2 = 1;
	    Puttama(2, rinkx - 16, node->xyz[1] - 32);
	    Puttama(3, rinkx + 32 - 16, node->xyz[1] - 32);
	}
	else
	{
	    rinkf2 = 2;
	}
    }
    if(p->dt1 > 240)
    {
	rinkf2 = 2;
    }
    if((p->dt1 > 240) && (p->dt1 <= 400))
    {
	count++;
	PutSprite(count, rinkx - 16, rinky + 32,
		  58 + p->dt1 % 4);
    }
    if((p->dt1 > 300) && (p->dt1 <= 400))
    {
	rinkf2 = 3;
	if(jiki.x + 15 - rinkx < -5)
	{
	    p->vx = -1;
	}
	else if(jiki.x + 15 - rinkx > 5)
	{
	    p->vx = +1;
	}
	else p->vx = 0;
	node->xyz[0] += p->vx;
	rinkx = node->xyz[0];
	rinky = node->xyz[1];
	Puttama(4, rinkx - 8, rinky + 16);
    }
    if((p->dt1 > 400) && (p->dt1 <= 500))
    {
	rinkf2 = 4;
	if(jiki.x + 15 - rinkx > 5)
	{
	    p->vx = -1;
	}
	else if(jiki.x + 15 - rinkx > 5)
	{
	    p->vx = +1;
	}
	else p->vx = 0;
	node->xyz[0] += p->vx;
	rinkx = node->xyz[0];
	rinky = node->xyz[1];
    }
    if(p->dt1 > 500)
    {
	rinkf2 = 5;
	if(jiki.x + 15 - rinkx < -5)
	{
	    p->vx = -1;
	}
	else if(jiki.x + 15 - rinkx > 5)
	{
	    p->vx = +1;
	}
	else p->vx = 0;
	node->xyz[0] += p->vx;
	rinkx = node->xyz[0];
	rinky = node->xyz[1];
    }
    if(p->dt1 > 600)
    {
	rinkf2 = 0;
	p->dt1 = 0;
    }
    fastebos++;
    p->dt1++;
    count++;
    DefSpriteEx(54, 16, 32);
    PutSpriteEx(54, node->xyz[0], node->xyz[1], 2, 2, 1);
}


void
chara_state13(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(tekino0->f == FALSE){
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }

    node->xyz[0] += rinkx - p->dt1;
    node->xyz[1] += rinky - p->dt2;
    p->dt1 = rinkx;
    p->dt2 = rinky;
    if(rinkf2 == 1)
    {
	if(node->xyz[0] > rinkx)
	{
	    Puttama(2, node->xyz[0] + 32, node->xyz[1]);
	}
	if(node->xyz[0] < rinkx)
	{
	    Puttama(3, node->xyz[0], node->xyz[1]);
	}
    }
    if(rinkf2 == 4)
    {
	count++;
	PutSprite(count, node->xyz[0], node->xyz[1] + 56, 58+filpcount % 4);
    }
    if(rinkf2 == 5)
    {
	if(node->xyz[0] > rinkx)
	{
	    Puttama(5, node->xyz[0] + 8, node->xyz[1] + 24);
	}
	if(node->xyz[0] < rinkx)
	{
	    Puttama(5, node->xyz[0] + 8, node->xyz[1] + 24);
	}
    }
}


void
chara_state20(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    p->vy -= 0.5;
    p->vy += 0.4;
}

void
chara_state21(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    p->vx += 0.5;
    p->vy += 0.4;
}

//ここまでgetate boss


void
chara_state22(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    sf = rand() % 4;
    if((sf == 0) || (sf == 1))
    {
	node->xyz[0] = -35;
	node->xyz[1] = rand() % (120 - 35);
	p->vx = (rand() % 4 + 1);
	p->vy = rand() % 3 + 1;
	node->set_move_collision(chara_state23);
    }
    if((sf == 2))
    {
	node->xyz[0] = rand() % 290;
	node->xyz[1] = -30;
	p->vx = rand() % 3 - 1;
	p->vy = (rand() % 4 + 1);
	node->set_move_collision(chara_state23);
    }
    if(sf == 3)
    {
	node->xyz[0] = 320;
	node->xyz[1] = rand() % (120 - 35);
	p->vx = (rand() % 4 + 1) * -1;
	p->vy = rand() % 3 -1;
	node->set_move_collision(chara_state23);
    }
}
	  
void
chara_state23(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p = asteroid(p);
}

void
chara_state24(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    kyeenemyno = p;
    tekino0 = 0;
    enemy_part1 = p->next;
    enemy_part2 = enemy_part1->next;
    enemy_part3 = enemy_part2->next;
    enemy_part4 = enemy_part3->next;
    enemy_part5 = enemy_part4->next;
    rinkx = 0;
    rinky = 0;
    rinkf1 = 0;
    rinkf2 = 0;
    node->set_move_collision(chara_state25);
}

void
chara_state25(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if(p->dt1 <= 360)
    {
	node->xyz[0] = Mycos(p->dt1) * 30 / SANKAKU + 82 + 32;
	node->xyz[1] = Mysin(p->dt1) * 30 / SANKAKU + 30;
    }
    if(p->dt1 > 360)
    {
	node->xyz[0] = Mycos(p->dt1) * 30 * -1 /SANKAKU + 142 + 32;
	node->xyz[1] = Mysin(p->dt1) * 30 / SANKAKU + 30;
    }
    count++;
    PutSprite(count, node->xyz[0] - 42, node->xyz[1], 64);
    amari = rand() % 160;
    if((amari == 1) && (enemy_part5->f == TRUE))
    {
	node->set_move_collision(chara_state26);
	rinkf1 = 1;
    }
    if((amari == 2) && (enemy_part1->f == TRUE))
    {
	node->set_move_collision(chara_state27);
	rinkf1 = 5;
	rinkx = 0;
    }
    if((enemy_part5->f == TRUE) && (enemy_part1->f != TRUE))
    {
	node->set_move_collision(chara_state28);
    }
    p->dt1 += 3;
    if(p->dt1 == 720)
    {
	p->dt1 = 0;
    }
}

void
chara_state26(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if((p->dt2 > 50) && (p->dt2 < 100))
    {
	rinkf1 = 2;
    }
    if(p->dt2 > 100)
    {
	rinkf1 = 3;
    }
    if(p->dt2 == 400)
    {
	rinkf1 = 4;
    }
    count++;
    PutSprite(count, node->xyz[0] - 42, node->xyz[1], 64);
    if(p->dt2 == 401)
    {
	p->dt2 = 0;
	rinkf1 = 0;
	node->set_move_collision(chara_state25);
    }
    p->dt2++;
}

void
chara_state27(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) //rocket punch
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if((p->dt2 > 50) && (p->dt2 < 60) && (node->xyz[0] > -24) && (node->xyz[1] > -24))
    {
	rinkf1 = 6;
	rinkx -= 4;
	node->xyz[0] -= 4;
	node->xyz[1] -= 4;
    }
    if(p->dt2 == 80)
    {
	rinkf1 = 7;
    }
    if(p->dt2 == 81)
    {
	rinkf1 = 8;
    }
    if(p->dt2 == 124)
    {
	rinkf1 = 9;
    }
    if(p->dt2 == 400)
    {
	rinkf1 = 10;
    }
    if(p->dt2 == 444)
    {
	rinkf1 = 11;
    }
    if(p->dt2 == 500)
    {
	rinkf1 = 12;
    }
    if((p->dt2 > 80) && (p->dt2 < 200))
    {
	if((rinkx != 0) && (p->dt2 % 2 == 1))
	{
	    rinkx++;
	    node->xyz[0]++;
	    node->xyz[1]++;
	}
    }
    count++;
    PutSprite(count, node->xyz[0] - 32, node->xyz[1], 6);
    if(rinkf1 == 12)
    {
	p->dt2 = 0;
	rinkf1 = 0;
	rinkx = 0;
	node->set_move_collision(chara_state25);
    }
    p->dt2++;
}
void
chara_state28(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (p->dt1 <= 360)
    {
	node->xyz[0] = Mycos(p->dt1) * 30 / SANKAKU + 82 + 32;
	node->xyz[1] = Mysin(p->dt1) * 30 / SANKAKU + 30;
    }
    if (p->dt1 > 360)
    {
	node->xyz[0] = Mycos(p->dt1) * 30 * -1 / SANKAKU + 142 + 32;
	node->xyz[1] = Mysin(p->dt1) * 30 / SANKAKU + 30;
    }
    count++;
    PutSprite(count, node->xyz[0] - 42, node->xyz[1], 64);
    if (p->dt1 % 30 == 3)
    {
	Putenemy(sgroot, root, 24, node->xyz[0] + 14,
		 node->xyz[1] + 14,
		 (rand() % 5 + 0.5) * (rand() % 2 ==
				       1 ? -1 : 1),
		 (rand() % 5 + 0.5) * (rand() % 2 ==
				       1 ? -1 : 1), chara_state29);
    }
    p->dt1 += 3;
}


void
chara_state29(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    if(p->dt1 % 18 == 1)
    {
	Puttama(0, node->xyz[0], node->xyz[1]);
    }
    p->dt1++;
}


void
chara_state30(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] = node->xyz[0] - 32;
    node->xyz[1] = node->xyz[1];
}

void
chara_state31(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) //right hand
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];
  
    if((enemy_part3->f == FALSE) || (kyeenemyno->f == FALSE))
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }

    if(rinkf1 == 0)
    {
	node->xyz[0] = kyeenemyno->x + 40;
	node->xyz[1] = kyeenemyno->y + 28;
	p->dt2 = 0;
    }
    if(rinkf1 == 5)
    {
	node->xyz[0] = kyeenemyno->x + 52;
	node->xyz[1] = kyeenemyno->y;
	count++;
	PutSprite(count, node->xyz[0] - 4, node->xyz[1] - 20, 80 + p->dt2 % 4);
	p->dt2++;
    }
    if(rinkf1 == 6)
    {
	if(node->xyz[1] < 240 - 40)
	{
	    node->xyz[1] += 6;
	}
	count++;
	PutSprite(count, node->xyz[0] - 4, node->xyz[1] - 20, 90 + p->dt2 % 4);
	p->dt2++;
    }
    if(rinkf1 == 7)
    {
	Putenemy(sgroot, root, 22, node->xyz[0] + 14, node->xyz[1] + 14, 0, 0, chara_state40);
    }
    if(rinkf1 == 11)
    {
	if(node->xyz[1] + 20 != node->xyz[1])
	{
	    node->xyz[1]--;
	}
	count++;
	PutSprite(count, node->xyz[0] + 8, node->xyz[1] + 44, 58 + p->dt2 % 4);
	p->dt2++;
    }
}


void
chara_state32(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) //left hand
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if ((enemy_part4->f == FALSE)
	|| (kyeenemyno->f == FALSE))
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }
    node->xyz[0] = kyeenemyno->x - 40;
    node->xyz[1] = kyeenemyno->y + 28;
    if (rinkf1 == 5)
    {
	node->xyz[0] = kyeenemyno->x - 24 + 4;
	node->xyz[1] = kyeenemyno->y + 28;
	p->charano = enemystate[20].charano;
    }
    if (rinkf1 == 11)
    {
	p->charano = enemystate[14].charano;
    }
    if (rinkf1 == 7)
    {
	Putenemy(sgroot, root, 23, node->xyz[0] + 14,
		 node->xyz[1] + 14, 0, 0, chara_state41);
	//      rinkf1=8;
    }
}


void
chara_state33(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) // right shoulder
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (kyeenemyno->f == FALSE)
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }
    node->xyz[0] = kyeenemyno->x + 32;
    node->xyz[1] = kyeenemyno->y;
    if (rinkf1 == 5)
    {
	node->xyz[0] = kyeenemyno->x + 32 - 4;
	node->xyz[1] = kyeenemyno->y;
	p->charano = enemystate[19].charano;
    }
    if (rinkf1 == 6)
    {
	p->charano = enemystate[11].charano;
    }
}


void
chara_state34(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) //left shoulder
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (kyeenemyno->f == FALSE)
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }
    node->xyz[0] = kyeenemyno->x - 32;
    node->xyz[1] = kyeenemyno->y;
    if (rinkf1 == 5)
    {
	p->charano = enemystate[21].charano;
    }
    if (rinkf1 == 6)
    {
	p->charano = enemystate[12].charano;
    }
}

void
chara_state35(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) // bust
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (kyeenemyno->f == FALSE)
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }
    node->xyz[0] = kyeenemyno->x;
    node->xyz[1] = kyeenemyno->y + 32;
    if (rinkf1 == 1)
    {
	p->charano = enemystate[16].charano;
    }
    if (rinkf1 == 2)
    {
	count++;
	PutSprite(count, node->xyz[0] - 10,
		  node->xyz[1] + 16,
		  58 + p->dt2 % 4);
	count++;
	PutSprite(count, node->xyz[0] + 10,
		  node->xyz[1] + 16,
		  58 + p->dt2 % 4);
	p->dt2++;
    }
    if (rinkf1 == 3)
    {
	count++;
	PutSprite(count, node->xyz[0] - 10,
		  node->xyz[1] + 16,
		  58 + p->dt2 % 4);
	count++;
	PutSprite(count, node->xyz[0] + 10,
		  node->xyz[1] + 16,
		  58 + p->dt2 % 4);
	if (p->dt2 % 20 == 1)
	{
	    Puttama(7, node->xyz[0], node->xyz[1] + 16);
	    Puttama(7, node->xyz[0] + 20,
		    node->xyz[1] + 16);
	}
	p->dt2++;
    }
    if (rinkf1 == 4) {
	p->charano = enemystate[15].charano;
	p->dt2 = 0;
    }
}


void
chara_state40(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) //arm vulkan
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (enemy_part1->f == FALSE)
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }
    if ((rinkf1 == 8) && (p->dt1 % 3 == 1))
    {
	if ((p->dt2 < 16))
	{
	    p->dt2++;
	    DefSprite(76, "boss2_rightarm_b", 16, p->dt2, 480, boss);
	}
	else
	{
	    //                                  rinkf1=9;
	}
    }
    if (rinkf1 == 9)
    {
	if (p->dt1 % 15 == 1)
	{
	    Puttama(8, node->xyz[0], node->xyz[1]);
	}
    }
    if (rinkf1 == 10)
    {
	if (p->dt2 != 0)
	{
	    p->dt2--;
	    DefSprite(76, "boss2_rightarm_b", 16, p->dt2, 480, boss);
	}
	else
	{
	    p->f = FALSE;
	    node->set_move_collision(noaction, delete_chara);
	    //          rinkf1=11;
	}
    }
    p->dt1++;
}


void
chara_state41(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) //left arm up arm vulkan
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (enemy_part2->f == FALSE)
    {
	Bom(node->xyz[0], node->xyz[1]);
	p->f = FALSE;
	node->set_move_collision(noaction, delete_chara);
    }
    node->xyz[0] = kyeenemyno->x - 20 - 7;
    node->xyz[1] = kyeenemyno->y + 28 + 15;
    if ((rinkf1 == 8) && (p->dt1 % 3 == 1))
    {
	if ((p->dt2 < 16))
	{
	    p->dt2++;
	    DefSprite(77, "boss2_leftarmbattery", p->dt2, 16, 480, boss);	/*左腕アップアーム砲 */
	}
	else
	{
	    rinkf1 = 9;
	}
    }
    if (rinkf1 == 9)
    {
	if (p->dt1 % 15 == 1) 
	{
	    Puttama(9 + rand() % 2, node->xyz[0], node->xyz[1]);
	}
    }
    if (rinkf1 == 10)
    {
	if (p->dt2 != 0)
	{
	    p->dt2--;
	    DefSprite(77, "boss2_leftarmbattery", p->dt2, 16, 480, boss);
	}
	else
	{
	    p->f = FALSE;

	    node->set_move_collision(noaction, delete_chara);
	    //          rinkf1=11;
	}
    }
    p->dt1++;
}


void
chara_state400(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->vy++;
    node->xyz[1] += p->vy / 4;
}


void
chara_state401(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->vx++;
    node->xyz[0] += p->vx / 8;
    if (node->xyz[0] > (jiki.x - 32))
    {
	p->vy--;
    }
    node->xyz[1] += p->vy / 8;
    if (p->dt1 % 50 == 37)
    {
	Puttama(1, node->xyz[0] + 8, node->xyz[1] + 24);
    }
    p->dt1++;
}


void
chara_state402(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->vx--;
    node->xyz[0] += p->vx / 8;
    if (node->xyz[0] < (jiki.x + 32))
    {
	p->vy--;
    }
    node->xyz[1] += p->vy / 8;
    if (p->dt1 % 50 == 37)
    {
	Puttama(1, node->xyz[0] + 8, node->xyz[1] + 24);
    }
    p->dt1++;
}


void
chara_state410(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    kyeenemyno = p;
    node->set_move_collision(chara_state411);
}


void
chara_state411(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    if (p->dt2 > 356)
    {
	p->vx = -1;
    }
    if (p->dt2 < -398)
    {
	p->vx = 1;
    }
    if ((p->dt1) % 62 == 0)
	Putenemy(sgroot, root, 41,
		 node->xyz[0],
		 node->xyz[1],
		 (int) -Mycos(p->dt1 / 16) * 4 /
		 SANKAKU,
		 (int) -Mysin(p->dt1 / 16) * 4 /
		 SANKAKU, chara_state7);
    if ((p->dt1) % 13 == 0)
	Puttama(11, node->xyz[0] + 32,
		node->xyz[1] + 32);
  
    p->dt2 += p->vx;
    p->dt1 += p->dt2 / 4;
  
    node->xyz[0] = jiki.x - 16 +
	Mycos(p->dt1 / 16) * 128 / SANKAKU;
    node->xyz[1] = jiki.y - 16 +
	Mysin(p->dt1 / 16) * 128 / SANKAKU;
    if (node->xyz[0] < 0)
    {
	node->xyz[0] = 0;
    }
    if (node->xyz[0] > 260)
    {
	node->xyz[0] = 260;
    }
    if (node->xyz[1] < 0)
    {
	node->xyz[1] = 0;
    }
    if (node->xyz[1] > 232)
    {
	node->xyz[1] = 232;
    }
}


void
chara_state500(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->s = 0;
  
    kyeenemyno = p;
    p->dt2++;
    p->dt2 %= 512;
    p->dt1++;
    count++;
    DefSpriteEx(100, 16, 16);
    //		PutSprite(count, enemy[tekino].x + 16,
    //  enemy[tekino].y + 16, 100);
    PutSpriteEx(100, node->xyz[0] + 16, node->xyz[1] + 16, 2, 2, p->dt1);
  
    if (p->dt1 % (5 + p->dt2 / 8) == 1) {
	if (rand() % 2 == 1)
	    Putenemy(sgroot, root, 24, node->xyz[0], node->xyz[1],
		     (rand() % 5 + 0.5) * (rand() % 2 ==
					   1 ? -1 : 1),
		     (rand() % 5 + 0.5) * (rand() % 2 ==
					   1 ? -1 : 1), chara_state501);
	else
	    Putenemy(sgroot, root, rand() % 2 + 1, node->xyz[0],
		     node->xyz[1],
		     (int) Mycos(p->dt1 / 4) * 4 /
		     SANKAKU,
		     (int) -Mysin(p->dt1 / 4) * 4 /
		     SANKAKU, chara_state501);
    }
    if (p->dt1 == 50) {
	/*Putenemy(sgroot, root, 44,0,0,1,1,411); */
    }
}


void
chara_state501(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    if(p->dt1 % 32 == 1)
    {
	Puttama(11, node->xyz[0], node->xyz[1]);
    }
    p->dt1++;
}


void
chara_state600(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    kyeenemyno = p;
    p->dt1 += 30;
    p->dt2++;
    p->dt1 %= 360;
    node->xyz[0] += Mycos(p->dt1) * 4 / SANKAKU;
    node->xyz[1] += Mysin(p->dt1) * 4 / SANKAKU;
    Puttama(11, node->xyz[0] + 16, node->xyz[1] + 16);
    Puttama(11, node->xyz[0] + 32, node->xyz[1] + 48);
    Puttama(11, node->xyz[0] + 48, node->xyz[1] + 16);
    if (p->dt2 > 240)
	node->set_move_collision(chara_state601);
    if (node->xyz[0] < 0)
	node->xyz[0] = 0;
    if (node->xyz[0] > 260)
	node->xyz[0] = 260;
    if (node->xyz[1] < 0)
	node->xyz[1] = 0;
    if (node->xyz[1] > 232)
	node->xyz[1] = 232;
}


void
chara_state601(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->dt2++;
    if (node->xyz[0] < jiki.x)
	p->vx++;
    if (node->xyz[0] > jiki.x)
	p->vx--;
    node->xyz[0] += p->vx;
    Putenemy(sgroot, root, 6, node->xyz[0] + 16 + rand() % 32,
	     node->xyz[1], 0, rand() % 4, chara_state400);
    if (node->xyz[0] < 0)
	node->xyz[0] = 0;
    if (node->xyz[0] > 260)
	node->xyz[0] = 260;
    if (node->xyz[1] < 0)
	node->xyz[1] = 0;
    if (node->xyz[1] > 232)
	node->xyz[1] = 232;
    if (p->dt2 > 800) {
	node->set_move_collision(chara_state602);
    }
}


void
chara_state602(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];

    p->dt2++;
    Putenemy(sgroot, root, 24, node->xyz[0] + 14, node->xyz[1] + 14,
	     (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1),
	     (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1),
	     chara_state29);
    if (p->dt2 > 1024) {
	node->set_move_collision(chara_state600);
	p->dt2 = 0;
    }
}


void
asteroid(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
{
    int charano = node->stack_xyz[0];
    SpriteTable *p = &sptable[charano];
    int i;

    asteroiddt[asteroidi] = p;
    //            if(asteroidi==0)
    //            {
    node->xyz[0] += p->vx;
    node->xyz[1] += p->vy;
    //            }
    if (asteroidi > 0) {
	for (i = 0; i < asteroidi; i++) {
	    if ((asteroiddt[i]->x + 32 > node->xyz[0])
		&& (node->xyz[0] + 32 > asteroiddt[i]->x)
		&& (asteroiddt[i]->y + 32 > node->xyz[1])
		&& (asteroiddt[i]->y < node->xyz[1] + 32)) {
		p->vx *= -1;
		p->vy *= -1;
	    }
	}
    }
    asteroidi++;
}
#endif