simple AI

Don't know how to make something and can't find a tutorial? Ask for one here.

simple AI

Postby master0500 » Thu Jun 07, 2012 11:49 am

i need an Ai for an enemy actor to hover over the player whilst swaying side to side and shooting at the player
+1 to best reply
master0500
 
Posts: 409
Joined: Sun Jun 26, 2011 9:42 pm
Score: 27 Give a positive score

Re: simple AI

Postby skydereign » Thu Jun 07, 2012 4:55 pm

Here's a simple way of doing it. This can be compressed even more, but this way is easier to understand the idea. Do note you need to start the xvelocity at some point.
Code: Select all
switch(dir)
{
    case 0:
    if(x>player.x+100)
    {
        dir=1;
        xvelocity=-5;
    }
    break;

    case 1:
    if(x<player.x-100)
    {
        dir=0;
        xvelocity=5;
    }
    break;
}

Shooting can be done with an infinite real timer on create, or a variable timer in draw.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Tutorial Requests

Who is online

Users browsing this forum: No registered users and 1 guest