diff spe/chara_state12.cc @ 49:f4140672ef9f

fix.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Fri, 21 Jan 2011 22:18:28 +0900
parents c330ded6d728
children cfd42ee2ad28
line wrap: on
line diff
--- a/spe/chara_state12.cc	Sat Jan 15 19:13:03 2011 +0900
+++ b/spe/chara_state12.cc	Fri Jan 21 22:18:28 2011 +0900
@@ -1,131 +1,212 @@
-#include "chara_state12.h"
-#include "tobject.h"
+#include "task_base.h"
+#include "task_object.h"
 
-SchedDefineTask(STATE12);
+SchedDefineTask1(State12, state12);
 
 static int
-run(SchedTask *smanager, void *rbuf, void *wbuf)
+state12(SchedTask *smanager, void *rbuf, void *wbuf)
 {
+    int fastebos = (int)smanager->get_param(0);
+    int count = (int)smanager->get_param(1);
+    int rinkx = (int)smanager->get_param(2);
+    int rinky = (int)smanager->get_param(3);
+
     CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
+    int length;
+    int rinkf2;
+    int index_count = 0;
 
-    if(fastebos > 60*60)
-    {
-	if(p->y > 240+32)
-	{
-	    p->state = delete_chara;
+    if (fastebos > 60*60) {
+	length = 2;
+	smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	smanager->setup_outputData();
+	
+	CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0);
+	int *w_count = (int*)smanager->get_output(wbuf, 3);
+	int *w_rinky = (int*)smanager->get_output(wbuf, 4);
+	ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 6);
+	sprite->flag = true;
+	sprite->length = length;
+	
+	if (p->y > 240+32) {
+	    p->task = DELETE_CHARA;
 	}
 	p->y += 3;
 	rinky += 3;
 	count++;
-	DefSpriteEx(54, 16, 32);
-	PutSpriteEx(54, p->x, p->y, 2, 2, 1);
-	p->state = chara_state12;
+	
+	DefSpriteEx(54, 16, 32, &sprite->data[index_count]);
+	index_count++;
+	PutSpriteEx(54, p->x, p->y, 2, 2, 1, &sprite->data[index_count]);
+	p->task = STATE12;
+	
+	*w_rinky = rinky;
+	*w_count = count;
+	*q = *p;
 	return 0;
     }
-    if(p->dt1 <= 60)
-    {
-	if(jiki.x + 15 - rinkx < -5)
-	{
+    
+    player *jiki = (player*)smanager->get_input(rbuf, 1);
+
+    if (p->dt1 <= 60) {
+	length = 2;
+	smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	smanager->setup_outputData();
+
+	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;
 	}
-      else if(jiki.x + 15 - rinkx > 5)
-      {
-	  p->vx = +0.8;
-      }
-      else p->vx = 0;
 	rinkx = p->x;
 	rinky = p->y;
     }
-    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 > 60) && (p->dt1 <= 70)) {
+	if(p->dt1 % 2 == 1) {
+	    length = 5;
+	    smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	    smanager->setup_outputData();
+	    
+	    ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 6);
+	    sprite->flag = true;
+	    sprite->length = length;
+
+	    Puttama(0, rinkx - 16, rinky, &sprite->data[index_count]);
+	    index_count++;
+	    Puttama(0, rinkx, rinky, &sprite->data[index_count]);
+	    index_count++;
+	    Puttama(0, rinkx + 16, rinky, &sprite->data[index_count]);
+	    index_count++;
+	} else {
+	    length = 2;
+	    smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	    smanager->setup_outputData();
 	}
     }
-  if((p->dt1 > 180) && (p->dt1 <= 240))
-  {
-      if(p->dt1 % 2 == 1)
-      {
-	  rinkf2 = 1;
-	  Puttama(2, rinkx - 16, p->y - 32);
-	  Puttama(3, rinkx + 32 - 16, p->y - 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)
-	{
+
+    if ((p->dt1 > 70) && (p->dt1 <= 180)) {
+	length = 2;
+	smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	smanager->setup_outputData();
+    }
+
+    if ((p->dt1 > 180) && (p->dt1 <= 240)) {
+	if (p->dt1 % 2 == 1) {
+	    length = 4;
+	    smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	    smanager->setup_outputData();
+	    
+	    ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 6);
+
+	    rinkf2 = 1;
+	    Puttama(2, rinkx - 16, p->y - 32, &sprite->data[index_count]);
+	    index_count++;
+	    Puttama(3, rinkx + 32 - 16, p->y - 32, &sprite->data[index_count]);
+	    index_count++;
+	} else {
+	    length = 2;
+	    smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	    smanager->setup_outputData();
+
+	    rinkf2 = 2;
+	}
+    }
+
+    if (p->dt1 > 240) {
+	rinkf2 = 2;
+    }
+
+    if ((p->dt1 > 240) && (p->dt1 <= 400)) {
+	length = 4;
+	smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	smanager->setup_outputData();
+	
+	ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 6);
+
+	count++;
+	PutSprite(count, rinkx - 16, rinky + 32, 58 + p->dt1 % 4, &sprite->data[index_count]);
+	index_count++;
+
+	if (p->dt1 > 300) {
+	    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;
+	    }
+	    p->x += p->vx;
+	    rinkx = p->x;
+	    rinky = p->y;
+	    Puttama(4, rinkx - 8, rinky + 16, &sprite->data[index_count]);
+	    index_count++;
+	}
+    }
+
+    if (p->dt1 > 400) {
+	length = 2;
+	smanager->set_outputSize(6, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
+	smanager->setup_outputData();
+    }
+    
+    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;
 	}
-	else if(jiki.x + 15 - rinkx > 5)
-	{
-	    p->vx = +1;
-	}
-	else p->vx = 0;
 	p->x += p->vx;
 	rinkx = p->x;
 	rinky = p->y;
-	Puttama(4, rinkx - 8, rinky + 16);
     }
-  if((p->dt1 > 400) && (p->dt1 <= 500))
-  {
-      rinkf2 = 4;
-      if(jiki.x + 15 - rinkx > 5)
-      {
-	  p->vx = -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;
 	}
-      else if(jiki.x + 15 - rinkx > 5)
-      {
-	  p->vx = +1;
-      }
-      else p->vx = 0;
-      p->x += p->vx;
-      rinkx = p->x;
-      rinky = p->y;
-  }
-  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;
-      p->x += p->vx;
-      rinkx = p->x;
-      rinky = p->y;
-  }
-  if(p->dt1 > 600)
-  {
-      rinkf2 = 0;
-      p->dt1 = 0;
-  }
-  fastebos++;
-  p->dt1++;
-  count++;
-  DefSpriteEx(54, 16, 32);
-  PutSpriteEx(54, p->x, p->y, 2, 2, 1);
-  return 0;
+	p->x += p->vx;
+	rinkx = p->x;
+	rinky = p->y;
+    }
+    if (p->dt1 > 600) {
+	rinkf2 = 0;
+	p->dt1 = 0;
+    }
+    CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0);
+    int *w_count = (int*)smanager->get_output(wbuf, 1);
+    int *w_fastebos = (int*)smanager->get_output(wbuf, 2);
+    int *w_rinkx = (int*)smanager->get_output(wbuf, 3);
+    int *w_rinky = (int*)smanager->get_output(wbuf, 4);
+    int *w_rinkf2 = (int*)smanager->get_output(wbuf, 5);
+    ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 6);
+    sprite->flag = true;
+    sprite->length = length;
+    
+    fastebos++;
+    p->dt1++;
+    count++;
+
+    DefSpriteEx(54, 16, 32, &sprite->data[index_count]);
+    index_count++;
+    PutSpriteEx(54, p->x, p->y, 2, 2, 1, &sprite->data[index_count]);
+
+    *q = *p;
+    *w_count = count;
+    *w_fastebos = fastebos;
+    *w_rinkx = rinkx;
+    *w_rinky = rinky;
+    *w_rinkf2 = rinkf2;
+    return 0;
 }