Game of Space Invaders created in Java without any game engine.
Runnable JAR can be found at SpaceInvaders/readme-resources/SpaceInvaders-MiroslavJelaska.jar
Do you like it? Show it by giving a ⭐️. 🚀
Action | Key |
---|---|
⤎ Move Left | A |
Move Right ⤏ | D |
Shoot 💥 | Spacebar |
Points are gained by destroying invader ships, 100 points per each. Bonus points are added for each destroyed ship depending on the time it was destroyed. The sooner in gameplay ship gets destroyed the more bonus points are gained.
Bonus points are given by following function:
BonusPoints(time) = 1000 points * e^(-0.1 * time)
This is actualy function of exponential decay where total amount N0 is 1000 and exponential decay constant 𝛌 is 0.1 within general formula .
private static final int TotalBonusPoints = 1000;
private static final double ExponentialDecayConstant = -0.1;
private int bonusPointsWithExponentialDecay(long time){
return (int)(TotalBonusPoints * Math.exp(ExponentialDecayConstant * time));
}
- gameprogrammingpatterns.com (📖 Book)
- Killer Game Programming in Java (📖 Book)
- Ryan van Zeben :: Java 2D Game Engine Development (📺 YouTube)
- gamedev.stackexchange :: Tips for writing the main game loop? (📄 Article)
- higherorderfun.com :: Understanding the Game Main Loop (📄 Article)
- codeincomplete.com :: Javascript Game Foundations - The Game Loop (📄 Article)
- [The Java™ Tutorials :: Trail: 2D Graphics (📄 Official tutorials)] (http://docs.oracle.com/javase/tutorial/2d/index.html)
- [Fabien Sanglard's website :: Game timers: Issues and solutions. (📄 Article)] (http://fabiensanglard.net/timer_and_framerate/)
- ZetCode :: Java games tutorial (📄 Article collection)
Color scheme is inspired by "monokai" color scheme. Colors used in game are:
-
#231f20
(Game background) -
#FFFFFF
(Hero) -
#F92672
(HeroProjectile) -
#A6E22E
(InvaderShip and StatusRibbon::Title) -
#AE81FF
(InvaderProjectile and Explosion) -
#282828
(StatusRibbon::Background) -
#E6DB74
(StatusRibbon::Text)
Audio effects used in the game were downloaded from www.freesound.org and were under CC license. Here I'll mention authors and their audio tracks which were used in this game.