Hi
(New update is released! see it in the bottom of this post)
After i made my very first AI code in the 20 line challenge(someone dont call i AI but i prefer to say it is VERY simple AI).
So i made this engine for ETC Newcomers to help them making a simple AI.
Before you take the Engine please read this. Maybe it would answer some of you questions
INFO :
Quote: "What DB versions can this engine compile in?"
It can compile in both DBPRO and DBC
Quote: "Can i use this code in my own game/program ?"
Yes you certanly can!
This code is Royalty free and can be used in you Commercial product or freeware product
Quote: "Am i allowed to send this code to my friend over msn ETC?"
Yes Of course you are!
Quote: "Am i allowed to make some changed in the code and post it on this forum ETC?"
Yes but then please say that the original code came from : The Nerd
Quote: "Am i allowed to say i made this?"
Well............ No
INFO ABOUT THE ENGINE :
i also wanna tell you the features of this engine:
Sliding collision(But the wall is invisible)
Really smooth control using the upkey,downkey,leftkey and the rightkey
An enemy object that will follow you.
NEW UPDATE! :
Here is the new features:
A new cube is positioned so when the enemi cube gets too close to the new cube the enemy cube will run away!
Here is the updated Engine: (works in DBPRO and DBC)
Rem Project: AI Engine
Rem Created: 09-01-2005 18:20:53
Rem ***** Main Source File *****
` AI Engine
`This code is written by : The Nerd
remstart
feel free to use this code Royalty free in you Commercial products and freeware products
I do NOT take any responsibility IF this code should give your computer any problems
Thank you for trying the code!
Have fun!
remend
` The sync setup
sync on
sync rate 30
` make the object for the army.
make object box 4,5,5,5
scale object 4,5,5,5
color object 4, RGB(0,255,255)
position object 4, -2,0,0
` 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 player variables :
playerx# = 0
playery# = 0
playerz# = 0
` make the enemy object.
make object box 2,5,5,5
scale object 2,5,5,5
color object 2, RGB(255,0,0)
` make the enemy variables :
enemyx# = -3
enemyy# = 0
enemyz# = 0
enemyspeed# = 0.3
stop# = 0
` position the enemy object.
position object 2,enemyx#,enemyy#,enemyz#
` **THIS IS THE START OF THE MAIN LOOP**
Do
` make the enemy AI.
move object 2, enemyspeed#
point object 2,playerx#,playery#,playerz#
if playerz#<-playerz# and playerz#=playerz#
move object 2,-0.4
endif
` Make the control input for the player.
if upkey() = 1 then playerz#=playerz#+0.6
if downkey() = 1 then playerz#=playerz#-0.6
if rightkey() = 1 then playerx#=playerx#+0.6
if leftkey() = 1 then playerx#=playerx#-0.6
` The collision system
if playerz#>10 and playerz#=playerz# then playerz# = 10
if playerz#<-4 and playerz#=playerz# then playerz# = -4
if playerx#>3 and playerx#=playerx# then playerx# = 3
if playerx#<-3 and playerx#=playerx# then playerx# = -3
` position the player object in the middle of the screen.
position object 1,playerx#,playery#,playerz#
sync
loop
THE ENGINE (Works for DBPRO and DBC) :
` AI Engine
`This code is written by : The Nerd
remstart
feel free to use this code Royalty free in you Commercial products and freeware products
I do NOT take any responsibility IF this code should give your computer any problems
Thank you for trying the code!
Have fun!
remend
` 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 player variables :
playerx# = 0
playery# = 0
playerz# = 0
` make the enemy object.
make object box 2,5,5,5
scale object 2,5,5,5
color object 2, RGB(255,0,0)
` make the enemy variables :
enemyx# = -3
enemyy# = 0
enemyz# = 0
enemyspeed# = 0.3
` position the enemy object.
position object 2,enemyx#,enemyy#,enemyz#
` **THIS IS THE START OF THE MAIN LOOP**
Do
` make the enemy AI.
move object 2, enemyspeed#
point object 2,playerx#,playery#,playerz#
` Make the control input for the player.
if upkey() = 1 then playerz#=playerz#+0.6
if downkey() = 1 then playerz#=playerz#-0.6
if rightkey() = 1 then playerx#=playerx#+0.6
if leftkey() = 1 then playerx#=playerx#-0.6
` The collision system
if playerz#>10 and playerz#=playerz# then playerz# = 10
if playerz#<-4 and playerz#=playerz# then playerz# = -4
if playerx#>3 and playerx#=playerx# then playerx# = 3
if playerx#<-3 and playerx#=playerx# then playerx# = -3
` position the player object in the middle of the screen.
position object 1,playerx#,playery#,playerz#
sync
loop