# Need help with programming an enemy for a platformer

**URL:** <https://forum.kirupa.com/t/need-help-with-programming-an-enemy-for-a-platformer/310025>\
**Category:** Uncategorized\
**Created:** [May 30, 2010, 5:38pm UTC](https://forum.kirupa.com/t/need-help-with-programming-an-enemy-for-a-platformer/310025 "2010-05-30T17:38:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ferretg](https://avatars.discourse-cdn.com/v4/letter/f/eb8c5e/32.png) [@ferretg](https://forum.kirupa.com/u/ferretg)\
**Post date:** [May 30, 2010, 5:38pm UTC](https://forum.kirupa.com/t/need-help-with-programming-an-enemy-for-a-platformer/310025/1 "2010-05-30T17:38:43Z")

</div>

I am trying to make an enemy for a side-scrolling platformer game that is similar to the green turtle in Super Mario. It needs to go 1 direction 1st then either turn when hitting a wall or fall if it walks over the edge. I am programming using separate as files connected together and so far have come up with the following code files.

enemy\_test.as:

package  
{  
import flash.display.MovieClip;  
import flash.utils.Timer;  
import flash.events.TimerEvent;  
public class inkman\_enTest extends MovieClip  
{

```
    public var Enemy:enemy;
    public var walls:Array;
    public var gtimer:Timer;
    public function inkman_enTest()
    {
        walls = new Array();
        Enemy = new enemy();
        addChild( Enemy );
        
        gtimer= new Timer(25);
        gtimer.addEventListener(TimerEvent.TIMER, gameLoop);
        gtimer.start();
    }
    
    function gameLoop(loop:TimerEvent):void 
    {
        Enemy.en_move(); 
    }
}

```

}

enemy.as:

package  
{  
import flash.display.MovieClip;  
public class enemy extends MovieClip  
{  
public function en\_start()  
{  
x= 100; // Variables for enemy starting place.  
y= 10;//  
}  
public function en\_move():void  
{  
this.x +=3;// Initial movement

```
    }
}

```

}

wall.as:

package  
{  
import flash.display.MovieClip;  
public class Wall extends MovieClip  
{  
public var WIDTH:int = 32;

```
    public var HEIGHT:int = 32; 
    
}

```

}

Any help would be appreciated. If not can I you point me to a website or forum where I can get more information. Thanks.
