ActionScript 2.0 :: Defense Game - Randomize Enemies?

Oct 6, 2007

I'm making a little tower defence game but i've run into a problem;I need a code to randomise my enemies (like in which direction they come from, and how many come)

View 1 Replies


Similar Posts:


Flash :: Tower Defense - Detecting If The Bullet Hits The Enemies

Apr 22, 2011

I am creating a tower defense game and I want to make a tower that shoots a bullet and every enemy that the bullet hits is damaged. The bullet can hurt multiple units. My problem is detecting if the bullet hits the enemies. Right now, I have the enemies in an array. With other towers, when an enemy is in range, the tower fires and when it hits its original target, it causes damage to that target.

For the tower I want to make, it will shoot the bullet the maximum range every time and I need it to damage every unit it hits on the way to that final destination.

View 4 Replies

Tower Defense Game Bullet Disappear

Mar 16, 2010

I found a tutorial on the internet and have begun toying with it. I figured out what all the segments did and how they worked and effected the game (mostly through trial and error...) once i figured out what EXACTLY i had i started making changes.

-What i want - once the bullet hits a monster OR goes out side of the range of the gun it disappears and another shot can be fired (which is done automatically via my script no user input needed)

-What i have - when the bullet goes off the page (x>550, x<0, Y>400, Y<0) it disappears and another shot can be fired... obviously this is problematic to game play...

[Code]..

View 1 Replies

IDE :: Tower Defense Game Bullet Disappear?

Mar 16, 2010

-What i want - once the bullet hits a monster OR goes out side of the range of the gun it disappears and another shot can be fired (which is done automatically via my script no user input needed)

-What i have - when the bullet goes off the page (x>550, x<0, Y>400, Y<0) it disappears and another shot can be fired... obviously this is problematic to game play...

Code:
Stop();
base_range = 200;
can_be_placed = false;

[code]....

View 1 Replies

ActionScript 3.0 :: Tower Defense Type Game - Object Access?

Feb 14, 2012

I am hammering out a Tower Defense type game. I'm starting to design my custom unit mechanics. I've used numerous other tutorials for the framework here (largely one mans blog - credited in my AS3 file..) I want when a unit dies, that it runs a function - checks a field I've created within the unit called a 'tag' - and depending on that do other things. From within the kill() function I successfully call my infantryDeath() function, and I've verified within kill() it's recognizing the dead objects tag. I've verified the entry into infantryDeath() and that the tag is still the same.

Here's the problem:
function infantryDeath(creep){
//inGameMessage("infantryDeath() successfully called"); <-- works
//inGameMessage("Unit died with ID: " + creep.tag); <-- properly shows the ID of the "creep" it received
inGameMessage(this); <-- prints out _level0 (the id for the level itself)
if (creep.tag = c1) <-- the unit with this tag dies, and triggers this block successfully{
[Code] .....

I have no clue why the object I'm supposedly working with changes just by virtue of being within the "if" block. If I pass an object into a function shouldn't manipulating that object remain constant within that function?

View 9 Replies

ActionScript 3.0 :: Platform Game 0 Can't Get Enemies To Face Hero

Nov 24, 2010

I'm making a platform game. The hero can move around, but the enemies are stationary. My problem is that I want the enemies to face the hero. The first enemy behaves correctly, but the subsequent enemies only behave correctly if I kill all the preceding enemies. I have added the hero and the enemies as Objects and put the enemies into an array called enemies. Both the hero and enemy objects have a direction property and an mc property that refers to their movie clips. This for loop gets called every frame.

for(var i:int = 0; i < enemies.length; i++)
{//face hero
if(hero.mc.x < enemies[i].mc.x) enemies[i].direction = -1;
else if(hero.mc.x > enemies[i].mc.x) enemies[i].direction = 1;
enemies[i].mc.scaleX = enemies[i].direction;}

View 4 Replies

ActionScript 3.0 :: Flash Platform Game Random Enemies?

Feb 22, 2011

we just recently defended our graduation project which is a platform game like mario. one of the modifications suggested by our panelists is to make level 1 generate random places for enemies and coins after one of them said that mario was a stupid game because you already know where the enemies are, the powerups, etc. i said i'll give it a go and see what i can do. but recently i realized that i havent played any platform game that generates random places for the enemies, coins and other objects. it is only in rpg games like ragnarok that i have seen enemies spawning at random places.

View 1 Replies

ActionScript 3.0 :: Randomize Game Display Different Characters

Jan 13, 2011

I've a question to ask regarding randomization using actionscript. Given a situation where you have different designed game characters and you would like to display different characters as the player replay/restart the game. How would you go about doing so?

View 5 Replies

ActionScript 2.0 :: Game Project - Placing Unique Instances Of Enemies On Screen

Mar 23, 2010

I've been working on a uni project. Basically, enemies are placed on the screen using a timer variable and using the attachMovie to put them on the screen. This is an example of the code I'm using:

Actionscript Code:
var enemies;var timer;
function onLoad(){
enemies = [];
timer = 0;}
function onEnterFrame(){timer++;
if (timer == 10) {
Timer = 0;
var enemy = _root.attachMovie("mc_1", "mc_1",
_root.getNextHighestDepth());
enemies.push(enemy);
}}

This works and places them on the screen, (and into the array) but by putting them into the array, I thought that each one would be a unique instance of the movieclip which doesn't always seem to be the case. If I shoot one of the enemies, sometimes another enemy will explode (or both of them) and other times I will knock into one enemy and another one will be the one who get's knocked.

For my collision code I'm using this:
Actionscript Code:
for(var i in _root.player.enemies){
if (some arguments..)
_root.player.enemies[i].health -= 10;
}}
The explosion code also uses a similar for loop. Should I look at another method to place unique instances of the enemies on the screen?

View 3 Replies

ActionScript 3.0 :: Chasing Hero Game Character As A Square And The Enemies Are Circles At The Moment

Sep 11, 2009

i am making a game and i have my main character as a square and the enemies are circles at the moment. i have just made the circles home in on the main character, but my problem is when the enemies come inline with the x or y coordinates of my character they start vibrating/shaking. im not sure how to fix this. i have included my fla so you can easily see whats going wrong.

View 1 Replies

ActionScript 2.0 :: Enemies On Minimap(radar) And Warping For Enemies

Feb 25, 2010

as from title above, minimap where enemies spawn and can be shown on the minimap and enemies warp like player_mc do. ps: i'm new to this forum. attached files below

View 0 Replies

ActionScript 3.0 :: Working On A Basic, Horizontal Shooter Platform Game - Make Enemies Move Smart, Towards The Player?

Oct 3, 2011

i am an newbie as3 developer, and i am working on a basic, horizontal shooter platform game.and my question is: how can i make enemies move smart, towards the player? ( but ofcours you are in able to dodge)so like, an enemy is moving to me so when i am not dodging, it will hit the player.

View 2 Replies

ActionScript 3.0 :: Put Enemies In An Array?

Jan 3, 2011

I'm making a Space Shooter Game for school and I just can't find how to put my enemies in an array. I found this code in an other thread

[Code]...

So what I need to make is 2 arrays, one arrEnemies where I put my emenies in and the other one arrBullets where the bullets go. Then these 2 arrays do a collision check

View 14 Replies

ActionScript 2.0 :: Make Multiple Enemies That Look Same?

Dec 22, 2010

I just started Flash like 2 weeks ago, so im not very good. Im making a game where you pick a character, and shoot pigs. Every pig you shoot adds 500 points to your score. Problem is only one pig works. If i copy and paste that pig and his code (as2), when i shoot one pig both pigs explode, giving me 1000 points. How can i make it so that when i shoot one pig, one pig explodes, and i get 500 points?[code]...

View 4 Replies

ActionScript 1/2 :: Distant Enemies Dont Appear?

Aug 31, 2011

i will explain my problem according the 11th enemy (the last enemy in the level). i past here the answers i gave to people fron other forums..I'm making a platform game, and i have a problem. i am attaching 11 enemys, and my last enemy not appears. the _X of the 11th enemy is 3300.I  tried a lot of stuff, and think, I discovered the source of the problem.on my hero class i wrote this:
 
_root._x -= (_root._x + (_x - 275)) / 5;

and when i changed it to this:

_root._x = -_x;

the last enemy appears!but i want it to be like first one.but it doesnt work.also, i found that if i placed the hero close to the last enemy, the last enemy appears.the _root._x refer to the stage and the _x refer to the hero.i found that if i remove this code(the gravity in the enemy class):

_y += grav;
grav += gravity;
while(ground.hitTest(_x, _y, true)){[code]....

View 1 Replies

ActionScript 1/2 :: Spawning Enemies Loop?

Feb 16, 2012

im making a script where it spwans enemies when the enemy count is lower then or equal to the CurrentEnemys.
but it spawns like 200 enemys and says the function is looping and my CurretEnemys trace says NaN..
 
Hers the script.
 
enemyCount = 0;
CurrentEnemys = 5; 
function startwave(){

[code]....

View 7 Replies

ActionScript 3.0 :: Creating A Enemies Killed Counter?

Mar 20, 2009

Everytime a monster dies, I want the monsters killed dynamic text field to increase the number by 1. I gave it a good shot but it feels like im missing something basic, Im fairly new to this still but picking it up quickly. The following code is inside of a movieClip dealing with the monsters. The second block of code is on my main timeline.

Quote:

import fl.motion.Animator;
import fl.motion.MotionEvent
var this_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>

[code]....

View 2 Replies

ActionScript 3.0 :: Rotating Enemies Along A Curved Surface?

Apr 14, 2009

This one concept has been bugging me for days now and I can't seem to solve it. You see, I'm trying to rotate my enemies along an uneven surface. So far, they follow along it perfectly, using my hitTestPoint collision checks.But I don't know how to rotate the collision points and thus rotate the movieclip along the curve so it remains clipped to the ground like in Fancy Pants Adventure 2 or a tanks game.Here is what it looks like right now

View 3 Replies

ActionScript 3.0 :: Refer To A The Value Of Enemies 1 Through 4 With The One Trace Line

Jul 19, 2010

I want to refer to a the value of enemies 1 through 4 in this script with the one trace line, so it will trace,"this is enemy1", "this is enemy2", etc., but I don't know what to write exactly after trace.

[Code]....

View 3 Replies

Professional :: Create Multiple Enemies And Be Able To Do HitTests Against Them?

Oct 12, 2010

i got this flash with duplicated mc's say...enemy1, enemy2, enemy3. now we all know we can do something such as..
 
if {_root.blah.hitTests(_root.enemy)){_root.enemy.nextFrame();}}
 
because the enemy is duplicated and its no longer "enemy" but enemy12 or ****.is there any way to ...create multiple enemies and be able to do hitTests against them somehow.Also im not really a fan of attachMC

View 5 Replies

ActionScript 1/2 :: Making Enemies Collide With Eachother?

Jun 8, 2007

I've got a function here that spawns an enemy for me and I'm calling it in a loop every few seconds or so that it creates a new enemy every second. This all works great.What I want to do though, is to make the enemies collide with each other. How would I go about doing this? I've tried using hitTestm but it detects that each enemy is hitting itself which is always.I've attached my code.

View 2 Replies

ActionScript 2.0 :: How To Make Random Enemies Spawn

Jan 18, 2011

can anyone give me any idea on how to make random enemies spawn with this code? The export is evil, for the enemies. I've tried a random function but it just doesn't work. Can anyone take this code and make enemies spawn randomly? Like can anyone actually modify it and the put it in their reply?Also, I don't care whether the enemies come from vertical or horizontal directions. The size of the flash is 550 x 400.[code]

View 1 Replies

ActionScript 3.0 :: Randomize Again If Value Isn't In The Array

Mar 24, 2009

What i need to do is to randomize the variable named: randomCard if randomCard doesnt equal any value of myCards array. (randomize again if the value of randomCard isnt in the myCards array)

obviously youll notice that in this part of the code: while (randomCard != myCards); myCards isnt correctly defined

Code:
private var myCards:Array = [0,2,4];
do {
randomCard = Math.floor(Math.random()*4);

[Code].....

View 1 Replies

ActionScript 2.0 :: Randomize A Set Of Numbers?

Dec 29, 2009

How would you randomize a specific set of values in a array?[code]...

View 6 Replies

ActionScript 1/2 :: Randomize Mp3 Player?

Sep 6, 2009

I'm using this code I obtained from a tutorial to run an mp3 player that reads an .xml playlist. Could someone please tell me what I'd need to add/change to the code so that it plays the tracks in a random order each time the player loads - I'm not concerned about omitting repeats. I've tried adding a "random" command to the Array that holds the tracks but this didn't work.

//Setup sound objectvar s:Sound=new Sound();s.onSoundComplete=playSong;s.setVolume(75);
//Array of songsvar sa:Array = new Array();
//Currently playing songvar cps:Number=-1;[code].......

View 7 Replies

ActionScript 3.0 :: Randomize Which Button Does What?

Oct 30, 2009

I need to make an animation in which you are shown 5 doors. if clicked, 4 of the doors will make the screen fade out, and a message that says congratulations will pop up. however, 1 of the 5 doors will make a tiger jump out if it is clicked.however, the door that the tiger should be assigned randomly.

View 3 Replies

Professional :: Randomize MP3 Player?

Sep 16, 2010

I have a simple mp3 player in AS2 and I need a way to randomize the songs.Here is my AS2 code.
 
var s:Sound = new Sound();s.onSoundComplete = playTracks;s.setVolume(75);
 
var sa:Array = new Array();var cps:Number = -1;var pos:Number;[code].....

View 3 Replies

Flash :: Randomize Output In Pro CS5?

May 26, 2011

Does anyone know if it is possible to randomize assets in Flash. Basically I am creating a flash based application which when the user hits a target button the preceeding screen should show a completely random asset (which would be an SWF), at the moment each button is simply tagged to a particular swf, although i need it to be more random than this?

View 1 Replies

ActionScript 2.0 :: How To Randomize Operator

Mar 1, 2003

I'm trying to get flash to randomize an arithmetic operator from a set of operators, i.e.operators = + - * / etc and I want flash to randomly pick one from the list!How do I do this? I looked at the random tut on kirupa but I don't know how to make it work with anything other than numbers!

View 12 Replies

ActionScript 2.0 :: 2 Arrays Randomize Together

Aug 2, 2006

I've got 2 arrays that I want to randomize together. So if array one (1,2,3,4,5) is randomized to be (5,2,3,4,1), how can I have the second array randomize to that order?[code]how can I say "make the xArray correspond with the random order of the zArray" with AS?

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved