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

Method update

code/main/TheHole.ts:127–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125 }
126
127 public update(): void{
128 if(this.getQuestEnded() == false){
129 // Test if the player won the quest, if so, end the quest and return
130 if(this.thePlayerWon()){
131 this.endQuest(true);
132 return;
133 }
134
135 // Test if the player is dead, if so, end the quest and return
136 if(this.getGame().getPlayer().shouldDie()){
137 this.endQuest(false);
138 return;
139 }
140
141 // Move the player horizontally
142 this.moveHorizontally();
143
144 // Update entities
145 this.updateEntities();
146
147 // Calculate the new global drawing offset
148 this.calcNewGlobalDrawingOffset();
149 }
150
151 // Draw
152 this.preDraw();
153 this.getRenderArea().drawArray(Database.getPartOfAscii("places/quests/theHole/background", -this.getGlobalDrawingOffset().y, -this.getGlobalDrawingOffset().y + 35), this.getRealQuestPosition().x, this.getRealQuestPosition().y);
154 this.drawEntities();
155 this.drawAroundQuest();
156 if(this.getQuestEnded() == false) this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestNoKeeping");
157 else if(this.getQuestEndedAndWeWon() == false) this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestNoKeepingBecauseLose");
158 else this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestKeeping");
159 this.postDraw();
160 }
161
162 // Private methods
163 private addChest(chest: Chest): void{

Callers

nothing calls this directly

Calls 15

thePlayerWonMethod · 0.95
endQuestMethod · 0.95
moveHorizontallyMethod · 0.95
getQuestEndedMethod · 0.80
getPlayerMethod · 0.80
updateEntitiesMethod · 0.80
preDrawMethod · 0.80
drawArrayMethod · 0.80
getRealQuestPositionMethod · 0.80
drawEntitiesMethod · 0.80

Tested by

no test coverage detected