# Cpu difficulty

**URL:** <https://forum.kirupa.com/t/cpu-difficulty/235860>\
**Category:** Uncategorized\
**Created:** [August 15, 2007, 11:05am UTC](https://forum.kirupa.com/t/cpu-difficulty/235860 "2007-08-15T11:05:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![howling\_shooter](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@howling\_shooter](https://forum.kirupa.com/u/howling_shooter)\
**Post date:** [August 15, 2007, 11:05am UTC](https://forum.kirupa.com/t/cpu-difficulty/235860/1 "2007-08-15T11:05:24Z")

</div>

hiya, i have a problem, i want my character to fight some enemies that wlak over the terrian towards him (pretty basic) but i can only get them to walk across flat terrian, is there a way to make it so that they can go over any terrain(like up a hill or over curved ground)?

onClipEvent (load) {  
enemyspeed = 2;  
// this sets the speed your enemy will move at  
enemystepsright = 0;  
// how far it has moved right  
enemystepsleft = 0;  
// how far it has moved left  
enemydir = “left”;  
// its direction is set left  
}  
onClipEvent (enterFrame) {  
if (this.hitTest(\_root.char.attackpoint)) {  
// if it hits the attackpoint in the character MC  
enemyspeed = 0;  
// its speed is set to 0  
enemystepsright = 0;  
// how far it has moved right is set to 0  
enemystepsleft = 0;  
// how far it has moved left set to 0  
dead = true;  
// dead is true  
this.gotoAndStop(“dead”);  
// goto and stop on the dead frame  
}  
if (this.hitTest(\_root.bulleter)) {  
// if this hits the bullet (\_root.bulleter)  
enemyspeed = 0;  
// its speed is set to 0  
enemystepsright = 0;  
// how far it has moved right is set to 0  
enemystepsleft = 0;  
// how far it has moved left set to 0  
dead = true;  
// dead is true  
this.gotoAndStop(“dead”);  
// goto and stop on the dead frame  
}  
if (this.hitTest(\_root.char) && !dead) {  
// if this hits the character and is not dead  
\_root.char.jumping = false;  
// characters jumping state is set false  
\_root.dead = true;  
// \_root.dead is set true  
}  
if (!dead) {  
// if NOT dead  
if (enemydir == “right”) {  
// if the direction (enemydir) is right  
enemystepsright += 1;  
// its amount of steps (enemystepsright) right goes up 1  
this.\_xscale = -100;  
// \_xscale (flips character) is set to neg. 100  
this.\_x += enemyspeed;  
// its X goes up the value of enemyspeed  
} else if (enemydir == “left”) {  
// otherwise if the direction (enemydir) is left  
enemystepsleft += 1;  
// its amount of steps (enemystepsright) left goes up 1  
this.\_xscale = 100;  
// \_xscale (flips character) is set to 100  
this.\_x -= enemyspeed;  
// its X goes down the value of enemyspeed  
}  
if (enemystepsright == 100) {  
// if enemystepsright is equal to 100  
enemystepsright = 0;  
// enemystepsright is set to 0  
enemydir = “left”;  
// direction is set to left  
} else if (enemystepsleft == 100) {  
// otherwise if enemystepsleft is equal to 100  
enemystepsleft = 0;  
// enemystepsleft is set to 0  
enemydir = “right”;  
// direction is set to right  
}  
}  
}
