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

Method checkCollision

code/main/QuestEntity.ts:153–169  ·  view source on GitHub ↗
(pos: Pos = new Pos(0, 0))

Source from the content-addressed store, hash-verified

151 }
152
153 public checkCollision(pos: Pos = new Pos(0, 0)): boolean{
154 // BUGS : if the level is >= 4, we just return a random value
155 if(Bugs.getQuestBugLevel() >= 4)
156 return Random.flipACoin();
157
158 for(var i = 0; i < this.quest.getEntities().length; i++){
159 // If it's not the same object as us
160 if(this.quest.getEntities()[i] != this){
161 // If we collide with it, we return true
162 if(this.collidesWith(this.quest.getEntities()[i], pos))
163 return true;
164 }
165 }
166
167 // No collision
168 return false;
169 }
170
171 public collidesWith(questEntity: QuestEntity, pos: Pos = new Pos(0, 0)): boolean{
172 // If we both have a collision box collection, we return the result of the collision test

Callers 4

jumpMethod · 0.95
moveWormsLikeMethod · 0.95
setGlobalPositionMethod · 0.95
testNewGlobalPositionMethod · 0.95

Calls 2

collidesWithMethod · 0.95
getEntitiesMethod · 0.80

Tested by

no test coverage detected