Enemy Behaviour

I am currently programming a 2D platform game (like super mario bros). But i am having problems with the enemies. So far i have been able to put an enemy in the game but i can't get it to move.

Enemy class

publicclass Enemyextends GameComponet//class attributes

{

privatefinalint walk_x_speed = 2;

privatefinalint fall_y_speed = 2;

privateint x_pos_left;

privateint x_pos_right;

privateint y_pos_up;

privateint y_pos_down;

// Counter for jumping and animation

privateint jump_counter;

privateint picture_counter;

privateint step_counter;

privateboolean falling;

privateboolean walking_left;

privateboolean walking_right;

privateint game_x_position;

privateboolean look_left;

// Constructor, calls super constructor

public Enemy(int x,int y, Image image, Component parent,int element_id)

{

super(x, y, image, parent, element_id);

}

// sets boolean value walking_left

publicvoid enemyWalkLeft(boolean value)

{

walking_left = value;

}

// sets boolean value walking_right

publicvoid enemyWalkRight(boolean value)

{

walking_right = value;

}

// set value of enemy falling

publicvoid enemyFall(boolean value)

{

// correct player position if player stops falling in a level element

// move player to level element surface

while(y_pos_down%Constant_Values.game_component_height != 0)

{

y_pos_down --;

y_pos_up--;

}

falling = value;

}

publicvoid enemyMove()

{

// player walks left

if(walking_left)

{

x_pos_left -= walk_x_speed;

x_pos_right -= walk_x_speed;

game_x_position -= walk_x_speed;

if (step_counter%15 == 0)

{

picture_counter ++;

if(picture_counter == 2)

{

picture_counter = 0;

}

step_counter = 1;

}

else

{

step_counter ++;

}

look_left =true;

}

// player walks right

elseif(walking_right)

{

x_pos_left += walk_x_speed;

x_pos_right += walk_x_speed;

game_x_position += walk_x_speed;

if (step_counter%15 == 0)

{

picture_counter ++;

if(picture_counter == 2)

{

picture_counter = 0;

}

step_counter = 1;

}

else

{

step_counter ++;

}

look_left =false;

}

// player falls

if(falling)

{

y_pos_up += fall_y_speed;

y_pos_down += fall_y_speed;

}

}

}//end class Enemy

the game loop where the enemy behaviour is activated.

publicvoid run ()

{

Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

while (true)

{

// test for collisions of the player with level elements

current_level.testForPlayerCollisions(player);

// move player

player.playerMove();

//this is the code that intializes the enemy

enemy.enemyWalkRight(true);

enemy.enemyMove();

what core features are required for the enemy to move?

are there any tutorials for programming enemies in java?

[6818 byte] By [Dash161a] at [2007-10-3 1:37:53]
# 1

Enemies are always chasing the player. If the enemies has reached the closest distance with player but they cannot touch it, enemies may take another path.

It is a bit tricky in making enemies chasing like a real-life dog or taking another path.

Enemies may chase players by going to left or right, or even up and down( depend on your map)

evilknighthka at 2007-7-14 18:36:04 > top of Java-index,Other Topics,Java Game Development...