The idea for this project was to create a game all on one script. This was inspired by a video I watched on this topic. The game idea is to dodge enemies that spawn on the left and right of the screen. You get points the longer you survive, as you strive to top the last score. Every time an enemy explodes, I want to have some effect. I went with this idea because it is simple to execute, given the complexity of using one line.
Here is my tagline: Avoid the enemies, survive as long as you can, and Get the highest score you can.
Here is the code for the game. To make it easier to understand, I separated the code into multiple lines in a new script. The code splits up into a few key parts. First, there are the variables. This controls the timers, enemies, player controls and more. Then there is the Player Movement, which controls the player's movement up and down on a line. For the game, I coded two versions of this, one for a constant movement and one where the player just stops when not inputting. Then there is the code for spawning enemies and for checking collision, this ensures there are enemies and that they can kill the player. This also makes it so if the player or enemy hits their border, then they die, creating an effect.
Here is the single-line script. I can not show it in full as it is too long to show in an image. You can see the length of the scroll bar at the bottom.
Here is the script where the player stops when not inputting
Here is the video there the player keeps going in a direction