00:00
00:00
Newgrounds Background Image Theme

fillup69 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Foss: Platformer

2,114 Views | 24 Replies
New Topic Respond to this Topic

Foss: Platformer 2006-01-25 13:28:55


Introduction
Ok, I've worked on this platformer in 2 days now,
and thought it was nice to have as a foss script.
If you thinking on using this script it would be nice if
take alook at the script and try to understand it!

How does it work?
This is a unbugable (i hope, i have had many betatesters)
platform engine that only support right square platforms.
its smooth and it got a nice slide effect when walking.
and you can have as many platforms you want.

How do I use it?
Make a caracther, it needs no instance name.
Covert it to a Movieclip, and all the script is going inside this MC.
Now you must just make as many platforms as you need,
and this is important, to get the platformers to work you must
name them: p1, p2, p3, p4, p5..etc... And in the very start of the code you will
see a variable that says: var platforms:Number = 1; change the number to
how many platforms you have.

So, where's the code?
onClipEvent (load) {
var platforms:Number = 1;
var fall:Number = 0;
var gravity:Number = 15;
var speed:Number = 0;
var maxSpeed:Number = 8;
var jump:Boolean = true;
var jumpSpeed:Number = 0;
var jumpHeight:Number = 8;
}
onClipEvent (enterFrame) {
_y += fall;
if (fall<gravity) {
fall++;
} else {
fall = gravity;
}
_x += speed;
if (Key.isDown(key.RIGHT)) {
if (speed<maxSpeed) {
speed++;
}
} else if (Key.isDown(key.LEFT)) {
if (speed>-maxSpeed) {
speed--;
}
} else {
if (speed<0) {
speed++;
} else if (speed>0) {
speed--;
}
}
if (Key.isDown(key.UP) && !jump && fall<3) {
jump = true;
}
if (jump) {
if (jumpSpeed>0) {
_y -= jumpSpeed;
jumpSpeed -= 0.5;
fall = 0;
} else {
jump = false;
}
} else {
jumpSpeed = 0;
jumpSpeed = jumpHeight;
}
for (i=1; i<=platforms; i++) {
if (hitTest(_root["p"+i])) {
if (_x<_root["p"+i]._x-_width+speed || _x>_root["p"+i]._x+_root["p"+i]._width+spe
ed) {
if (_x<_root["p"+i]._x-_width+speed) {
_x = _root["p"+i]._x-_width;
speed = 0;
}
if (_x>_root["p"+i]._x+_root["p"+i]._width+sp
eed) {
_x = _root["p"+i]._x+_root["p"+i]._width;
speed = 0;
}
} else {
if (_y<_root["p"+i]._y-_height+fall || _y>_root["p"+i]._y+_root["p"+i]._height+fa
ll) {
if (_y<_root["p"+i]._y-_height+fall) {
_y = _root["p"+i]._y-_height;
jump = false;
fall = 0;
}
} else if (_y>_root["p"+i]._y+_root["p"+i]._height-j
umpSpeed) {
if (!jump) {
fall = jumpSpeed;
} else {
_y = _root["p"+i]._y+_root["p"+i]._height;
fall = 2;
}
jumpSpeed = 0;
jump = false;
} else {
if (_x<_root["p"+i]._x-_width+(_root["p"+i]._
width/2)) {
_x = _root["p"+i]._x-_width;
} else {
_x = _root["p"+i]._x+_root["p"+i]._width;
}
}
}
}
}
}

WARNING
There is gonna be some errors in the script because of
the auto format here on NG BBS. So if you want fully code, you
can get it from here: FULL SCRIPT!

Can we see an example
Sure, right here: PLATFORM EXAMPLE!

Questions?
Just post them here, if you are wondering about how
anything in the script works.

Response to Foss: Platformer 2006-01-25 13:32:13


Really liked this.
Nice script ;)


BBS Signature

Response to Foss: Platformer 2006-01-25 13:32:51


Whoa! nice tutorial! :D but you forgot FOSS: Main .

Response to Foss: Platformer 2006-01-25 13:32:53


It's pretty good.

Pastebin removes the codes after a small while, use spaces in your code if you want to avoid Newgrounds line breaks.


BBS Signature

Response to Foss: Platformer 2006-01-25 13:34:05


nice script! Smooth movement too! It's just that you can't control the height of your jump...Anyway it was good, but There are lots of tutorials about this already. I bet there's like 2 or more on "AS: Main" too, if you know that ^^.

Good script...if u use it for a game, good luck with it!

Response to Foss: Platformer 2006-01-25 13:34:31


At 1/25/06 01:32 PM, Ravian wrote: Whoa! nice tutorial! :D but you forgot FOSS: Main .

Ahh shit! your right :P

At 1/25/06 01:32 PM, Rantzien wrote: It's pretty good.

Pastebin removes the codes after a small while, use spaces in your code if you want to avoid Newgrounds line breaks.

damn, i didnt know that! :(

Response to Foss: Platformer 2006-01-25 13:35:46


At 1/25/06 01:34 PM, Rhinan wrote: nice script! Smooth movement too! It's just that you can't control the height of your jump..

sure you can,
do u see the variable:

var jumpHeight:Number = 8; ??

Response to Foss: Platformer 2006-01-25 13:37:42


At 1/25/06 01:35 PM, Creeepy wrote:
At 1/25/06 01:34 PM, Rhinan wrote: nice script! Smooth movement too! It's just that you can't control the height of your jump..
sure you can,
do u see the variable:

var jumpHeight:Number = 8; ??

yeah but i meant the 'how long you press the up-button' thing =P. Ofcourse you can change it in the script, but the player can't!

Response to Foss: Platformer 2006-01-25 13:38:36


...in your example ...while on the first platform... if you jump straight up and hit the platform above, the square shoots to the side... is that supposed to happen?

Response to Foss: Platformer 2006-01-25 13:39:58


At 1/25/06 01:37 PM, Rhinan wrote: yeah but i meant the 'how long you press the up-button' thing =P. Ofcourse you can change it in the script, but the player can't!

sure not, that would just look stupid! :P

anyway thanks for the comments people! :)

Response to Foss: Platformer 2006-01-25 13:41:27


At 1/25/06 01:39 PM, Creeepy wrote:
At 1/25/06 01:37 PM, Rhinan wrote: yeah but i meant the 'how long you press the up-button' thing =P. Ofcourse you can change it in the script, but the player can't!
sure not, that would just look stupid! :P

anyway thanks for the comments people! :)

heh lol ^^. Why would it look stupid if you can control your own hight depending on the time how long you press the up-button? It's in most games!! But still, very, very good script!!

Response to Foss: Platformer 2006-01-25 13:48:32


You know you can make a free website on
http://www.sitesled.com/
and without pop-ups and adfree.
The adress will be pretty long but you can use it as a script shower...

Or, alternatively, you can upload a .txt file with the script here:
http://www.denvish.net/ul/


BBS Signature

Response to Foss: Platformer 2006-01-25 14:02:05


Nice engine dude. :-)


> twitter.

Response to Foss: Platformer 2006-01-25 14:03:49


WARNING:
I forgot to mention that the registration point in the caracther and platform must be in the upper left corner! :)

At 1/25/06 01:41 PM, Rhinan wrote: heh lol ^^. Why would it look stupid if you can control your own hight depending on the time how long you press the up-button? It's in most games!!

is it? i have never seen any platform games where you can do that!
or i saw one once, but i blammed it because i thought it was a bug ^^

At 1/25/06 01:48 PM, -SNAIL- wrote: You know you can make a free website on
http://www.sitesled.com/
and without pop-ups and adfree.
The adress will be pretty long but you can use it as a script shower...

Or, alternatively, you can upload a .txt file with the script here:
http://www.denvish.net/ul/

Ya i think i will add a *.txt file later!

At 1/25/06 02:02 PM, different wrote: Nice engine dude. :-)

thank you, mate! :)

Response to Foss: Platformer 2006-01-25 14:10:53


good tutorial, i love you creepy, you wanna marry me?

Response to Foss: Platformer 2006-01-25 14:13:37


At 1/25/06 02:10 PM, coldk05 wrote: good tutorial

thank you

i love you creepy

I love you to, baby!

you wanna marry me?

lemme think about it! :)

Response to Foss: Platformer 2006-01-25 14:47:44


total OWNAGE !

Response to Foss: Platformer 2006-01-25 14:58:24


At 1/25/06 02:47 PM, ZerOKitchen wrote: total OWNAGE !

thanks i guess! :)

Response to Foss: Platformer 2006-01-25 15:02:18


At 1/25/06 01:28 PM, Creeepy wrote: WARNING
There is gonna be some errors in the script because of
the auto format here on NG BBS. So if you want fully code, you
can get it from here: FULL SCRIPT!

pastebin is temporary. the file will be gone within 12 hours or so.
you need to do something like upload it as an .AS or .TXT to denvish's upload thingy.


BBS Signature

Response to Foss: Platformer 2006-01-25 15:29:47


At 1/25/06 01:28 PM, Creeepy wrote: How does it work?
How do I use it?
So, where's the code?
Can we see an example?

I wonder who asked the questions...

At 1/25/06 03:02 PM, authorblues wrote: pastebin is temporary. the file will be gone within 12 hours or so.
you need to do something like upload it as an .AS or .TXT to denvish's upload thingy.

Already said that...


BBS Signature

Response to Foss: Platformer 2006-02-15 09:22:14


isn't working for me creepy, there is an error with } else {. Can you help?

Response to Foss: Platformer 2006-02-15 10:15:12


I uploaded the correctly formatted code here:
Error free code


BBS Signature

Response to Foss: Platformer 2006-02-24 07:16:56


At 2/15/06 10:15 AM, Rantzien wrote: I uploaded the correctly formatted code here:
Error free code

Thank you, Rantzien! ^^

Response to Foss: Platformer 2006-02-24 10:12:16


Good script, but it kind of feels like the guy(square) is underwater while in space. The controls feel kind of jelly-like, you should tighten them a bit.

Also, just a tip -creepy-, to make your code a bit more readible and shorter:

this is what you have-

for (i=1; i<=platforms; i++) {
if (hitTest(_root["p"+i])) {

you could have done this instead

for (i=1; i<=platforms; i++) {
var mc:MovieClip=_root["p"+i];
if (hitTest(mc)) {

and then as you can see, you could have just used mc everywhere in your code instead of repeating _root["p"+i] all the time. its also alot easier for you to code, because you only have to type in the short mc instead of the long _root["p"+i] when coding.


BBS Signature

Response to Foss: Platformer 2006-02-24 10:16:17


At 2/24/06 10:12 AM, Juice-Tin wrote: Good script, but it kind of feels like the guy(square) is underwater while in space. The controls feel kind of jelly-like, you should tighten them a bit.

yeah, but you can change that in the top, just change the variables how you want it.

and then as you can see, you could have just used mc everywhere in your code instead of repeating _root["p"+i] all the time. its also alot easier for you to code, because you only have to type in the short mc instead of the long _root["p"+i] when coding.

Yeah i was acctually thinking about that, but i never thought my hitTest script would be so advanced and long, so i didnt do it, and when i finished it i just didnt take the time to change it.