diff webGL/dandy/resources/#Character_state.js# @ 17:2018ad94fd9b

upload sound.js
author NOBUYASU Oshiro
date Mon, 26 Jul 2010 20:19:36 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webGL/dandy/resources/#Character_state.js#	Mon Jul 26 20:19:36 2010 +0900
@@ -0,0 +1,696 @@
+
+function state_update()
+{
+    for(var i = 0; Boolean(active_chara_list.enemy[i]) ; i++)
+	{
+	    var p = active_chara_list.enemy[i];
+	    if(p.flag == true)
+		{
+		    p = p.state(p);
+		}
+	}
+}
+
+noaction = function no_action(p)
+{
+    p.state = noaction;
+    return p;
+}
+
+delete_chara = function delete_character( p )
+{
+    p.state = noaction;
+    p.flag = false;
+    return p;
+}
+
+chara_state0 = function character_state0( p )
+{
+    p.x += p.vx;
+    p.y += p.vy;
+    p.state = chara_state0;
+    return p;
+}
+
+chara_state1 = function character_state1( p )
+{
+    p.x -= p.vx;
+    p.y -= p.vy;
+    p.state = chara_state1;
+    return p;
+}
+
+chara_state2 = function character_state2( p )
+{
+    p.x -= 0.25;
+    p.y += p.vy;
+    p.state = chara_state2;
+    return p;
+}
+
+chara_state3 = function character_state3( p )
+{
+    p.x += p.vx;
+    p.y += p.vy;
+    if((p.dt1 == 60) ||
+       (p.dt1 == 90) ||
+       (p.dt1 == 30))
+	{
+	    Puttama(0, p.x, p.y);
+	}
+    p.dt1++;
+    p.state = chara_state3;
+    return p;
+}
+
+chara_state4 = function character_state4(p)
+{
+    p.y += p.vy;
+    p.x += p.vx;
+    if(p.y < jiki.y && p.y + 16 > jiki.y)
+	{
+	    p.vy = -2 * d_y;
+	    p.vx = ((jiki.x > p.x ) ? 4*d_x : -4*d_x);
+	    p.state = chara_state7;
+	}
+    else p.state = chara_state4;
+    return p;
+}
+
+chara_state5 = function character_state5(p)
+{
+    p.y += p.vy;
+    p.x += p.vx;
+    if(p.y + 96 < jiki.y
+       && p.y + 128 > jiki.y)
+	{
+	    p.vy = -2;
+	    p.vx = ((jiki.x > p.x) ? 4 : -4);
+	    p.state = chara_state0;
+	}
+    else p.state = chara_state5;
+    //PutSprite(count, p.x, p.y, p.charano);                                                                           
+    return p;
+}
+
+chara_state6 = function character_state6(p)
+{
+    p.y += p.vy;
+    p.x += p.vx;
+    if(p.y + 96 < jiki.y
+       && p.y + 128 > jiki.y)
+	{
+	    p.vy = 2;
+	    p.vx = ((jiki.x > p.x) ? 4 : -4);
+	    p.state = chara_state0;
+	}
+    else p.state = chara_state6;
+    //PutSprite(count, p.x, p.y, p.charano);                                                                           
+    return p;
+}
+
+chara_state7 = function character_state7(p)
+{
+    p.x += p.vx;
+    p.y += p.vy;
+    if((p.dt1 == 60) || (p.dt1 == 90)
+       || (p.dt1 == 30))
+	{
+	    Puttama(1, p.x, p.y);
+	}
+    p.dt1++;
+    p.state = chara_state7;
+    return p;
+}
+
+// stage1 boss patern
+chara_state8 = function character_state8( p )
+{
+    if(p.y < 520*d_y)
+	{
+	    p.y += p.vy;
+	    tekino0 = p;
+	    count++;
+	    /*
+		 kyeenmyno = p;
+		 DefSpriteEx(p.charano, 16*4, 32*4);
+		 PutSpriteEx(p.charano, (p.x * 4), (p.y * 4), 0.2, 0.2, 1);
+		 */
+	    p.dt1 = 512;
+	    p.s = 0.125;
+	    p.state = chara_state8;
+	    return p;
+	}
+    p.state = chara_state9;
+    return p;
+}
+
+chara_state9 = function character_state9( p )
+{
+    if(p.s <= 2)
+	{
+	    p.s += 0.05
+	    p.y -= 12*d_y;
+	    count++;
+	    //	    DefSpriteEx(54, 16*4, 32*4);
+	    //	    PutSpriteEx(54, (p.x * 4), (p.y * 4), p.x, p.x, 1);
+	    p.state = chara_state9;
+	    return p;
+	}
+    count++;
+    rinkx = p.x/d_x;
+    rinky = p.y/d_y;
+	//    DefSpriteEx(54, 16,32);
+	//    PutSpriteEx(54, p.x, p.y, p.s, p.s, 1);
+	//    Putenemy(5, rinkx - 16, rinky -16, 1, 0, chara_state10);
+	//    Putenemy(5, rinkx - 16, rinky -16, -1, 0, chara_state10);
+	
+    PutBoss(1, rinkx - 16*d_x, rinky -16*d_y, 1, 0, chara_state10);
+    PutBoss(1, rinkx - 16*d_x, rinky -16*d_y, -1, 0, chara_state10);
+	
+    p.state = chara_state11;
+    p.dt1 = 8192;
+	
+    return p;
+}
+
+chara_state10 = function character_state10( p )
+{
+    if(p.dt1 < 48)
+	{
+	    p.x += p.vx;
+	    p.y += p.vy;
+	    p.dt1++;
+	    p.state = chara_state10;
+	    return p;
+	}
+    rinkf1 = 1;
+    p.dt1 = rinkx * d_x;
+    p.dt2 = rinky * d_y;
+    p.state = chara_state13;
+    return p;
+}
+
+chara_state11 = function character_state11( p )
+{
+    if(rinkf1 == 0)
+	{
+	    count++;
+	    //	    DefSpriteEx(54, 16, 32);
+	    //	    PutSpriteEx(54, p.x, p.y, p.s, p.s, 1);
+	    
+	    p.state = chara_state11;
+	    return p;
+	}
+    p.dt1 = 0;
+    p.dt2 = 0;
+    p.state = chara_state12;
+    return p;
+}
+
+chara_state12 = function character_state12( p )
+{
+    if(fastebos > 60*60)
+	{
+	    //	    if(p.y > 70+boss[1].h)
+	    if(p.y > (240+32)*d_y)
+		{
+		    p.state = delete_chara;
+		}
+		p.y += 0.3*d_y;
+	    rinky += 0.3*d_y;
+	    count++;
+	    //	    DefSpriteEx(54, 16, 32);
+	    //	    PutSpriteEx(54, p.x, p.y, 2, 2, 1);
+ 	    p.state = chara_state12;
+	    return p;
+	}
+    if(p.dt1 <= 60)
+	{
+	    if(jiki.x + 15*d_x -rinkx < -5*d_x)
+		{
+		    p.vx = -0.3 * d_x;
+		}
+	    else if(jiki.x + 15*d_x - rinkx > 5*d_x)
+		{
+		    p.vx = +0.8 * d_x;
+		}
+	    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/d_x - 16 , rinky/d_y);
+		    Puttama(0, rinkx/d_x, rinky/d_y);
+		    Puttama(0, rinkx/d_x + 16, rinky/d_y);
+		}
+	}
+    if((p.dt1 > 180) && (p.dt1 <= 240))
+	{
+	    if(p.dt1 % 2 == 1)
+		{
+		    rinkf2 = 1;
+		    Puttama(2, rinkx/d_x - 16, p.y/d_y -32);
+		    Puttama(3, rinkx/d_x + 32 - 16, p.y/d_y - 32);
+		}
+	    else 
+		{
+		    rinkf2 = 2;
+		}
+	}
+    if(p.df1 > 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*d_x - rinkx < -5*d_x)
+		{
+		    p.vx = -1 * d_x;
+		}
+	    else if(jiki.x + 15*d_x - rinkx > 5*d_x)
+		{
+		    p.vx = +1 * d_x;
+		}
+	    else p.vx = 0;
+	    p.x += p.vx;
+	    rinkx = p.x;
+	    rinky = p.y;
+	    Puttama(4, rinkx/d_x - 8, rinky/d_y + 16);
+	}
+    if((p.dt1 > 400) && (p.dt1 <= 500))
+	{
+	    rinkf2 = 4;
+	    if(jiki.x + 15*d_x - rinkx > 5*d_x)
+		{
+		    p.vx = -1*d_x;
+		}
+	    else if(jiki.x + 15*d_x - rinkx > 5*d_x)
+		{
+		    p.vx = +1*d_x;
+		}
+	    else p.vx = 0;
+	    p.x += p.vx;
+	    rinkx = p.x;
+	    rinky = p.y;
+	}
+    if(p.dt1 > 500)
+	{
+	    rinkf2 = 5;
+	    if(jiki.x + 15*d_x - rinkx < -5*d_x)
+		{
+		    p.vx = -1*d_x;
+		}
+	    else if(jiki.x + 15*d_x - rinkx > 5*d_x) 
+		{
+		    p.vx = +1*d_x;
+		}
+	    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);
+    p.state = chara_state12;    
+    return p;
+	
+}
+
+chara_state13 = function character_state13(p)
+{
+    if(tekino0.flag == false)
+	{
+	    Bom(p.x, p.y);
+	    p.flag = false;
+	    p.state = delete_chara;
+	    p.collision = noaction;
+	    return p;
+	}
+    p.x += rinkx*d_x - p.dt1*d_x;
+    p.y += rinky*d_y -p.dt2*d_y;
+    p.dt1 = rinkx;
+    p.dt2 = rinky;
+    if(rinkf2 == 1)
+	{
+	    if(p.x > rinkx * d_x)
+		{
+		    Puttama(2, p.x/d_x + 32, p.y/d_y);
+		}
+	}
+    if(rinkf2 == 4)
+	{
+	    count++;
+	    //	    PutSprite(count, p.x, p.y + 56, 58+filpcount % 4);
+	    //	    PutBoss(count, p.x, p.y + 56, 58+filpcount % 4);
+	    //	    PutBoss(2, rinkx/d_x - 16, rinky/d_y -16, 1, 0, chara_state10);
+	}
+    if(rinkf2 == 5)
+	{
+	    if(p.x > rinkx*d_x)
+		{
+		    Puttama(5, p.x/d_x + 8 , p.y/d_y + 24);
+		}
+	    if(p.x < rinkx*d_x)
+		{
+		    Puttama(5, p.x/d_x + 8, p.y/d_y + 24);
+		}
+	}
+    return p;
+}
+
+
+chara_state20 = function character_state20(p)
+{
+    p.x += p.vx;
+    p.y += p.vy;
+    p.vx -= 0.5*d_x;
+    p.vy += 0.4*d_y;
+    return p;
+}
+
+chara_state21 = function character_state21(p)
+{
+    p.x += p.vx;
+    p.y += p.vy;
+    p.vx += 0.5*d_x;
+    p.vy += 0.4*d_y;
+    return p;
+}
+
+chara_state22 = function character_state22(p)
+{
+    sf = Math.random() % 4;
+    sf = parseInt(sf);
+    if((sf == 0) || (sf == 1))
+	{
+	    p.x = -35*d_x;
+	    p.y = Math.random() % (120 - 35)*d_y;
+	    p.vx = (Math.random() % 4 + 1)*d_x;
+	    p.vy = ( Math.random() % 3 + 1 )*d_y;
+	    p.state = chara_state23;
+	}
+    if((sf == 2))
+	{
+	    p.x = ( Math.random() % 290 )*d_x;
+	    p.y = -30 * d_y;
+	    p.vx = ( Math.random() % 3 - 1 )*d_x;
+	    p.vy = ( (Math.random() % 4 + 1) )*d_y;
+	    p.state = chara_state23;
+	}
+    if(sf == 3)
+	{
+	    p.x = ( 320 )*d_x;
+	    p.y = ( Math.random() % (120 - 35) )*d_y;
+	    p.vx = ( (Math.random() % 4 + 1) * -1 ) *d_x;
+	    p.vy = ( Math.random() % 3 -1 ) *d_y;
+	    p.state = chara_state23;
+	}
+    return p;
+}
+chara_state23 = function character_state32(p)
+{
+    /*’ËÜ’Åö’¤Ï’¤³’¤Î 2 ’¹Ô’¤À’¤±
+    p=asteroid(p);
+    return p;
+    */
+
+    //
+    p.x += p.vx;
+    p.y += p.vy;
+    p.state = chara_state23;
+    return p;
+}
+
+chara_state24 = function(p)
+{
+    //    kyeenemyno = p;
+    tekino0 = 0;
+
+    //global’¤Ç’Àë’¸À
+    enemy_part1 = new Character();
+    enemy_part2 = new Character();
+    enemy_part3 = new Character();
+    enemy_part4 = new Character();
+    enemy_part5 = new Character();
+
+    /*
+    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;
+    p.state = chara_state25;
+    return p;
+}
+
+chara_state25 = function(p)
+{
+    if(p.dt1 <= 360)
+	{
+	    p.x = (Mycos(p.dt1) * 30 / SANKAKU + 82 + 32) *d_x;
+	    p.y = (Mysin(p.dt1) * 30 / SANKAKU + 30)*d_y;
+	}
+    if(p.dt1 > 360)
+	{
+	    p.x = (Mycos(p.dt1) * 30 * -1 /SANKAKU + 142 + 32) * d_x;
+	    p.y = (Mysin(p.dt1) * 30 / SANKAKU + 30) * d_y;
+	}
+    count++;
+    //    PutSprite(count, p.x - 42, p.y, 64);
+    amari = Math.random() % 160;
+    if((amari == 1) && (enemy_part5.flag == true))
+	{
+	    p.state = chara_state26;
+	    rinkf1 = 1;
+	}
+    if((amari == 2) && (enemy_part1.flag == true))
+	{
+	    p.state = chara_state27;
+	    rinkf1 = 5;
+	    rinkx = 0;
+	    return p;
+	}
+    if( (enemy_part1.flag != true) && (enemy_part5.flag == true))
+	{
+	    p.state = chara_state28;
+	}
+    p.dt1 += 3;
+    if(p.dt1 == 720)
+	{
+	    p.dt1 = 0;
+	}
+    return p;
+}
+
+chara_state26 = function(p)
+{
+    if((p.dt2 > 50) && (p.dt2 < 100))
+	{
+	    rinkf1 = 2;
+	}
+    if(p.dt2 > 100)
+	{
+	    rinkf1 = 3;
+	}
+    if(p.dt2 == 400)
+	{
+	    rinkf1 = 4;
+	}
+    count++;
+    //    PutSprite(count, p.x - 42, p.y, 64);
+    if(p.dt2 == 401)
+	{
+	    p.dt2 = 0;
+	    rinkf1 = 0;
+	    p.state = chara_state25;
+	    return p;
+	}
+    p.dt2++;
+    return p;
+}
+
+chara_state27 = function(p)
+{
+    if((p.dt2 > 50) && (p.dt2 < 60) && (p.x > -24) && (p.y > -24))
+	{
+	    rinkf1 = 6;
+	    rinkx -= 4;
+	    p.x -= 4;
+	    p.y -= 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++;
+		    p.x++;
+		    p.y++;
+		}
+	}
+    count++;
+    //    PutSprite(count, p.x - 32, p.y, 6);
+    if(rinkf1 == 12)
+	{
+	    p.dt2 = 0;
+	    rinkf1 = 0;
+	    rinkx = 0;
+	    p.state = chara_state25;
+	    return p;
+	}
+    p.dt2++;
+    return p;
+}
+
+chara_state28 = function(p)
+{
+    if (p.dt1 <= 360)
+	{
+	    p.x = Mycos(p.dt1) * 30 / SANKAKU + 82 + 32;
+	    p.y = Mysin(p.dt1) * 30 / SANKAKU + 30;
+	}
+    if (p.dt1 > 360)
+	{
+	    p.x = Mycos(p.dt1) * 30 * -1 / SANKAKU + 142 + 32;
+	    p.y = Mysin(p.dt1) * 30 / SANKAKU + 30;
+	}
+    count++;
+    //    PutSprite(count, p.x - 42, p.y, 64);
+    if (p.dt1 % 30 == 3)
+	{
+	    Putenemy(24, p.x + 14,
+		     p.y + 14,
+		     (Math.random() % 5 + 0.5) * (Math.random() % 2 ==
+					   1 ? -1 : 1),
+		     (Math.random() % 5 + 0.5) * (Math.random() % 2 ==
+					   1 ? -1 : 1), chara_state29);
+	}
+    p.dt1 += 3;
+    return p;
+}
+
+chara_state29 = function(p)
+{
+    p.x += p.vx;
+    p.y += p.vy;
+    if(p.dt1 % 18 == 1)
+	{
+	    Puttama(0, p.x, p.y);
+	}
+    p.dt1++;
+    return p;
+}
+
+
+
+
+
+chara_state30 = function(p)
+{
+    p.x = p.x - 32 * d_x;
+    p.y = p.y;
+    return p;
+}
+
+
+chara_state31 = function(p)
+{
+
+
+
+    return p;
+}
+
+
+
+chara_state400 = function character_state400(p)
+{
+    //    p.vy++;
+    p.vy += 1*d_y;
+    p.y += p.vy / 4 * d_y;
+    p.state = chara_state400;
+    return p;
+}
+
+chara_state401 = function character_state401(p)
+{
+    {
+		p.vx++;
+		//		p.vx += 1*d_x;
+		p.x += p.vx / 8 * d_x;
+		if (p.x > (jiki.x - 32 * d_x))
+	    {
+			p.vy--;
+	    }
+		p.y += p.vy / 8 * d_y;
+		if (p.dt1 % 50 == 37)
+	    {
+			Puttama(1, p.x + 8, p.y + 24);
+	    }
+		p.dt1++;
+		return p;
+    }
+}
+
+chara_state402 = function character_state402(p)
+{
+    p.vx--;
+    p.x += p.vx / 8 * d_x;
+    if(p.x < (jiki.x + 32 * d_x))
+	{
+	    p.vy--;
+	}
+    p.y += p.vy / 8 * d_y;
+    if(p.dt1 % 50 == 37)
+	{
+	    Puttama(1, p.x + 8, p.y + 42);
+	}
+    p.dt1++;
+    return p;
+}
\ No newline at end of file