Be a Supporter!

As: Platformer with Slopes

  • 6,601 Views
  • 24 Replies
New Topic Respond to this Topic
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
As: Platformer with Slopes Apr. 7th, 2006 @ 11:58 PM Reply

AS:Main

Hey, this is an example of the game.

Controls
Move- Left and Right
Jump-Space
http://denvish.net/u..0_Platformer%206.swf

The special thing about this platformer is that all yu need to do is draw the grounds, and it tells if it is a wall, or a ceiling, or ground.

First create a ball or square or anything, and make it 50X50. (Click properties, and change width and height to 50 and 50) Then make it into a movelcip, and make sure the + is at the exact bottem middle! Then add this code.

// Made by pyro111 April 7, 2006
onClipEvent (load) {
// only happens once
fall = true;
//makes a varialbe called fall, and sets it to true
jump = 0;
// makes and sets jump to 0
jumping = false;
// makes and sets jumpign to false
spd = 0;
// makes and sets spd to 0
grav = 0;
// makes and sets grav to 0
slow = .97;
// makes and sets slow to .97
this.playerB.playerC.gotoAndStop(1);
// only used if you want it to rotate
}
// closes load
onClipEvent (keyUp) {
// if no key is pressed
this.playerB.playerC.gotoAndStop(1);
// makes playerB.playerC stop on frame 1
}
//closes keyUp
onClipEvent (enterFrame) {
// happens every frame
_x += spd;
// makes x go up by spd
this.playerB._rotation += spd;
// makes the rotation spd
if (Key.isDown(Key.SPACE) && grav == 0) {
// if space is pressed and grav is equal to 0
jumping = true;
// makes jumping true
_y -= jump;
// makes y go down (but really up) by the varialbe jump
grav = 0;
// sets grav to 0
fall = false;
// makes fall false
} else {
// otherwise (and the first } closes the if
jumping = false;
// jumping is false
fall = true;
// fall is true
}
// closes the else
if (jumping == true) {
// if jumping is true
jump--;
// makes jump go down by 1
}
// closes the if
if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
// if left or right arent pressed
spd *= slow;
// makes spd multiply by slow (.97)
}
// closes the if
if (spd<.5 && spd>0) {
// if spd is less than .5 and greater than 0
spd = 0;
// makes spd 0
}
//closes the if
if (spd>-.5 && spd<0) {
// if spd is greater than -.5 and less than 0
spd = 0;
// makes spd 0
}
//closes the if
if (Key.isDown(Key.RIGHT) && spd<20) {
// if the right key is pressed and spd is less than 20
spd++;
// makes spd go up by 1
this.playerB.playerC.play();
// makes the movieclip play
}
//closes the if
if (Key.isDown(Key.LEFT) && spd>-20) {
// if left is pressed and spd is greater than 20
spd--;
// makes spd go down by 1
this.playerB.playerC.play();
// makes the movieclip play
}
//closes the if
if (fall == true) {
// if fall is true
_y += grav;
// y goes up (but really down, the axis are inverted) by grav
grav++;
// grav goes up by 1
jumping = false;
// makes jumping false
}
//closes the if
if (grav>20) {
// if grav is greater than 20
grav = 20;
// grav is 20
}
//closes the if
if (_root.gd.hitTest(_x+25, _y-25, true)) {
// if the ground hits the right of this
spd *= -1;
// spd is multipled by 1
jumping = false;
// makes jumping false
fall = true;
// makes fall true
jump = -10;
// makes jump -10
}
//closes the if
if (_root.gd.hitTest(_x-25, _y-25, true)) {
// this the ground hits the left of this
spd *= -1;
// spd is multiplied by -1
jumping = false;
// makes jumping false
fall = true;
// makes falling true
jump = -10;
// makes jump -10
}
//closes the if
if (_root.gd.hitTest(_x, _y-50, true)) {
// if the ground hits the top
jumping = false;
fall = true;
jump = -10;
// same as before withought changing the spd
}
//closes the if
if (_root.gd.hitTest(_x, _y, true)) {
// if the ground hits the bottem
falling = false;
// makes falling false
grav = 0;
// makes grav 0
jump = 10;
// makes jump 10
} else {
// otherwise
falling = true;
// falling is true
}
//closes the else
while (_root.gd.hitTest(_x, _y, true)) {
// while it is touching the ground
_y--;
// this y is subtraceted by 1 (making it go up)
}
// closes the while
}
// closes the enter frame

To make the ground, just draw anything (tiny lines wont work) and call the movieclip gd. Thats all there is to it. Hope I helped someone, and this is my 3rd submission to As:Main.

sinz3ro
sinz3ro
  • Member since: Aug. 2, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to As: Platformer with Slopes Apr. 8th, 2006 @ 12:02 AM Reply

that is really good


// Harvest++ coming soon, more modes, more stuff, customizable character, achievements and more!

BBS Signature
dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As: Platformer with Slopes Apr. 8th, 2006 @ 03:02 AM Reply

not much of a tutorial... :/ this is more suited for FOSS than AS since its only commented code


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
Kromeclutch
Kromeclutch
  • Member since: May. 5, 2005
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to As: Platformer with Slopes Apr. 8th, 2006 @ 08:14 AM Reply

Nice job on the code : ) Thanks!


BBS Signature
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to As: Platformer with Slopes Apr. 8th, 2006 @ 08:17 AM Reply

Ha ha, it rolls uphill :)

Nice, but not really a tutorial - plus I think Joelasticot made a tutorial on this.


Sup, bitches :)

BBS Signature
E-K
E-K
  • Member since: Mar. 4, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to As: Platformer with Slopes May. 30th, 2006 @ 09:15 AM Reply

my ball dsnt rotate.....and it cant go up any walls

blueyedguy
blueyedguy
  • Member since: Mar. 16, 2006
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to As: Platformer with Slopes May. 30th, 2006 @ 09:43 AM Reply

Hey thats really cool thanks for that!

KougaijiGyumao
KougaijiGyumao
  • Member since: May. 26, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As: Platformer with Slopes Jun. 5th, 2006 @ 08:48 PM Reply

At 5/30/06 09:15 AM, E-K wrote: my ball dsnt rotate.....and it cant go up any walls

That doesn't sound right... Anyways, great tut. ^__^

Khao
Khao
  • Member since: Sep. 20, 2003
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As: Platformer with Slopes Jun. 5th, 2006 @ 09:57 PM Reply

At 6/5/06 09:37 PM, Khao wrote: CHECK IN THE AS:MAIN TO SEE IF YOUR IDEA HAS ALREADY BEEN DONE BEFORE DOING ONE, FUCKTARD

pie.

There is always more than one way to do things, and some come out with completly differnt outcomes. Platformers are really differnent, so there are going to be way more than 1 way to do something. There are more than one tutorials on other subjects, too. But whatever.

<deleted>
Response to As: Platformer with Slopes Jun. 14th, 2006 @ 09:01 PM Reply

// Made by pyro111 April 7, 2006
onClipEvent (load) {
// only happens once
fall = true;
//makes a varialbe called fall, and sets it to true
jump = 0;
// makes and sets jump to 0
jumping = false;
// makes and sets jumpign to false

jumpign???

dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As: Platformer with Slopes Jun. 15th, 2006 @ 02:11 AM Reply

At 6/14/06 09:01 PM, Allen1288 wrote: jumping = false;
// makes and sets jumpign to false

jumpign???

who the fuck cares if he made one little typo in a comment? Get a life :X


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
Felix-The-Cat
Felix-The-Cat
  • Member since: Aug. 5, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to As: Platformer with Slopes Jul. 29th, 2006 @ 08:39 PM Reply

At 5/30/06 09:15 AM, E-K wrote: my ball dsnt rotate.....and it cant go up any walls

I think what you need to do is tell Flash, (put this in the actions,) that when move left or right play movie clip.


If you're thinking it, NO! I'm not the same person as that old black & white cartoon character.

DeltaSt0rm
DeltaSt0rm
  • Member since: Jul. 29, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As: Platformer with Slopes Aug. 6th, 2006 @ 09:49 AM Reply

Very good man :D How can you edit how high you can jump?

johnfn
johnfn
  • Member since: Aug. 16, 2003
  • Online!
Forum Stats
Member
Level 20
Blank Slate
Response to As: Platformer with Slopes Aug. 6th, 2006 @ 10:26 AM Reply

No offense but your comment style is terrible, meaning this is almost useless for anyone who wants to LEARN. You leave tons of obvious comments like

spd++;
// makes spd go up by 1

this.playerB.playerC.play();
// makes the movieclip play

Seriously, everyone knows what that does! The problem is that you fail to document how the code actually lets the ball roll. You missed the explaination of the grand scheme of whats going on. This bugs me. :P


[6,11,4,10,2,10,-68,5,15,-68,16,4 ,1,-68,-2,1,15,16,-67].map(function(v){ return String.fromCharCode(v + 100) }).join(""); // updated for web 2.0!

BBS Signature
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As: Platformer with Slopes Aug. 6th, 2006 @ 12:44 PM Reply

At 8/6/06 10:26 AM, johnfn wrote: blah blah blah

This is old and shitty and I want it removed. I made a new one which is much better expalined.

DeltaSt0rm
DeltaSt0rm
  • Member since: Jul. 29, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As: Platformer with Slopes Aug. 7th, 2006 @ 08:14 AM Reply

Sorry, but could I have a link to it please?

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to As: Platformer with Slopes Aug. 7th, 2006 @ 08:16 AM Reply

At 8/6/06 12:44 PM, pyro111 wrote:
At 8/6/06 10:26 AM, johnfn wrote: blah blah blah
This is old and shitty and I want it removed. I made a new one which is much better expalined.

lol, but the comments are pretty bad. You should space them out or something to make it easier to read.


BBS Signature
shade999999
shade999999
  • Member since: Oct. 26, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to As: Platformer with Slopes Nov. 14th, 2006 @ 05:37 PM Reply

OMG THANK YOU! I have been looking for a way to get my character to roll (or walk) up a hill. I have Googl'ed it so much and haven't been able to find how. Now I will just have to spend a few weeks modifying your code so I can get the screen to scroll too, then I will have a perfect game.


BBS Signature
black-scorp
black-scorp
  • Member since: Aug. 25, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As: Platformer with Slopes Nov. 14th, 2006 @ 05:46 PM Reply

dead link

shade999999
shade999999
  • Member since: Oct. 26, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to As: Platformer with Slopes Nov. 14th, 2006 @ 06:29 PM Reply

I really only need know how to get the ball from bouncing at the bottom. I just want it to roll smoothly or bounce somewhat like in Paintball-The Game.


BBS Signature
Tugler
Tugler
  • Member since: Aug. 26, 2006
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Platformer with Slopes Nov. 14th, 2006 @ 06:57 PM Reply

Can ya re-host it?

It doesn't work any more.

Click my Sig! I make money :)

BBS Signature
Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to As: Platformer with Slopes Mar. 24th, 2007 @ 04:12 AM Reply

I dont understand the bit about "only used if you want it to rotate" that could mean one of two things: 1. The clip rolls when you move 2. the movieclip is always facing down towards teh ground, if 2. then it would be useful to know how to do that...


Song of the Firefly is on Steam Greenlight and Facebook. Give them a look and support the project!
------------------------------

BBS Signature
pivot11
pivot11
  • Member since: Jun. 16, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to As: Platformer with Slopes Mar. 24th, 2007 @ 10:20 AM Reply

Well, first off there's way too many platform tuts on As:main. And second, that link say site not found. (at least for me)


Blok' Party, Orbital Khaos, site, MSMstudios, Phrozen Phlame

BBS Signature
suppi
suppi
  • Member since: Jun. 29, 2003
  • Offline.
Forum Stats
Member
Level 07
Audiophile
Response to As: Platformer with Slopes Apr. 17th, 2007 @ 07:49 PM Reply

is it possible for me to tack another jumping code on this one-the jumping in this is remeniscent of smb for nes-not a good thing.