Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-11-2008, 05:55 PM   #1
hott5hotj
Registered User
 
Join Date: Dec 2007
Posts: 14
Default Shooting Game

Hi, I am trying to create a shooting game and have got it working, but now I want to add a new object to shoot, but when I try to create another object only the first object appears. I want basically the random appearance of the object1 and 2, so its either 1 or 2 that comes down but not alternating...it can show up randomly...Can anyone help me?

Code:
var bulletSpeed=9;
var bulletReady=true;
var bulletDelay=150;
var bulletArray=[];
var bulletCount=0;
function createBullets(){
	var bulletMc= this.attachMovie("bullet","bullet"+bulletCount,1000+bulletCount);
	bulletCount++;
	bulletMc._x=AngrycanMc._x+(AngrycanMc._width/2)-(bulletMc._width/2);
	bulletMc._y=AngrycanMc._y+bulletMc._height;
		bulletArray.push(bulletMc);
}
function moveBullets(){
	if(bulletReady &&Key.isDown(Key.SPACE)){
		bulletReady= false;
		currentTime= getTimer();
		createBullets();
	}else{
		if(currentTime+bulletDelay<=getTimer()){
			bulletReady=true;
		}
	}
	for(var i = 0; i<bulletArray.length;i++){
		var b = bulletArray[i];
		if (b._y>-50) {
			b._y-=bulletSpeed;
		} else {
			removeMovieClip(b);
			bulletArray.splice(i, 1);
		}
		if (!hit) {
			if(b.hitTest(ob,ob2)) {
				hit = true;
				ob.play();
				removeMovieClip(b);
				bulletArray.splice(i, 1);
			}
		}
	}
}
var hit = false;
var obSpeed= 2;




function createObject(o) {
	ob = this.attachMovie(o, o, 100);
	ob._x = random(180)+20;

}




	
function resetObject() {
	ob._x= random(180)+20
	ob._y = -40;
	ob.gotoAndStop(1);
	ob.restart = false;
	hit = false
}
function moveObject() {
	if (ob._y<250) {
		ob._y+=obSpeed;
	} else {
		resetObject();
	}
	if (ob.restart) {
		resetObject();
	}
}
createObject("object1");
this.onEnterFrame = function() {
	moveObject();
	moveAngrycan();
	moveBullets();
}



;



		
	AngrycanMc.onRollOver=function () {
		getURL("http://www.mrkabz.com","_blank");
	}
hott5hotj is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
shooting game problems darkman Gaming and Game Development 5 10-18-2009 05:02 PM
FlashGameLicense.com - virtual marketplace to connect game developers and buyers AdamSchroeder General Chat 0 12-18-2007 09:16 PM
Rate My Game, plz fill the questioner UzumakiJr Site Check 0 12-16-2006 08:48 PM
[AS2] help with mi shooting game BLADEDARK Gaming and Game Development 1 04-18-2006 01:50 AM
Shooting game problem Morret Gaming and Game Development 1 06-16-2005 04:11 AM


All times are GMT. The time now is 05:47 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.