This is an Asteroids clone written in Elixir with Nerves, more for fun and learning than for anything else. Also since the code (and behavior) is relatively simple, I hope that it can serve as an example for Scenic, Nerves, and as a simple poncho project.
It is licensed under the 3-clause BSD license (see LICENSE) for details.
From the root of the repository run the following commands:
cd play_ui
mix deps.get
iex -S mix
Note: if scenic doesn't launch then you may be affected by the bug https://github.com/boydm/scenic_new/issues/36
Keys:
W
- Move upA
- Move leftS
- Move downD
- Move rightSPC
- Shoot an asteroidUse the mouse to target the asteroids (or your finger if you're running with a Nerves touch screen)
Have fun!
SchedEx is used to implement the core animation timer which runs at a rate of 60 frames per second.
Collision detection is incredibly basic and non-performant. Ideally either scenic or a cooperating library would implement some collision detector helpers. If you're interested in collision detection then please contribute to Scenic issue #91.
play/
- The main game logicplay_ui/
- Run via scenic on the desktopfw/
- Run on a Nerves device with a touchscreen
TODO:
The player javascript will record action states (not key states) Actions:
NOTE: if move_aim_direction
is used then the other move and aim actions should
not be used. This will be enforced on the server-side.
set:actions
GenServer.cast
to the Asteroids scene to update that players currently set actions