comparison 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
comparison
equal deleted inserted replaced
16:527eac9a7d0b 17:2018ad94fd9b
1
2 function state_update()
3 {
4 for(var i = 0; Boolean(active_chara_list.enemy[i]) ; i++)
5 {
6 var p = active_chara_list.enemy[i];
7 if(p.flag == true)
8 {
9 p = p.state(p);
10 }
11 }
12 }
13
14 noaction = function no_action(p)
15 {
16 p.state = noaction;
17 return p;
18 }
19
20 delete_chara = function delete_character( p )
21 {
22 p.state = noaction;
23 p.flag = false;
24 return p;
25 }
26
27 chara_state0 = function character_state0( p )
28 {
29 p.x += p.vx;
30 p.y += p.vy;
31 p.state = chara_state0;
32 return p;
33 }
34
35 chara_state1 = function character_state1( p )
36 {
37 p.x -= p.vx;
38 p.y -= p.vy;
39 p.state = chara_state1;
40 return p;
41 }
42
43 chara_state2 = function character_state2( p )
44 {
45 p.x -= 0.25;
46 p.y += p.vy;
47 p.state = chara_state2;
48 return p;
49 }
50
51 chara_state3 = function character_state3( p )
52 {
53 p.x += p.vx;
54 p.y += p.vy;
55 if((p.dt1 == 60) ||
56 (p.dt1 == 90) ||
57 (p.dt1 == 30))
58 {
59 Puttama(0, p.x, p.y);
60 }
61 p.dt1++;
62 p.state = chara_state3;
63 return p;
64 }
65
66 chara_state4 = function character_state4(p)
67 {
68 p.y += p.vy;
69 p.x += p.vx;
70 if(p.y < jiki.y && p.y + 16 > jiki.y)
71 {
72 p.vy = -2 * d_y;
73 p.vx = ((jiki.x > p.x ) ? 4*d_x : -4*d_x);
74 p.state = chara_state7;
75 }
76 else p.state = chara_state4;
77 return p;
78 }
79
80 chara_state5 = function character_state5(p)
81 {
82 p.y += p.vy;
83 p.x += p.vx;
84 if(p.y + 96 < jiki.y
85 && p.y + 128 > jiki.y)
86 {
87 p.vy = -2;
88 p.vx = ((jiki.x > p.x) ? 4 : -4);
89 p.state = chara_state0;
90 }
91 else p.state = chara_state5;
92 //PutSprite(count, p.x, p.y, p.charano);
93 return p;
94 }
95
96 chara_state6 = function character_state6(p)
97 {
98 p.y += p.vy;
99 p.x += p.vx;
100 if(p.y + 96 < jiki.y
101 && p.y + 128 > jiki.y)
102 {
103 p.vy = 2;
104 p.vx = ((jiki.x > p.x) ? 4 : -4);
105 p.state = chara_state0;
106 }
107 else p.state = chara_state6;
108 //PutSprite(count, p.x, p.y, p.charano);
109 return p;
110 }
111
112 chara_state7 = function character_state7(p)
113 {
114 p.x += p.vx;
115 p.y += p.vy;
116 if((p.dt1 == 60) || (p.dt1 == 90)
117 || (p.dt1 == 30))
118 {
119 Puttama(1, p.x, p.y);
120 }
121 p.dt1++;
122 p.state = chara_state7;
123 return p;
124 }
125
126 // stage1 boss patern
127 chara_state8 = function character_state8( p )
128 {
129 if(p.y < 520*d_y)
130 {
131 p.y += p.vy;
132 tekino0 = p;
133 count++;
134 /*
135 kyeenmyno = p;
136 DefSpriteEx(p.charano, 16*4, 32*4);
137 PutSpriteEx(p.charano, (p.x * 4), (p.y * 4), 0.2, 0.2, 1);
138 */
139 p.dt1 = 512;
140 p.s = 0.125;
141 p.state = chara_state8;
142 return p;
143 }
144 p.state = chara_state9;
145 return p;
146 }
147
148 chara_state9 = function character_state9( p )
149 {
150 if(p.s <= 2)
151 {
152 p.s += 0.05
153 p.y -= 12*d_y;
154 count++;
155 // DefSpriteEx(54, 16*4, 32*4);
156 // PutSpriteEx(54, (p.x * 4), (p.y * 4), p.x, p.x, 1);
157 p.state = chara_state9;
158 return p;
159 }
160 count++;
161 rinkx = p.x/d_x;
162 rinky = p.y/d_y;
163 // DefSpriteEx(54, 16,32);
164 // PutSpriteEx(54, p.x, p.y, p.s, p.s, 1);
165 // Putenemy(5, rinkx - 16, rinky -16, 1, 0, chara_state10);
166 // Putenemy(5, rinkx - 16, rinky -16, -1, 0, chara_state10);
167
168 PutBoss(1, rinkx - 16*d_x, rinky -16*d_y, 1, 0, chara_state10);
169 PutBoss(1, rinkx - 16*d_x, rinky -16*d_y, -1, 0, chara_state10);
170
171 p.state = chara_state11;
172 p.dt1 = 8192;
173
174 return p;
175 }
176
177 chara_state10 = function character_state10( p )
178 {
179 if(p.dt1 < 48)
180 {
181 p.x += p.vx;
182 p.y += p.vy;
183 p.dt1++;
184 p.state = chara_state10;
185 return p;
186 }
187 rinkf1 = 1;
188 p.dt1 = rinkx * d_x;
189 p.dt2 = rinky * d_y;
190 p.state = chara_state13;
191 return p;
192 }
193
194 chara_state11 = function character_state11( p )
195 {
196 if(rinkf1 == 0)
197 {
198 count++;
199 // DefSpriteEx(54, 16, 32);
200 // PutSpriteEx(54, p.x, p.y, p.s, p.s, 1);
201
202 p.state = chara_state11;
203 return p;
204 }
205 p.dt1 = 0;
206 p.dt2 = 0;
207 p.state = chara_state12;
208 return p;
209 }
210
211 chara_state12 = function character_state12( p )
212 {
213 if(fastebos > 60*60)
214 {
215 // if(p.y > 70+boss[1].h)
216 if(p.y > (240+32)*d_y)
217 {
218 p.state = delete_chara;
219 }
220 p.y += 0.3*d_y;
221 rinky += 0.3*d_y;
222 count++;
223 // DefSpriteEx(54, 16, 32);
224 // PutSpriteEx(54, p.x, p.y, 2, 2, 1);
225 p.state = chara_state12;
226 return p;
227 }
228 if(p.dt1 <= 60)
229 {
230 if(jiki.x + 15*d_x -rinkx < -5*d_x)
231 {
232 p.vx = -0.3 * d_x;
233 }
234 else if(jiki.x + 15*d_x - rinkx > 5*d_x)
235 {
236 p.vx = +0.8 * d_x;
237 }
238 else p.vx = 0;
239 rinkx = p.x;
240 rinky = p.y;
241 }
242 if((p.dt1 > 60) && (p.dt1 <= 70))
243 {
244 if(p.dt1 % 2 == 1)
245 {
246 Puttama(0, rinkx/d_x - 16 , rinky/d_y);
247 Puttama(0, rinkx/d_x, rinky/d_y);
248 Puttama(0, rinkx/d_x + 16, rinky/d_y);
249 }
250 }
251 if((p.dt1 > 180) && (p.dt1 <= 240))
252 {
253 if(p.dt1 % 2 == 1)
254 {
255 rinkf2 = 1;
256 Puttama(2, rinkx/d_x - 16, p.y/d_y -32);
257 Puttama(3, rinkx/d_x + 32 - 16, p.y/d_y - 32);
258 }
259 else
260 {
261 rinkf2 = 2;
262 }
263 }
264 if(p.df1 > 240)
265 {
266 rinkf2 = 2;
267 }
268 if((p.dt1 > 240) && (p.dt1 <= 400))
269 {
270 count++;
271 // PutSprite(count, rinkx - 16, rinky + 32, 58 + p.dt1 %4)
272 }
273 if((p.dt1 > 300) && (p.dt1 <= 400))
274 {
275 rinkf2 = 3;
276 if(jiki.x + 15*d_x - rinkx < -5*d_x)
277 {
278 p.vx = -1 * d_x;
279 }
280 else if(jiki.x + 15*d_x - rinkx > 5*d_x)
281 {
282 p.vx = +1 * d_x;
283 }
284 else p.vx = 0;
285 p.x += p.vx;
286 rinkx = p.x;
287 rinky = p.y;
288 Puttama(4, rinkx/d_x - 8, rinky/d_y + 16);
289 }
290 if((p.dt1 > 400) && (p.dt1 <= 500))
291 {
292 rinkf2 = 4;
293 if(jiki.x + 15*d_x - rinkx > 5*d_x)
294 {
295 p.vx = -1*d_x;
296 }
297 else if(jiki.x + 15*d_x - rinkx > 5*d_x)
298 {
299 p.vx = +1*d_x;
300 }
301 else p.vx = 0;
302 p.x += p.vx;
303 rinkx = p.x;
304 rinky = p.y;
305 }
306 if(p.dt1 > 500)
307 {
308 rinkf2 = 5;
309 if(jiki.x + 15*d_x - rinkx < -5*d_x)
310 {
311 p.vx = -1*d_x;
312 }
313 else if(jiki.x + 15*d_x - rinkx > 5*d_x)
314 {
315 p.vx = +1*d_x;
316 }
317 else p.vx = 0;
318 p.x += p.vx;
319 rinkx = p.x;
320 rinky = p.y;
321 }
322 if(p.dt1 > 600)
323 {
324 rinkf2 = 0;
325 p.dt1 = 0;
326 }
327 fastebos++;
328 p.dt1++;
329 count++;
330 // DefSpriteEx(54, 16, 32);
331 // PutSpriteEx(54, p.x, p.y, 2, 2, 1);
332 p.state = chara_state12;
333 return p;
334
335 }
336
337 chara_state13 = function character_state13(p)
338 {
339 if(tekino0.flag == false)
340 {
341 Bom(p.x, p.y);
342 p.flag = false;
343 p.state = delete_chara;
344 p.collision = noaction;
345 return p;
346 }
347 p.x += rinkx*d_x - p.dt1*d_x;
348 p.y += rinky*d_y -p.dt2*d_y;
349 p.dt1 = rinkx;
350 p.dt2 = rinky;
351 if(rinkf2 == 1)
352 {
353 if(p.x > rinkx * d_x)
354 {
355 Puttama(2, p.x/d_x + 32, p.y/d_y);
356 }
357 }
358 if(rinkf2 == 4)
359 {
360 count++;
361 // PutSprite(count, p.x, p.y + 56, 58+filpcount % 4);
362 // PutBoss(count, p.x, p.y + 56, 58+filpcount % 4);
363 // PutBoss(2, rinkx/d_x - 16, rinky/d_y -16, 1, 0, chara_state10);
364 }
365 if(rinkf2 == 5)
366 {
367 if(p.x > rinkx*d_x)
368 {
369 Puttama(5, p.x/d_x + 8 , p.y/d_y + 24);
370 }
371 if(p.x < rinkx*d_x)
372 {
373 Puttama(5, p.x/d_x + 8, p.y/d_y + 24);
374 }
375 }
376 return p;
377 }
378
379
380 chara_state20 = function character_state20(p)
381 {
382 p.x += p.vx;
383 p.y += p.vy;
384 p.vx -= 0.5*d_x;
385 p.vy += 0.4*d_y;
386 return p;
387 }
388
389 chara_state21 = function character_state21(p)
390 {
391 p.x += p.vx;
392 p.y += p.vy;
393 p.vx += 0.5*d_x;
394 p.vy += 0.4*d_y;
395 return p;
396 }
397
398 chara_state22 = function character_state22(p)
399 {
400 sf = Math.random() % 4;
401 sf = parseInt(sf);
402 if((sf == 0) || (sf == 1))
403 {
404 p.x = -35*d_x;
405 p.y = Math.random() % (120 - 35)*d_y;
406 p.vx = (Math.random() % 4 + 1)*d_x;
407 p.vy = ( Math.random() % 3 + 1 )*d_y;
408 p.state = chara_state23;
409 }
410 if((sf == 2))
411 {
412 p.x = ( Math.random() % 290 )*d_x;
413 p.y = -30 * d_y;
414 p.vx = ( Math.random() % 3 - 1 )*d_x;
415 p.vy = ( (Math.random() % 4 + 1) )*d_y;
416 p.state = chara_state23;
417 }
418 if(sf == 3)
419 {
420 p.x = ( 320 )*d_x;
421 p.y = ( Math.random() % (120 - 35) )*d_y;
422 p.vx = ( (Math.random() % 4 + 1) * -1 ) *d_x;
423 p.vy = ( Math.random() % 3 -1 ) *d_y;
424 p.state = chara_state23;
425 }
426 return p;
427 }
428 chara_state23 = function character_state32(p)
429 {
430 /*’ËÜ’Åö’¤Ï’¤³’¤Î 2 ’¹Ô’¤À’¤±
431 p=asteroid(p);
432 return p;
433 */
434
435 //
436 p.x += p.vx;
437 p.y += p.vy;
438 p.state = chara_state23;
439 return p;
440 }
441
442 chara_state24 = function(p)
443 {
444 // kyeenemyno = p;
445 tekino0 = 0;
446
447 //global’¤Ç’Àë’¸À
448 enemy_part1 = new Character();
449 enemy_part2 = new Character();
450 enemy_part3 = new Character();
451 enemy_part4 = new Character();
452 enemy_part5 = new Character();
453
454 /*
455 enemy_part1 = p.next;
456 enemy_part2 = enemy_part1.next;
457 enemy_part3 = enemy_part2.next;
458 enemy_part4 = enemy_part3.next;
459 enemy_part5 = enemy_part4.next;
460 */
461 rinkx = 0;
462 rinky = 0;
463 rinkf1 = 0;
464 rinkf2 = 0;
465 p.state = chara_state25;
466 return p;
467 }
468
469 chara_state25 = function(p)
470 {
471 if(p.dt1 <= 360)
472 {
473 p.x = (Mycos(p.dt1) * 30 / SANKAKU + 82 + 32) *d_x;
474 p.y = (Mysin(p.dt1) * 30 / SANKAKU + 30)*d_y;
475 }
476 if(p.dt1 > 360)
477 {
478 p.x = (Mycos(p.dt1) * 30 * -1 /SANKAKU + 142 + 32) * d_x;
479 p.y = (Mysin(p.dt1) * 30 / SANKAKU + 30) * d_y;
480 }
481 count++;
482 // PutSprite(count, p.x - 42, p.y, 64);
483 amari = Math.random() % 160;
484 if((amari == 1) && (enemy_part5.flag == true))
485 {
486 p.state = chara_state26;
487 rinkf1 = 1;
488 }
489 if((amari == 2) && (enemy_part1.flag == true))
490 {
491 p.state = chara_state27;
492 rinkf1 = 5;
493 rinkx = 0;
494 return p;
495 }
496 if( (enemy_part1.flag != true) && (enemy_part5.flag == true))
497 {
498 p.state = chara_state28;
499 }
500 p.dt1 += 3;
501 if(p.dt1 == 720)
502 {
503 p.dt1 = 0;
504 }
505 return p;
506 }
507
508 chara_state26 = function(p)
509 {
510 if((p.dt2 > 50) && (p.dt2 < 100))
511 {
512 rinkf1 = 2;
513 }
514 if(p.dt2 > 100)
515 {
516 rinkf1 = 3;
517 }
518 if(p.dt2 == 400)
519 {
520 rinkf1 = 4;
521 }
522 count++;
523 // PutSprite(count, p.x - 42, p.y, 64);
524 if(p.dt2 == 401)
525 {
526 p.dt2 = 0;
527 rinkf1 = 0;
528 p.state = chara_state25;
529 return p;
530 }
531 p.dt2++;
532 return p;
533 }
534
535 chara_state27 = function(p)
536 {
537 if((p.dt2 > 50) && (p.dt2 < 60) && (p.x > -24) && (p.y > -24))
538 {
539 rinkf1 = 6;
540 rinkx -= 4;
541 p.x -= 4;
542 p.y -= 4;
543 }
544 if(p.dt2 == 80)
545 {
546 rinkf1 = 7;
547 }
548 if(p.dt2 == 81)
549 {
550 rinkf1 = 8;
551 }
552 if(p.dt2 == 124)
553 {
554 rinkf1 = 9;
555 }
556 if(p.dt2 == 400)
557 {
558 rinkf1 = 10;
559 }
560 if(p.dt2 == 444)
561 {
562 rinkf1 = 11;
563 }
564 if(p.dt2 == 500)
565 {
566 rinkf1 = 12;
567 }
568 if((p.dt2 > 80) && (p.dt2 < 200))
569 {
570 if((rinkx != 0) && (p.dt2 % 2 == 1))
571 {
572 rinkx++;
573 p.x++;
574 p.y++;
575 }
576 }
577 count++;
578 // PutSprite(count, p.x - 32, p.y, 6);
579 if(rinkf1 == 12)
580 {
581 p.dt2 = 0;
582 rinkf1 = 0;
583 rinkx = 0;
584 p.state = chara_state25;
585 return p;
586 }
587 p.dt2++;
588 return p;
589 }
590
591 chara_state28 = function(p)
592 {
593 if (p.dt1 <= 360)
594 {
595 p.x = Mycos(p.dt1) * 30 / SANKAKU + 82 + 32;
596 p.y = Mysin(p.dt1) * 30 / SANKAKU + 30;
597 }
598 if (p.dt1 > 360)
599 {
600 p.x = Mycos(p.dt1) * 30 * -1 / SANKAKU + 142 + 32;
601 p.y = Mysin(p.dt1) * 30 / SANKAKU + 30;
602 }
603 count++;
604 // PutSprite(count, p.x - 42, p.y, 64);
605 if (p.dt1 % 30 == 3)
606 {
607 Putenemy(24, p.x + 14,
608 p.y + 14,
609 (Math.random() % 5 + 0.5) * (Math.random() % 2 ==
610 1 ? -1 : 1),
611 (Math.random() % 5 + 0.5) * (Math.random() % 2 ==
612 1 ? -1 : 1), chara_state29);
613 }
614 p.dt1 += 3;
615 return p;
616 }
617
618 chara_state29 = function(p)
619 {
620 p.x += p.vx;
621 p.y += p.vy;
622 if(p.dt1 % 18 == 1)
623 {
624 Puttama(0, p.x, p.y);
625 }
626 p.dt1++;
627 return p;
628 }
629
630
631
632
633
634 chara_state30 = function(p)
635 {
636 p.x = p.x - 32 * d_x;
637 p.y = p.y;
638 return p;
639 }
640
641
642 chara_state31 = function(p)
643 {
644
645
646
647 return p;
648 }
649
650
651
652 chara_state400 = function character_state400(p)
653 {
654 // p.vy++;
655 p.vy += 1*d_y;
656 p.y += p.vy / 4 * d_y;
657 p.state = chara_state400;
658 return p;
659 }
660
661 chara_state401 = function character_state401(p)
662 {
663 {
664 p.vx++;
665 // p.vx += 1*d_x;
666 p.x += p.vx / 8 * d_x;
667 if (p.x > (jiki.x - 32 * d_x))
668 {
669 p.vy--;
670 }
671 p.y += p.vy / 8 * d_y;
672 if (p.dt1 % 50 == 37)
673 {
674 Puttama(1, p.x + 8, p.y + 24);
675 }
676 p.dt1++;
677 return p;
678 }
679 }
680
681 chara_state402 = function character_state402(p)
682 {
683 p.vx--;
684 p.x += p.vx / 8 * d_x;
685 if(p.x < (jiki.x + 32 * d_x))
686 {
687 p.vy--;
688 }
689 p.y += p.vy / 8 * d_y;
690 if(p.dt1 % 50 == 37)
691 {
692 Puttama(1, p.x + 8, p.y + 42);
693 }
694 p.dt1++;
695 return p;
696 }