You are not logged in.
Announcement
#1 22/08/08 2:48am
- Breakeraj
- Addict
- Registered: 19/02/08
- Posts: 240
Add intellegence to Enemys?
I am trying to make a platformer game and i've looked around for a tutorial on how to add intellegence to an enemy. I want the enemy to follow the player around.Could someone help me with that?Please i've searched alot for tutorials.
Offline
#2 22/08/08 3:08am
- crimsonhotsun
- Hardcore Member
- Registered: 30/03/08
- Posts: 96
Re: Add intellegence to Enemys?
if(pl._x<enemy._x){
enemy._x--;
}
else if(pl._x>enemy._x){
enemy._x++;
}
if(pl._y>enemy._y){
enemy.jumping=true;
enemy.gravity=-5;
}
Figure it out...
[img]http://img101.imageshack.us/img101/9094/20707804nc6.png[/img]
My humble forums: [url=http://hologram.zxq.net/forums/]VirtualWorldForums[/url]
Offline
#4 22/08/08 8:38pm
- Breakeraj
- Addict
- Registered: 19/02/08
- Posts: 240
Re: Add intellegence to Enemys?
crimsonhotsun wrote:
if(pl._x<enemy._x){
enemy._x--;
}
else if(pl._x>enemy._x){
enemy._x++;
}
if(pl._y>enemy._y){
enemy.jumping=true;
enemy.gravity=-5;
}
Figure it out...
Ok i tried that and nothing really happened.So i rename the "pl" to player?
Then what should i do with the code?
Offline
#5 23/08/08 12:48am
- crimsonhotsun
- Hardcore Member
- Registered: 30/03/08
- Posts: 96
Re: Add intellegence to Enemys?
Put a sprite on the screen named "enemy". Then put the pl on the screen. Add this:
if(enemy.jumping){
enemy._y+=enemy.gravity;
enemy.gravity-=1;
if(enemy._y>=ground._y){
enemy.jumping=false;
enemy._y=ground._y;
}
}
put the whole thing in this:
enemy.onEnterFrame=function(){
//put all the code here
}
make sure all this code is on the stage, or it won't work.
You should do simpler tutorials to learn more about flash, your knowledge (I don't mean to insult) seems small concerning flash.
Last edited by crimsonhotsun (23/08/08 12:49am)
[img]http://img101.imageshack.us/img101/9094/20707804nc6.png[/img]
My humble forums: [url=http://hologram.zxq.net/forums/]VirtualWorldForums[/url]
Offline
#6 23/08/08 2:58am
- Breakeraj
- Addict
- Registered: 19/02/08
- Posts: 240
Re: Add intellegence to Enemys?
crimsonhotsun wrote:
Put a sprite on the screen named "enemy". Then put the pl on the screen. Add this:
if(enemy.jumping){
enemy._y+=enemy.gravity;
enemy.gravity-=1;
if(enemy._y>=ground._y){
enemy.jumping=false;
enemy._y=ground._y;
}
}
put the whole thing in this:
enemy.onEnterFrame=function(){
//put all the code here
}
make sure all this code is on the stage, or it won't work.
You should do simpler tutorials to learn more about flash, your knowledge (I don't mean to insult) seems small concerning flash.
Thanks.I'll try that out later.But i've been trying lots of tutorials i found but im really not that good at flash.
Offline
#7 23/08/08 3:00am
- crimsonhotsun
- Hardcore Member
- Registered: 30/03/08
- Posts: 96
Re: Add intellegence to Enemys?
Nobody starts out good at flash. I didn't even know what actionscript was. It's taken me 2 years to learn but no one can tell me I don't know now. Practice and dedication make a good programmer. Just keep trying. It'll come to you.
[img]http://img101.imageshack.us/img101/9094/20707804nc6.png[/img]
My humble forums: [url=http://hologram.zxq.net/forums/]VirtualWorldForums[/url]
Offline
#9 24/08/08 2:47pm
- nothing
- Moderator
- Registered: 21/03/08
- Posts: 389
Re: Add intellegence to Enemys?
Lol 1337 isn't a programming language...
[url=http://pspflashgaming.com/forum/viewtopic.php?id=1078]BioShock[/url] PSP|fPS-Factor Released|[url=http://www.p22server.hostwq.net/index.html]p22 Center[/url]
I'm starting p22 again.
Offline
#10 24/08/08 7:29pm
#11 25/08/08 12:18am
- nothing
- Moderator
- Registered: 21/03/08
- Posts: 389
Re: Add intellegence to Enemys?
lol
[url=http://pspflashgaming.com/forum/viewtopic.php?id=1078]BioShock[/url] PSP|fPS-Factor Released|[url=http://www.p22server.hostwq.net/index.html]p22 Center[/url]
I'm starting p22 again.
Offline
#12 25/08/08 12:34pm