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

Method constructor

code/main/Knight.ts:9–45  ·  view source on GitHub ↗
(quest: Quest, pos: Pos)

Source from the content-addressed store, hash-verified

7
8 // Constructor
9 constructor(quest: Quest, pos: Pos){
10 super(quest,
11 pos,
12 new Naming("A knight", "a knight"),
13 new RenderArea(15, 6),
14 new Pos(0, 0),
15 new CollisionBoxCollection(new CollisionBox(this, new Pos(3, 1), new Pos(1, 1)),
16 new CollisionBox(this, new Pos(6, 1), new Pos(3, 1)),
17 new CollisionBox(this, new Pos(0, 2), new Pos(9, 1)),
18 new CollisionBox(this, new Pos(2, 3), new Pos(13, 1)),
19 new CollisionBox(this, new Pos(3, 4), new Pos(9, 1)),
20 new CollisionBox(this, new Pos(4, 5), new Pos(2, 1)),
21 new CollisionBox(this, new Pos(9, 5), new Pos(2, 1))
22 ),
23 new QuestEntityMovement(new Pos(0, 0))
24 );
25
26 // Default movement related variables values
27 this.moving = false;
28 this.currentAsciiNumber = 1;
29
30 // Set gravity
31 this.getQuestEntityMovement().setGravity(true);
32
33 // Set destructible
34 this.setDestructible(true);
35 this.setMaxHp(150);
36 this.setHp(150);
37
38 // Set the ascii art and the transparent character
39 this.reDrawAscii();
40 this.setTransparency(new RenderTransparency(" ", "%"));
41
42 // Set the weapon and its delay
43 this.addQuestEntityWeapon(new QuestEntityWeapon(this.getQuest(), this, new Naming("A sword", "a sword"), new CollisionBoxCollection(new CollisionBox(this, new Pos(-1, 0), new Pos(17, 7))), 70));
44 this.getLastQuestEntityWeapon().getCloseCombatDelay().setFixedDelay(8);
45 }
46
47 // update()
48 public update(): void{

Callers

nothing calls this directly

Calls 12

reDrawAsciiMethod · 0.95
setGravityMethod · 0.80
setDestructibleMethod · 0.80
setTransparencyMethod · 0.80
addQuestEntityWeaponMethod · 0.80
getQuestMethod · 0.80
setFixedDelayMethod · 0.80
getCloseCombatDelayMethod · 0.80
setMaxHpMethod · 0.45
setHpMethod · 0.45

Tested by

no test coverage detected