Forum Topic: AS help with AI

(288 views • 17 replies)

This topic is 1 page long.

<< < > >>
Shouting

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 08:41 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438

Ok I am making a game like bunker and everything is done except... I can't seem to figure out how to make the enemies come out randomly or just fall randomly. I could use some help on that plz.


None

ColdLogic

Reply To Post Reply & Quote

Posted at: 2/4/06 08:47 PM

ColdLogic EVIL LEVEL 15

Sign-Up: 11/12/03

Posts: 293

post your code. I'll do it for you if it's easy.


None

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 08:49 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438

At 2/4/06 08:47 PM, ColdLogic wrote: post your code. I'll do it for you if it's easy.

Now by code what part do mean. Cuz theres the player code the health.....


None

ColdLogic

Reply To Post Reply & Quote

Posted at: 2/4/06 08:52 PM

ColdLogic EVIL LEVEL 15

Sign-Up: 11/12/03

Posts: 293

uh oh sounds scarey lol, well show me what you have, upload it to image shack or whatever so I can see how it works, or send me the file. That shouldn't be a hard function to code, I'm bored. fryerdrew@hotmail.com


None

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 09:00 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438

http://img385.images..=basedefender6cs.swf

Alright thats the basic engine. I want it to be colourful! Some things shall be changed um i will add a score board to it but the health bar and the shooting works flawlessly.


None

ColdLogic

Reply To Post Reply & Quote

Posted at: 2/4/06 09:04 PM

ColdLogic EVIL LEVEL 15

Sign-Up: 11/12/03

Posts: 293

looks like your off to a good start, I can easily put enemies in for you if you want, all I need is the file. All i would do is put in the code and a default mc like a circle and have them come at you from the outside.

or I can just tell you how I would do it. whatever you want to do.

this does look way to similar to another game I played though, if you submit it make sure you put something extra and above the one before it.


None

Ani-Money

Reply To Post Reply & Quote

Posted at: 2/4/06 09:07 PM

Ani-Money LIGHT LEVEL 19

Sign-Up: 08/19/05

Posts: 2,622

At 2/4/06 09:00 PM, nintendogeek wrote: http://img385.images..=basedefender6cs.swf

please speed up the bullets, no-one will want to play if the bullets take ages to move. Or will they get faster with like upgrades or something?


None

ColdLogic

Reply To Post Reply & Quote

Posted at: 2/4/06 09:09 PM

ColdLogic EVIL LEVEL 15

Sign-Up: 11/12/03

Posts: 293

it's the basic engine man, of course there is no upgrades, but the code is functioning properly and thats awsome. I agree faster bullets, or the ability to speed them up would be sweet. I think he had that in mind anyway tho.


None

Cojones893

Reply To Post Reply & Quote

Posted at: 2/4/06 09:17 PM

Cojones893 EVIL LEVEL 22

Sign-Up: 03/09/03

Posts: 2,344

I opened up the swf in the browser and I noticed the bullets do not delete themselves once they leave the screen that might be a good idea since left over bullets will cause lag. Also do you want them to come from all the sides?

The code might look like:

rX = Math.round(Math.random())
rY = Math.round(Math.random())
badGuy._x = rX*650-50 //so either -50 or 600
badGuy._y = rY*500-50 //so either -50 or 450

get it? That should provide all sides of the screen with some baddies.


None

ColdLogic

Reply To Post Reply & Quote

Posted at: 2/4/06 09:19 PM

ColdLogic EVIL LEVEL 15

Sign-Up: 11/12/03

Posts: 293

yeah but they also always have to face the turret! think about that part also.


None

Cojones893

Reply To Post Reply & Quote

Posted at: 2/4/06 09:21 PM

Cojones893 EVIL LEVEL 22

Sign-Up: 03/09/03

Posts: 2,344

actually I just noticed my code only brings them from the corners....let me whip up a quick code that actually works


None

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 09:24 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438

Hey thanks for the suggestions and powerups hmmm i might be able to add those in or i could have it so every level up your bullets go faster, but i think im jumping way over my head i think i shall just edit their base speed. And the enemies should come from all angles and when they are shot i want an explosian to finish them off.


None

Cojones893

Reply To Post Reply & Quote

Posted at: 2/4/06 09:40 PM

Cojones893 EVIL LEVEL 22

Sign-Up: 03/09/03

Posts: 2,344

CODE

var d:Number = 0;
var rX, rY, i:Number;
//---------------------------
var xBounds:Number = 550;
var yBounds:Number = 400;
//---------------------------
function createBad(n:Number):Void {
var c:Number = 0;
while (c<n) {
d++;
_root.attachMovie("badGuy", "b"+d, d);
i = Math.round(Math.random());
if (i == 0) {
rX = Math.random()*(xBounds+100)-50;
rY = Math.round(Math.random())*(yBounds+100)-50
;
} else {
rX = Math.round(Math.random())*(xBounds+100)-50
;
rY = Math.random()*(yBounds+100)-50;
}
_root["b"+d]._x = rX;
_root["b"+d]._y = rY;
c++;
}
}

EXPLANATION

First paste all that code in your first frame, then right click on your bad guy in the library, then click "Linkage...", then Click "Export for Actionscript" and "Exports in first Frame" (if not clicked already), then in the indentifier box type "badGuy". To create bad guys type this somewhere in your code:

_root.createBad(1); //that will create 1 bad guy somewhere outside the bounds

or

_root.createBad(10); //that will create 10 bad guys all at the same time outside of the bounds

You can also change the xBounds and yBounds to match your game.


None

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 09:47 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438


You can also change the xBounds and yBounds to match your game.

Whoa thanks alot man I'll give that a try but the other guy is gonna help me out as well so I'm gonna have to see.


None

Xelius

Reply To Post Reply & Quote

Posted at: 2/4/06 09:48 PM

Xelius EVIL LEVEL 21

Sign-Up: 01/07/05

Posts: 385

That's a example from Macromedia Flash MX Game Design Demystified, more specificly the trigonometry chapter. I recommend you take the time to actually read the book and understaning the code, rather than just copying it. Then you'll have no problem extending it into a full game. You can't expect helpful guys like Cojones893 to make the whole game for you. Good luck with it. =)


None

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 09:55 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438

At 2/4/06 09:48 PM, Xelius wrote: That's a example from Macromedia Flash MX Game Design Demystified, more specificly the trigonometry chapter. I recommend you take the time to actually read the book and understaning the code, rather than just copying it. Then you'll have no problem extending it into a full game. You can't expect helpful guys like Cojones893 to make the whole game for you. Good luck with it. =)

Hey I'm not expecting anyone to make a full game for me. I just asked for some help.


None

nintendogeek

Reply To Post Reply & Quote

Posted at: 2/4/06 10:00 PM

nintendogeek LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 438

Oh ya and where exactly would i put _root.createBad(10);
I tried to fit it into the full code but it didn't work. Do i need to have an mc of the badguy just standing outside of the screen then put that code into it.


None

Cojones893

Reply To Post Reply & Quote

Posted at: 2/4/06 10:45 PM

Cojones893 EVIL LEVEL 22

Sign-Up: 03/09/03

Posts: 2,344

no you put that inside another function probably the guys. Just randomly call it. You also don't need the bad guy on the stage since it uses attachMovie and duplicateMovieClip


All times are Eastern Standard Time (GMT -5) | Current Time: 12:40 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!