Skip to content

Commit

Permalink
Update AB_4_BatAttack.md (AlexNisnevich#480)
Browse files Browse the repository at this point in the history
Teleport in front of the exit
  • Loading branch information
kedilayanaveen10 authored Jan 14, 2022
1 parent 54f4b45 commit 475259b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion solutions/bonus/AB_4_BatAttack.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,22 @@ map.defineObject("shield",{
}
}
});
```
```

## kedilayanaveen10: Teleport
Teleport in front of the exit
```javascript
map.placeObject(map.getPlayer().getX(), map.getPlayer().getY()-1, 'teleporter');
map.placeObject(map.getWidth()-11, 1, 'teleporter');
teleporters = map.getDynamicObjects();

//teleporters we placed will be at the end of the array because map pushes every new dynamic object at the back of the array __dynamicObjects that it maintains.
//Code in map.placeObject (in map.js):
//__dynamicObjects.push(new DynamicObject(this, type, x, y, __game));

var t1 = teleporters[teleporters.length-2];
var t2 = teleporters[teleporters.length-1];

t1.setTarget(t2);
t2.setTarget(t1);
```

0 comments on commit 475259b

Please sign in to comment.