The Enemies Are Mobile!

<p><strong>Objective</strong>: Enable the enemies in my project to move in a new way.</p> <p>So now that I have all the framework nearly completed, I want to focus on the enemies for this one. It&rsquo;s nice that I have them moving in one direction from the top of the screen on the y-axis, but let&rsquo;s spice this up a little bit and give these enemies some new flare to their movement.</p> <p>So originally, in my enemy script, I passed in a Calculate Movement method with indicates how they spawn from the top and move downwards toward the bottom. Here is the initial code for that:</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:770/1*1KAMR67QJUx01V2Alq_ICQ.png" style="height:267px; width:700px" /></p> <p>When the enemy spawns from the top of the game screen, I want to implement a way for the enemy to begin moving left and right. The approach I took to implement this was to create an &ldquo;int&rdquo; variable and use it as a random indicator at which type of movement the enemy will take.</p> <p>The enemy will either move straight down, diagonally left, or diagonally right. I give the variable a &ldquo;random.range&rdquo; value in void start.</p> <p><a href="https://medium.com/@scralex421/the-enemies-are-mobile-1fe2d05c6351"><strong>Website</strong></a></p>
Tags: Enemies Mobile