forums

TNT Basic Forums > Programming Q&A
Artificial Intelligence
< Last Thread     Next Thread >
Author
Thread        Post A Reply

09-16-2003 19:23

Posted by:
EvolPenguin

Location:
Chicago

Click Here to Email EvolPenguin   Find more posts by EvolPenguin

I'm making a game where u have to chase a zombie around a screen with a few blocks in it. How would I make the zombie act intelligent? I don't know what I would do. A lot of if then statements? Or what?

Thanks in advance,
Alex

09-16-2003 21:37

Posted by:
DanLurie

Location:
Earth>USA>New Jersey>Clifton>My Chair

Click Here to Email DanLurie   Find more posts by DanLurie

Sure. You can use rnd to produce random numbers to simulate behaviors, too.

09-16-2003 23:06

Posted by:
EvolPenguin

Location:
Chicago

Click Here to Email EvolPenguin   Find more posts by EvolPenguin

Thats cool. Thanks for the info. So i would be like:

if playerx<enemyx
enemyx=enemyx+3
end if

LIke that right? But how would I use rnd?

Thanks
Alex

09-16-2003 23:09

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Yes, use a lot of if statements and use some random numbers so the zombie's doesn't develop a predictable pattern. If you get close to a zombie, say within 2 tiles, the zombie sees you and is on runaway mode, which you set with some variable. Then the zombie will continue to go in the opposite direction until you are out of sight (5 tiles for example) for a certain amount of time, after which the zombie will go back to sleeping mode.
To make the zombie move over obstacles you have to see if a tile is in its way and make it jump over it.

09-17-2003 20:19

Posted by:
EvolPenguin

Location:
Chicago

Click Here to Email EvolPenguin   Find more posts by EvolPenguin

Thats cool. I just used Matthews shooting example for the beggining. I have my code a bunch of if statements. How would I use rnd? Would i just go like this:

int n
n = random

It probably wouldn't be random, but what would i use to create a random number. I had one problem with my code. Collision, i cant make the sprite dissapear when it gets hit by a fireball. The enemy sprite is sprite 66. It looks like this, using Matthews code.

if gShotX[openShot]=gEnemyX and gShotY[openShot]=gEnemyY
sprite off 66
end if

Thanks for your help,
Alex

09-17-2003 20:28

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

the code for random is as follows

random(lowest number,highest number)

This command takes two numbers and generates a random number between (and including) them.

09-17-2003 23:15

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

quote:
if gShotX[openShot]=gEnemyX and gShotY[openShot]=gEnemyY
sprite off 66
end if


This only executes if the shot coordinates and enemy coordinates are exactly the same; if their upper left corners are aligned. Instead you should use TNT's built in collision detection.

if sprite col(shotSprite,enemySprite)=enemySprite

09-18-2003 00:54

Posted by:
EvolPenguin

Location:
Chicago

Click Here to Email EvolPenguin   Find more posts by EvolPenguin

allright, but what do I use for shotsprite and enemysprite. What are they, the x and y or what? The id number?

Alex

09-18-2003 22:23

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Yes, shotSprite and enemySprite would be the sprite ids of the shot and the enemy respectively.

09-19-2003 23:37

Posted by:
EvolPenguin

Location:
Chicago

Click Here to Email EvolPenguin   Find more posts by EvolPenguin

hmm
still doesn't work, i am working on it though.Here is my code:
if sprite col(gShotSprite,66)=66
sprite off 66
end if

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.