OSDN Git Service

当たり判定の修正と敵キャラクターを踏んでダメージを与える動作の実装
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / OperatedCharacterClass.js
1 var OperatedCharacterClass = function(ownerStage, args){
2         OperatedCharacterClass.base.apply(this, arguments);
3         
4         //\82±\82ê\82ç\82Ì\92l\82ð\81i\8ae\83L\83\83\83\89\83N\83^\81[\82ð\8e¦\82·\81j\8eq\83N\83\89\83X\82©\82ç\8fã\8f\91\82«\82·\82é\82±\82Æ\82Å\8cÂ\90«\82ð\90\82Ý\8fo\82¹\82é
5         this.movingVelocity = 200;
6         this.jumpPower_tickCountBase = 10;
7         this.jumpPower_tickCountAtLeast = 5;
8         this.jumpPower_tickCount = 0;
9         this.jumpPower = 45;
10         this.jumpSound = createAudio("jump12.mp3");
11         this.collisionMarginTop = 2;
12         this.collisionMarginLeft = 10;
13         this.collisionMarginRight = 10;
14         this.collisionMarginBottom =2;
15         
16 }.extend(CharacterClass, {
17         className: "OperatedCharacterClass",
18         //\82±\82±\82É\83L\83\83\83\89\82Ì\93®\82«\82É\91Î\82·\82é\90§\8cä\82ð\82¨\82±\82È\82¤\8f\88\97\9d\8cQ(\88Ú\93®\81A\8dU\8c\82\82È\82Ç)\82ð\8bL\8fq\81B
19         //\83L\83\83\83\89\82²\82Æ\82É\90«\8e¿\82ð\95Ï\82¦\82½\82¢\82Ì\82Å\82 \82ê\82Î\82»\82ê\82ðthis.xxx\83C\83\93\83X\83^\83\93\83X\95Ï\90\94\82É\8bL\8fq\82µ\81A\8ag\92£\83N\83\89\83X\82Å\82»\82Ì\92l\82ð\8fã\8f\91\82«\82·\82é\82×\82«\82Å\82 \82é\81B
20         //\8f]\82Á\82Ä\82±\82Ì\8eq\83N\83\89\83X\82©\82çthis.movingSpeed\82È\82Ç\82ð\82¢\82\82é\82Ì\82Í\82Ó\82³\82í\82µ\82­\82È\82¢\82Æ\8dl\82¦\82é\81B
21         
22         // \92Ê\8fí\8d\82É\90i\82Þ\82Æ\82«\82É\8cÄ\82Î\82ê\82é\81B\8d\83L\81[\82ð\89\9f\82µ\82Ä\82¢\82é\8aÔ\92\86tick\96\88\82É\8cÄ\82Î\82ê\82é
23         goLeft : function(){
24                 this.imageState = 0;
25                 this.direction = 0;
26                 this.movingSpeed.x += ((-this.movingVelocity) - this.movingSpeed.x) / 3;
27         },
28         
29         //\92Ê\8fí\89E\82É\90i\82Þ\82Æ\82«\82É\8cÄ\82Î\82ê\82é\81B
30         goRight : function(){
31                 this.imageState = 0;
32                 this.direction = 1;
33                 this.movingSpeed.x += (this.movingVelocity - this.movingSpeed.x) / 3;
34         },
35         
36         //\92Ê\8fí\83W\83\83\83\93\83v\82·\82é\82Æ\82«\82É\8cÄ\82Î\82ê\82é\81B\83W\83\83\83\93\83v\83L\81[\82ð\89\9f\82µ\82Ä\82¢\82é\8aÔ\82Í\82¸\82Á\82Æ\8cÄ\82Î\82ê\82é
37         //\83W\83\83\83\93\83v\83L\81[\82ð\89\9f\82µ\82Ä\82¢\82é\8e\9e\8aÔ\82Ì\92·\82³\82É\89\9e\82\82Ä\83W\83\83\83\93\83v\82Ì\8d\82\82³\82ª\95Ï\89»\82·\82é\81B
38         jump : function(){
39                 if(this.collideFlag & CollideBottom){
40                         //\83W\83\83\83\93\83v\82Ì\8f\89\8aú\89»
41                         this.jumpEnd = OperatedCharacterClass.prototype.jumpEnd;
42                         this.jumpPower_tickCount = this.jumpPower_tickCountBase;
43                 }
44                 if(this.jumpPower_tickCount > 0){
45                         if(this.jumpPower_tickCount == this.jumpPower_tickCountBase){
46                                 this.jumpSound.load();
47                                 this.jumpSound.play();
48                         }
49                         this.jumpPower_tickCount--;
50                         var p = (this.jumpPower_tickCountBase / this.jumpPower_tickCountBase);
51                         this.movingSpeed.y += -this.jumpPower * p * p;
52                 }
53         },
54         jumpEnd: function(){
55                 //\83W\83\83\83\93\83v\83L\81[\82ª\89\9f\82³\82ê\82Ä\82¢\82È\82¢\8aÔ\82Í\82±\82¿\82ç\82ª\8cÄ\82Ñ\8fo\82³\82ê\82é\81B\83W\83\83\83\93\83v\8f\88\97\9d\82ª\82·\82×\82Ä\8fI\97¹\82µ\82½\8cã\82Ínull\82É\82È\82é\81B
56                 //\83W\83\83\83\93\83v\83L\81[\82ð\82²\82­\92Z\8e\9e\8aÔ\89\9f\82µ\82½\8fê\8d\87\82Å\82à\81A\82 \82é\88ê\92è\82Ì\8d\82\82³\82Ü\82Å\82Í\83W\83\83\83\93\83v\82·\82é\82æ\82¤\82É\82·\82é\82½\82ß\81B
57                 if(this.jumpPower_tickCount < this.jumpPower_tickCountBase - this.jumpPower_tickCountAtLeast){
58                         this.jumpPower_tickCount = 0;
59                         this.jumpEnd = null;
60                 } else{
61                         this.jump();
62                 }
63         },
64         tick : function(){
65                 OperatedCharacterClass.base.prototype.tick.apply(this); 
66         },
67         draw : function(x, y){
68                 OperatedCharacterClass.base.prototype.draw.apply(this, [x, y]);
69         }
70 });