The main goal in these games is to kill incoming enemy creeps and prevent them from reaching a certain spot on the map like the entrance to your base. In addition, the leading enemy sets "lead x" and "lead y" to its x and y position to identify to the towers where the leading clone actually is.Tower defense (TD) is a popular subgenre of real-time strategy games. If an enemy's private progress is greater than the global lead progress, it sets the lead progress to its own, showing that it is in the lead. Every enemy constantly checks if it's progress is greater than the "lead progress" global variable.
Make a block called "change y by () and update" that makes the sprite move and increase its progress. Every pixel it moves along the path, its progress increases by 1. When an enemy is generated, it starts with zero progress. Each enemy has its own progress it records. The only private variable above is "progress". There are four variables associated with the leading enemy: Wait until // it must wait for the map to clearĪll the enemy clones have a very simple method of determining which is in the front. Repeat until // generate until blank list item detected The following script generates the enemies constantly and pauses between rounds: Furthermore, each round is separated by a blank list item in each list.
For example, if item 1 of "waits" is 4, then the enemy sprite would wait 4 seconds before creating an enemy with the costume # stored in item 1 of "types". Each item in the "waits" list is associated with the corresponding item in the "types" list. The boulder generation is encoded into lists, which is a part of efficient programming. A higher costume makes a stronger enemy with more layers.