Hi.
i have just made my first AI EVER!!
But it is still really good(i think).
*Controls* :
Control the green box using:
Upkey = move forward
downkey = move backwards
leftkey = move left
rightkey = move right
And then a red box will follow you!
If you wanna try it then here is the code:
(compressed version) :
sync on
sync rate 30
make object box 1, 5,5,5 : scale object 1, 5,5,5 : color object 1, RGB(0,128,0)
make object box 2, 5,5,5 : scale object 2, 5,5,5 : color object 2, RGB(255,0,0)
position object 2, enex#,eney#,enez# : playerx# = 0 : playery# = 0
playerz# = 0
enex# = 0
eney# = 0
enez# = 0
enespeed# = 0.1
do
position object 1, playerx#,playery#,playerz#
if upkey() = 1 then playerz#=playerz#+1.0
if downkey() = 1 then playerz#=playerz#-1.0
if leftkey() = 1 then playerx#=playerx#-1.0
if rightkey() = 1 then playerx#=playerx#+1.0
move object 2, enespeed#
point object 2, playerx#,playery#,playerz#
sync
loop
Here is the version with comments:
Rem Project: AI
Rem Created: 04-01-2005 21:00:48
Rem ***** Main Source File *****
` make the sync setup.
sync on
sync rate 30
` make the player object.
make object box 1, 5,5,5
scale object 1, 5,5,5
color object 1, RGB(0,128,0)
` make the enemy object, scale it, color it and position it.
make object box 2, 5,5,5
scale object 2, 5,5,5
color object 2, RGB(255,0,0)
position object 2, enex#,eney#,enez#
` make the player variables
playerx# = 0
playery# = 0
playerz# = 0
` make the enemy varibles
enex# = 0
eney# = 0
enez# = 0
enespeed# = 0.1
` **THIS IS THE START OF THE MAIN LOOP**
do
` position the player object
position object 1, playerx#,playery#,playerz#
` make the player control
if upkey() = 1 then playerz#=playerz#+1.0
if downkey() = 1 then playerz#=playerz#-1.0
if leftkey() = 1 then playerx#=playerx#-1.0
if rightkey() = 1 then playerx#=playerx#+1.0
` *make the enemy AI*
move object 2, enespeed#
point object 2, playerx#,playery#,playerz#
sync
loop
Hope you all like it
The Nerd