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

Method constructor

code/main/TheHole.ts:22–74  ·  view source on GitHub ↗
(game: Game)

Source from the content-addressed store, hash-verified

20
21 // Constructor
22 constructor(game: Game){
23 super(game, "You can move with the left and right arrow keys!");
24
25 // Resize the quest
26 this.resizeQuest(100, 35, new Pos(100, 136));
27
28 // Add collision boxes around
29 this.addPlayerCollisionBoxes(true, true, true, true);
30
31 // Add the player
32 this.getGame().getPlayer().loadCandyBoxCharacter(this);
33 this.getGame().getPlayer().setGlobalPosition(new Pos(48, 0));
34 this.configPlayerOrClone(this.getGame().getPlayer());
35 this.addEntity(this.getGame().getPlayer());
36
37 // Add the walls
38 this.createWalls();
39
40 // Add the spikes
41 this.addSpikes(new Spikes(this, new Pos(44, 42), 20));
42 this.addSpikes(new Spikes(this, new Pos(23, 59), 22));
43 this.addSpikes(new Spikes(this, new Pos(90, 62), 8));
44 this.addSpikes(new Spikes(this, new Pos(87, 69), 4));
45 this.addSpikes(new Spikes(this, new Pos(94, 69), 4));
46 this.addSpikes(new Spikes(this, new Pos(93, 74), 2));
47 this.addSpikes(new Spikes(this, new Pos(66, 74), 14));
48 this.addSpikes(new Spikes(this, new Pos(66, 82), 4));
49 this.addSpikes(new Spikes(this, new Pos(76, 83), 6));
50 this.addSpikes(new Spikes(this, new Pos(3, 95), 8));
51 this.addSpikes(new Spikes(this, new Pos(13, 97), 10));
52 this.addSpikes(new Spikes(this, new Pos(24, 96), 2));
53 this.addSpikes(new Spikes(this, new Pos(29, 96), 2));
54 this.addSpikes(new Spikes(this, new Pos(33, 95), 12));
55 this.addSpikes(new Spikes(this, new Pos(64, 64), 4));
56
57 // Add the chests
58 this.addChest(new Chest(this, new Pos(27, 67), true, new CallbackCollection(this.openFirstChest.bind(this)), Saving.loadBool("theHoleFirstChestFound")));
59 this.addChest(new Chest(this, new Pos(59, 74), true, new CallbackCollection(this.openSecondChest.bind(this)), Saving.loadBool("theHoleSecondChestFound")));
60 this.addChest(new Chest(this, new Pos(37, 107), false, new CallbackCollection(this.openThirdChest.bind(this)), Saving.loadBool("theHoleThirdChestFound")));
61 this.addChest(new Chest(this, new Pos(4, 129), true, new CallbackCollection(this.openFourthChest.bind(this)), Saving.loadBool("theHoleFourthChestFound")));
62
63 // Add the lost tribe warrior alone in its room
64 this.addLostTribeWarrior(new LostTribeWarrior(this, new Pos(68, 89), new Pos(63, 85), new Pos(93, 95)));
65
66 // Add the lost tribe warriors in the big room
67 this.addLostTribeWarrior(new LostTribeWarrior(this, new Pos(14, 126), new Pos(2, 112), new Pos(79, 129)));
68 this.addLostTribeWarrior(new LostTribeWarrior(this, new Pos(21, 126), new Pos(2, 112), new Pos(79, 129)));
69 this.addLostTribeWarrior(new LostTribeWarrior(this, new Pos(31, 125), new Pos(2, 112), new Pos(79, 129)));
70 this.addLostTribeWarrior(new LostTribeWarrior(this, new Pos(51, 123), new Pos(2, 112), new Pos(79, 129)));
71
72 // Add the message
73 this.getGame().getQuestLog().addMessage(new QuestLogMessage("You jumped into the big hole! You're falling quickly, try to stay alive!"));
74 }
75
76 // willBeDisplayed()
77 public willBeDisplayed(): void{

Callers

nothing calls this directly

Calls 15

configPlayerOrCloneMethod · 0.95
createWallsMethod · 0.95
addSpikesMethod · 0.95
addChestMethod · 0.95
addLostTribeWarriorMethod · 0.95
resizeQuestMethod · 0.80
loadCandyBoxCharacterMethod · 0.80
getPlayerMethod · 0.80
setGlobalPositionMethod · 0.80
addEntityMethod · 0.80
bindMethod · 0.80

Tested by

no test coverage detected