The way therevells set it up, startX is where the enemy begins. It's in between startX-maxSteps and startX+maxSteps which are the two end-points. The enemy moves at speedX in the appropriate direction until it reaches one, then changes direction to head towards the other.
There are other ways you could do it - many people would store the two end points, and set the enemy to the midpoint of them when it starts. Either way is fine.
As for scrolling, the enemy only needs to know its position on the map. Where it gets drawn on screen is a combination of where it is on the map, plus where the map is on screen. If the enemy is at 100,200 on the map, and the map is being drawn (because of the player position) so that the top left of the screen is 50,40 on the map, then the enemy is drawn at 50,160 on the screen (100-50,200-40).
You can have lots of instances of any class - each instance has its own set of fields. Each enemy is created using a New statement which sets its x and y position. They will be stored as fields of your App class (in the simplest case) - maybe individual named enemies or an array of them or whatever.
|