MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / update

Method update

code/main/Knight.ts:48–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46
47 // update()
48 public update(): void{
49 // If we're not moving
50 if(this.moving == false){
51 // If we're able to move now
52 if(this.testNewGlobalPosition(this.getGlobalPosition().plus(new Pos(-3, 0)))){
53 this.moving = true; // We move
54 this.getQuestEntityMovement().setOffset(new Pos(-3, 0)); // The movement
55 }
56 }
57 // Else, if we're moving
58 else{
59 // If we're not able to move anymore
60 if(this.testNewGlobalPosition(this.getGlobalPosition().plus(new Pos(-3, 0))) == false){
61 this.moving = false; // We stop moving
62 this.getQuestEntityMovement().setOffset(new Pos(0, 0)); // The movement
63 this.currentAsciiNumber = 1; // currentAsciiNumber
64 this.reDrawAscii();
65 }
66 // Else we're really moving
67 else{
68 // Change the currentAsciiNumber
69 this.currentAsciiNumber += 1;
70 if(this.currentAsciiNumber > 5) this.currentAsciiNumber = 1;
71 this.reDrawAscii();
72 }
73 }
74
75 // Call the mother class update
76 super.update();
77 }
78
79 // willDie()
80 public willDie(): void{

Callers

nothing calls this directly

Calls 6

reDrawAsciiMethod · 0.95
testNewGlobalPositionMethod · 0.80
plusMethod · 0.80
getGlobalPositionMethod · 0.80
setOffsetMethod · 0.80

Tested by

no test coverage detected