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 > General Help > Games

Reply
 
Thread Tools Search this Thread Display Modes
Old 06-11-2004, 10:05 AM   #1
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
[HELP] Screen movement

okay ... I have a game i'm trying to make a rough engine for ... and I'd like some screen motion ... let me explain

I have a viewable area of 550 x 400 but would like the actual stat be about 1650 x 1200. So basically a 3x3 square of 550 x 400. Now I would liek the screen to move with my hero unless it is on the edge ...
Code:
|_a_|_b_|_c_|
|_d_|_e_|_f_|
|_g_|_h_|_i_|
Okay lets say that is the set up ... I'm in "e" if i walk towards "d" the viewable area move to the left untl all of "d" is viable and then my hero just moves towards the wall withouth the screen moving.

I hope I explained this right. Any help is appreciated...

oh yeah this is what I got so far http://fable.abuseadam.com/town.html. Signs and items can be looked at with SPACE by the by.

My hero moves with this code from Ed Mack(?) inthe hittest topic:

Code:
onClipEvent(load){
	s = 10;
	r = 5;
	b = this.getBounds(this);

	function move(x,y){
		if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)){
			if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)){
				if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)){
					if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)){
						_x += x;
						_y += y;
					}
				}
			}
		}
	}
}

onClipEvent(enterFrame){
	if(Key.isDown(Key.UP)){
		move(0,-s);
	}
	if(Key.isDown(Key.UP) && Key.isDown(Key.CONTROL)){
		move(0,-r);
	}
	if(Key.isDown(Key.DOWN)){
		move(0,s);
	}
	if(Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL)){
		move(0,r);
	}
	if(Key.isDown(Key.LEFT)){
		move(-s,0);
	}
	if(Key.isDown(Key.LEFT) && Key.isDown(Key.CONTROL)){
		move(-r,0);
	}
	if(Key.isDown(Key.RIGHT)){
		move(s,0);
	}
	if(Key.isDown(Key.RIGHT) && Key.isDown(Key.CONTROL)){
		move(r,0);
	}
}

Last edited by ashmills; 06-11-2004 at 11:13 AM.
ashmills is offline   Reply With Quote
Old 06-11-2004, 10:35 AM   #2
Squize
Hype over content...
 
Squize's Avatar
 
Join Date: Apr 2001
Location: Lost forever in a happy crowd...
Posts: 5,745
The effect you want is called "Scrolling". Have a search, you'll find a zillion threads about it, honestly

Squize.
Squize is offline   Reply With Quote
Old 06-11-2004, 11:08 AM   #3
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
yes this I knwo ... I did a search and found mostly them saying make the BG move instead of the hero ... alright great idea, but I don't think It works in my case ... tell me if I'm wrong...

I have 2 Issues with this, my first:

I have multiple layers.
A BG Layer: All the objects the hero can walk on.
A MAP Layer: All the stop points the hero can't walk on.
A ROOF Layer: All the object the hero walk behind/under.
A HIT Layer: Hit points for all the object the hero can interact with.

In those layers lie X amounts of items. In order to do this technique all of these items would have to move instead of the hero.

2nd Issue being that I want the hero to move not the screen when the screen comes to an "END" point. Now I assume I just make the screen and hero move at the same rate at all times except when the "END" point comes up, then the screen moves and the hero doesn't ... not of the topics I read delt with these issues ... Further help would be appreciate...

Also ... doesn't anyone know how to pass a form value in a html page to a dynamic text box in Flash? I tried something like
Code:
<script LANGUAGE="JavaScript"> 
<!-- 

function pass_to_flash()
{
	document.town.name.text = document.charform.name.value;
}  

//--> 
</script>
needless to say that didn't work.
ashmills is offline   Reply With Quote
Old 06-11-2004, 11:16 AM   #4
Ihoss
Guest
 
Posts: n/a
have a look at tonypas tile based tutorial. I think he explain it there.

passing a vatiable into flash:
Code:
window.document.[name of movie].SetVariable("/mc/variable",value);
  Reply With Quote
Old 06-11-2004, 11:53 AM   #5
Squize
Hype over content...
 
Squize's Avatar
 
Join Date: Apr 2001
Location: Lost forever in a happy crowd...
Posts: 5,745
ashmills, you've got all the different layers in container mc's ? If that's the case then just moving the containers will scroll the screen ( Just put the player on it's own layer so it doesn't scroll ).
Then when the background scrolls as far as it can you then just use the normal player._x+=speed to move him.

Squize.
Squize is offline   Reply With Quote
Old 06-11-2004, 12:00 PM   #6
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
alright I made them all containers and can make them move ... but I think because of the way I do my hit test ... if the walls touch my hero they go right through him cause he isn't moving everythign else is ... hmm should I use a different hit test or is their away to work around it...

I put this on the objects ...

Code:
onClipEvent(load){
	s = 10;
	r = 5;
	b = _root.hero.getBounds(this);

	function move(x,y){
		if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)){
			if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)){
				if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)){
					if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)){
						_x += x;
						_y += y;
					}
				}
			}
		}
	}
}

onClipEvent(enterFrame){
	if(Key.isDown(Key.UP)){
		move(0,-s);
	}
	if(Key.isDown(Key.UP) && Key.isDown(Key.CONTROL)){
		move(0,-r);
	}
	if(Key.isDown(Key.DOWN)){
		move(0,s);
	}
	if(Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL)){
		move(0,r);
	}
	if(Key.isDown(Key.LEFT)){
		move(-s,0);
	}
	if(Key.isDown(Key.LEFT) && Key.isDown(Key.CONTROL)){
		move(-r,0);
	}
	if(Key.isDown(Key.RIGHT)){
		move(s,0);
	}
	if(Key.isDown(Key.RIGHT) && Key.isDown(Key.CONTROL)){
		move(r,0);
	}
}
hoping tat when the hero touched map all woudl stop ... but needless to say it didn't work


oh yeah and thanks for the JS thing ... i figured it out as soon as the email got sent ot me that you posted ^_^.

Last edited by ashmills; 06-11-2004 at 12:03 PM.
ashmills is offline   Reply With Quote
Old 06-11-2004, 02:41 PM   #7
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
I know I'm being annoying and I'm sorry,

i've been working on this all morning ... and still no luck on the scrolling thing ... my hero just moves through walls when I move the screen insted of him ... I would like to use the hittest method I am using as it serves my purpose extremely well but I can't seem to get it to work with this scrolling feature ... if someone could help me further it would be appreciated...

I'll give a link to the FLA for those who might need it to help..

http://Fable.AbuseAdam.com/town.fla
ashmills is offline   Reply With Quote
Old 06-11-2004, 03:06 PM   #8
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
oh yeah an by the by even though it looks to be tile based at the moment it more than likely will be more art based once I get the basics working ... it is just tile based lookign ot get the basics going. I would like the hit test I do for that reason, I can block of many types of shapes and what not.
ashmills is offline   Reply With Quote
Old 06-11-2004, 05:15 PM   #9
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
alright ... this is where I am at

http://fable.abuseadam.com/townscroll.html

and here is the fla incase someone wants to help...

http://fable.abuseadam.com/townscroll.fla

I'd appreciate any help ... I sure as hell can't figure out how to make the wall hit test still work, or make the scroll stop and my reg walk beging again when I get near an edge ... I appreciate any help in advance...

Walk SE to find the town with walls and fences and the such.

I know why it is happening but not how to fix it. It is happening cause my hero isn't moving the bg is ... so the hit test doesn't succesfully connect for some reason ... must be the way I check ... I guess I'd have to do the hittest with map instead and when it hits hero ... then do my stops? hmm I'm gonna try ... like i said any help is appreciated.

Last edited by ashmills; 06-11-2004 at 05:18 PM.
ashmills is offline   Reply With Quote
Old 06-11-2004, 06:41 PM   #10
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
Okay ...as you can see from the updated fla I tried to do a hit test with the walls on hero movie clip ... but it doesn't seem to work ...

code:

onClipEvent(load){
s = 10;
r = 5;
b = _root.map.getBounds(_root.map);

function move(x,y){
if(!_root.hero.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)){
if(!_root.hero.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)){
if(!_root.hero.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)){
if(!_root.hero.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)){
_x += x;
_y += y;
}
}
}
}
}
}
onClipEvent(enterFrame){


if(_root.scroll == "true")
{


if(Key.isDown(Key.UP)){
move(0,s);
}
if(Key.isDown(Key.UP) && Key.isDown(Key.CONTROL)){
move(0,r);
}
if(Key.isDown(Key.DOWN)){
move(0,-s);
}
if(Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL)){
move(0,-r);
}
if(Key.isDown(Key.LEFT)){
move(s,0);
}
if(Key.isDown(Key.LEFT) && Key.isDown(Key.CONTROL)){
move(r,0);
}
if(Key.isDown(Key.RIGHT)){
move(-s,0);
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.CONTROL)){
move(-r,0);
}

}
}



I don't knwo what else to do ... hmm i'll keep trying..
ashmills is offline   Reply With Quote
Old 06-11-2004, 06:56 PM   #11
ashmills
Senior Member
 
Join Date: Jul 2002
Posts: 184
welp I the moron just realized I was refering to my walls as map ... when they are indeed hit ... so anyhow I've gotten a step closer ... Not it works just fine, but when I'm in the town it thinks I'm still hitting the mc so ... it doesn't scroll I think I can fix that ...


but if you want to tell me how go right ahead.

Last edited by ashmills; 06-11-2004 at 07:02 PM.
ashmills is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:32 PM.


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.