Super Binary Man
New Features
- added an enemy class from which all future enemies will inherit from
- implemented the first enemy called "Dumdum".
- introduced sprite-sprite collision
- added a basic life system
- added a level-reset capability
- changed the level layout a bit
- changed the warp system
play the new version here
note that you may have to clear your browser's cache
Implementation details
- collision system
- The new collision function (as seen here simply checks whether two sprites are overlapping, when called, if it returns true the level will reset at shown at this line
Link to relevant lines in the code on GitHub and explain briefly what you added/changed.
- The new collision function (as seen here simply checks whether two sprites are overlapping, when called, if it returns true the level will reset at shown at this line
- Enemies
- The new enemy class can be seen here. It inherits from the Sprite class, and is very similar to the player class except it's meant to be controlled by a game ai.
- Dumdum is the first enemy in the game as seen here. It begins by choosing a random direction and speed. There is a small chance at every game tick that it will change its direction and speed. There is a medium chance of it changing direction and speed when a player hits the wrong block. It can warp around the screen like any sprite. It does not chase the player.
- Warp system
- The warp function has been moved to the Sprite class as seen here. As you can see from the code, warping is now done in an anti parallel configuration which makes predicting enemy movements while under stress more difficult and also allows for more effective dodging at certain situations.
- The level layout has been changed to accommodate the new warp system as seen here.
- Level reset
- A level reset function now includes a call to resetBlocks. It accepts a single argument (either true/false) for whether to decrease the player's life. You can see the code here
- The level reset also takes care of calling the gameOver state
Posted on Utopian.io - Rewarding Open Source Contributors