Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-07-2001, 03:51 PM   #1
frodo
Registered User
 
Join Date: Apr 2001
Location: london
Posts: 7
Default platform type game thing!!

I am currently working on a platform type game and after much searching on different actionscript forums i managed to find some code on this forum :

-- CODE ON THE HERO MOVIE CLIP --

Code:
onClipEvent(load){
	MovieClip.prototype.keepOnFloor = function(gr,floor){
		this._y+=this._gravity+=gr;
		var pos=new Object();
		pos.x=this._x; pos.y=this._y;
		for (var i=0;i<=this._gravity; i++){
			if (floor.hitTest(pos.x,pos.y -i,1)){
				while(floor.hitTest(pos.x,pos.y -i,1)){
					pos.y--;
				}
				this._y=pos.y-i;
				this._gravity=0;
			}
		}
	}
}

onClipEvent(enterFrame){
	if (key.isdown(key.LEFT)) {_x-=5;}
	else if (key.isdown(key.RIGHT)) {_x+=5;}
	else if (key.isdown(key.UP)&&this._gravity==0){
			this._gravity=-50;
	}
	this.keepOnFloor(7,ground);
}
--CODE IN PLATFORM MOVIE CLIP--

Code:
onClipEvent(enterFrame){
	if (hitTest("_root.hero")){
		_root.hero.ground = this; 
		//trace(this);
	}
}
The code works like this:

If the hero is detected on a platform the name of that platform is passed to the hero movie clip via this as is indicated in the platform movie clip.
This work some of the time but at others the hero just falls through the platform. If there is anyone who can help in any way it would be well apprieciated.Thanks.
frodo is offline   Reply With Quote
Old 12-08-2001, 03:21 AM   #2
20 Ton Squirrel
Risu Oyabun!
 
20 Ton Squirrel's Avatar
 
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
Default Answer type reply thing!

Yo! I, too, have suffered at the hands of side-scrolling fruity goodness... with my hero plummetting to doomy doom despite ingenious code. Indeed even the Friends of Ed, who are indirectly friends of mine because I happen to like Ed, have tasted the bitter tang of defeatedosity.

THE WEED OF CRIME BEARS BITTER FRUIT!!!!

Ummm... right. You might want to check out a marvelous book by the Friends of Ed titled Flash 5 Game Studio. Contained in this book are samples galore of gaming things.

In fact, on the FOE website you can find sample code that deals with THIS VERY PROBLEM... sort of. I found that the character still fell through despite their rather clever collision detection. But heck, it's a start, right? Check it out...

20 Ton Squirrel's Shameless Plug for FOE
20 Ton Squirrel is offline   Reply With Quote
Old 12-08-2001, 12:50 PM   #3
frodo
Registered User
 
Join Date: Apr 2001
Location: london
Posts: 7
Default big thanks for reply

Thanks for the reply 20 after about 2 hours of extra tweeking i managed to solve it, to a certain extent, but the man still seem to fall through before the code compensates and puts the hero on the platform. So yes, i suppose it works.But being the perfectionist i am [--this being my new years resolution or will be,oh yes!!--] i want the hero to fall and land first time on the platform. But your right, it's a start..
I have a copy of Flash 5 Games Studio and i have seen the code which you mensioned, i think, but i will have a closer look. And i'll have a look on FOE web site.
Thanks a lot again..

Last edited by frodo; 12-08-2001 at 12:55 PM..
frodo is offline   Reply With Quote
Old 12-08-2001, 06:25 PM   #4
20 Ton Squirrel
Risu Oyabun!
 
20 Ton Squirrel's Avatar
 
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
Default

Post up if you find a good solution, I'd like to hear it. Maybe when I get some of the current crap off my plate o' projects I can come back to this one... if I find anything I'll let you know as well.
20 Ton Squirrel is offline   Reply With Quote
Old 02-22-2003, 02:59 PM   #5
303 maddec
Flasher since 1998
 
303 maddec's Avatar
 
Join Date: Jan 2003
Location: Switzerland
Posts: 239
Talking around this tutorial, rescue run--> mario

I'm looking around this tutorial from friends of ed (recuerun) now, I don't know if you're always interested on

Yes, I think too that it is a good point to begin... but do you go further into this, did you made some improvements?

First there is a bug when the character is fallingdown after a jump,
the movement don't go fluently to the platform, there is little jerk, do you know how to explain this problem? Is it because platform coord. aren't integer???

second I'm trying to make this game better, and be as near as possible to a mario game in the quality of the playability etc...
(very ambitious ).
the first problem I saw, is that all jump are the same height because the scripting don't use a on clipevent (keyUp).
I have tried to use one and put: speedVert*=-1;
so the hight of the jump is changing depending on how much time you push your key down.... but it didn't play very well,,,
because jerks. I'm going looking around this problem now...
maybe the jump() function is a bit too much simple???
I'm interested on your reply about that, and about what you experienced yourself...

second I have put a specific value for maxspeed and speedincrement to use during the jump, --> the character is less easily moveable during a jump than during his walking....
like in mario....

more later........
Thank you for your help and comments.
303 maddec 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
OHawk.com Flash Game Competition jorisvdb Just for Kicks Challenges 6 10-10-2004 08:30 PM
[AS2] Problems with platform game (jumping and collision issues) Amaster Gaming and Game Development 6 09-14-2004 10:26 PM
Need help with platform game actionscript... mortalpoet ActionScript 1.0 (and below) 0 03-17-2004 10:46 AM
Get movieclip type deogee ActionScript 1.0 (and below) 12 06-01-2003 07:11 PM
duplicate type thing limpduck ActionScript 1.0 (and below) 0 03-30-2001 01:08 AM


All times are GMT. The time now is 03:28 AM.


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