To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Actionscript 3.0

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 11-25-2009, 01:58 PM   #1
Jdsflash
Senior Member
 
Join Date: May 2005
Location: Wisconsin
Posts: 130
Question Game code issue - as3 newbe

I want to move these boxes around the screen independantly. For level 4 I get stuck in what I dont no. The boxes also seem to move as a unit too.

I feel like there is a more simple way to do what I want here too. Go easy one me this is my first attmpt at simple gaming code.

Link to the swf - Get to level 4 and you will see the issue.
http://www.wisc-online.com/prototypes/Jgame/shooter.swf

Full source files
http://www.wisc-online.com/prototypes/Jgame/shooter.zip

Heres an image of what I want to happen.

Code:
 

var Dir:String = "down"
var Speed:Number = new Number()
addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
	if(CurLevel == 1){
		//Do not move boxes
	}else if(CurLevel == 2 && CanPlay =="yes"){
		Movelevel2("mc0");
		Movelevel2("mc1");
		Movelevel2("mc2");
		Movelevel2("mc3");
	}else if(CurLevel == 3 && CanPlay =="yes"){
		Movelevel3("mc0");
		Movelevel3("mc1");
		Movelevel3("mc2");
		Movelevel3("mc3");
	}else if(CurLevel == 4 && CanPlay =="yes"){
		Movelevel4("mc0");
		Movelevel4("mc1");
		Movelevel4("mc2");
		Movelevel4("mc3");
	}
}


function Movelevel4(mc:String) {

	for (i=0; i<4; i++) {
		if(this[mc].x>720){
			Dir = "downleft"
		}else if(this[mc].x<-50){
			Dir = " upright"
		}else if(this[mc].y>500){
			Dir = "upleft"
		}else if(this[mc].y<150){
			Dir = " downright"
		}
	}
	if(Dir == "downright"){
		for (i=0; i<4; i++) {
			this[mc].x+=Math.ceil(Math.random()*3);
			this[mc].y+=Math.ceil(Math.random()*3);
		}
	}else if(Dir == "upright"){
		for (i=0; i<4; i++) {
			this[mc].x+=Math.ceil(Math.random()*3);
			this[mc].y-=Math.ceil(Math.random()*3);
		}
	}else if(Dir == "downleft"){
		for (i=0; i<4; i++) {
			this[mc].x-=Math.ceil(Math.random()*3);
			this[mc].y+=Math.ceil(Math.random()*3);
		}
	}else if(Dir == "upleft"){
		for (i=0; i<4; i++) {
			this[mc].x-=Math.ceil(Math.random()*3);
			this[mc].y-=Math.ceil(Math.random()*3);
		}
	}else if(Dir == "down"){
		for (i=0; i<4; i++) {
			this[mc].x+=Math.ceil(Math.random()*3);
			this[mc].y+=Math.ceil(Math.random()*3);
		}
	}
	}
__________________
Josh
Multimedia Programmer
flashmajic.com
Jdsflash is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Actionscript 3.0

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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


All times are GMT -4. The time now is 10:30 AM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.