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

Method move

code/main/PondLolligator.ts:47–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 }
46
47 public move(): void{
48 // If the lolligator is facing left, then it goes to the left
49 if(this.isLeft){
50 this.x -= 1;
51 // If we're not fully visible but we should be
52 if(this.visibleType == PondLolligatorVisibleType.NOT_FULLY_VISIBLE_YET && this.x + this.width < this.pondLines[this.pondLineIndex].getX2() - 2 && Random.oneChanceOutOf(5))
53 this.visibleType = PondLolligatorVisibleType.FULLY_VISIBLE;
54 else if(this.visibleType == PondLolligatorVisibleType.FULLY_VISIBLE && (this.x < this.pondLines[this.pondLineIndex].getX1() + 2 || Random.oneChanceOutOf(2)))
55 this.visibleType = PondLolligatorVisibleType.NOT_FULLY_VISIBLE_ANYMORE;
56 }
57 // Else it goes to the right
58 else{
59 this.x += 1;
60 // If we're not fully visible but we should be
61 if(this.visibleType == PondLolligatorVisibleType.NOT_FULLY_VISIBLE_YET && this.x > this.pondLines[this.pondLineIndex].getX1() + 2 && Random.oneChanceOutOf(5))
62 this.visibleType = PondLolligatorVisibleType.FULLY_VISIBLE;
63 else if(this.visibleType == PondLolligatorVisibleType.FULLY_VISIBLE && (this.x + this.width > this.pondLines[this.pondLineIndex].getX2() - 2 || Random.oneChanceOutOf(2)))
64 this.visibleType = PondLolligatorVisibleType.NOT_FULLY_VISIBLE_ANYMORE;
65 }
66 }
67
68 // Called to know if the lolligator should be deleted or not
69 public shouldBeDeleted(): boolean{

Callers

nothing calls this directly

Calls 2

getX2Method · 0.80
getX1Method · 0.80

Tested by

no test coverage detected