Aliens
You can access the list of aliens through the array game.aliens
You can also find an alien with a specific id using game.findAlien(id)
, which returns an object representing the matched alien or null
(if no aliens are matching the provided id)
Creation
To create an alien, use game.addAlien({ options })
List of accepted options:
(Note: Server will respond with Incorrect data
when at least one input property value is improper)
Option | Description | Default value (if omitted) |
---|---|---|
x | X coordinate | 0 |
y | Y coordinate | 0 |
vx | Velocity vector X component | 0 |
vy | Velocity vector Y component | 0 |
code | Type of alien must be an integer in range [10-20] | 10 |
level | Level of the alien, in range [0-X] where X depends on the alien type | 0 |
points | The number of points you earn when you kill this alien | None |
crystal_drop | The crystal amount to be dropped when this alien is killed | None |
weapon_drop | The code of a collectible weapon to be dropped by this alien when killed | None |
Here is the list of supported codes:
Code | Alien name |
---|---|
10 | Chicken |
11 | Crab |
12 | Fortress |
13 | Caterpillar |
14 | Candlestick |
15 | Hirsute |
16 | Piranha |
17 | Pointu |
18 | Fork |
19 | Saucer |
20 | Final Boss |
A new Alien
object is immediately added to game.aliens
; however, it cannot be used before it has been assigned an id (natural number, a.k.a non-negative integer) by the server.
Limits
You can only have 300 alive aliens (including aliens generated by the game mode) at any time in your game
The server will respond with Too many aliens
for each alien passing the limit
Accessible fields
For each alien object in game.aliens
, You have access to the same properties as the available ones when you add aliens, plus some additional properties:
Option | Description |
---|---|
game | Points to the global game object |
id | a unique identifier for the alien |
Configuration
Once an alien is live and has an assigned id, you can set options to it. For example:
> game.aliens[0].set({x:0,y:0});
> █
Will move the first alien in the list to the center of the map
Accepted options when using alien.set
:
Option | Description | Server response error message (if improper) |
---|---|---|
x | X coordinate | Wrong coordinate |
y | Y coordinate | Wrong coordinate |
vx | Velocity vector X component | Wrong coordinate |
vy | Velocity vector Y component | Wrong coordinate |
shield | Shield | Wrong shield value |
regen | Shield regen | Wrong regen value |
damage | Laser damage | Wrong damage value |
laser_speed | Laser speed | Wrong damage value |
rate | Firing rate | Wrong rate value |
kill | Set kill: (any "truthy" value, e.g: true) to destroy the alien | No violation |