HOME | DD

Doomrider911 — Platformer tutorial

Published: 2007-07-15 22:37:27 +0000 UTC; Views: 977; Favourites: 2; Downloads: 21
Redirect to original
Description Add this actionscript to the character....

onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 6;
maxjump = 0.2;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.ground.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.UP) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 22;
}
if (Key.isDown(Key.UP)) {
jumpcount += 1;
}
if (jumpcount>maxjump && jumpSpeed>-2) {
jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe<4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe<4) {
state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe<4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe<4) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}
Basically, this is just a combination of two tutorials i used. i used tutorial and code to make this. it is basically john's tut only simpler. If you make a game, give credit to , , and me,
Related content
Comments: 15

Silvy39 [2011-11-13 13:28:05 +0000 UTC]

I gave the name ground to...the ground. But The Player is falling or standing under it! Why?

👍: 0 ⏩: 0

redligot2009 [2011-07-08 10:18:12 +0000 UTC]

oh yeah, to make doors where you have to press to enter the room, add an if(Key.isDown condition beside the hitTest. in other words,
onClipEvent(enterFrame){
if(this.hitTest(_root.player))if (Key.isDown(Key.UP)){
_root.gotoAndPlay(1);//whatever frame you wanna go to
}
}

👍: 0 ⏩: 0

Milk-ManOfPlyiersInc [2009-03-27 05:57:00 +0000 UTC]

how do you make him walk in only one frame?

👍: 0 ⏩: 0

th1rte3nthsora [2007-09-22 08:34:24 +0000 UTC]

my guy just goes through the floor when i create a floor what shudd i do?

👍: 0 ⏩: 1

Doomrider911 In reply to th1rte3nthsora [2007-09-22 17:41:33 +0000 UTC]

did you give the ground the instance name "ground" ?

👍: 0 ⏩: 0

XgameoverX [2007-07-21 20:21:20 +0000 UTC]

LOL the guy doesnt diE! LOL

👍: 0 ⏩: 1

Doomrider911 In reply to XgameoverX [2007-07-22 01:19:36 +0000 UTC]

i dun know how to make him die...

👍: 0 ⏩: 3

person333 In reply to Doomrider911 [2007-07-25 04:46:53 +0000 UTC]

if you want him to die, pop his script in the final frame of the health bar clip

_root.gotoandstop("dead screen")

its that simple

👍: 0 ⏩: 1

Doomrider911 In reply to person333 [2007-07-25 14:10:31 +0000 UTC]

yeah i figured it out.

👍: 0 ⏩: 0

MisterWill In reply to Doomrider911 [2007-07-23 14:49:27 +0000 UTC]

Why make a tutorial on a topic you know nothign about then? If you don't know how to make him die you deffinetly didn't code this. To make him die would be something like:

if(health==0){
this.gotoAndPlay("Die);
}

👍: 0 ⏩: 1

Doomrider911 In reply to MisterWill [2007-07-23 20:11:42 +0000 UTC]

first of all i even said I DIDNT MAKE THE CODE secondly i only made this to simplify some stuff in john's tutorial using person333's code. READ THE COMMENTS BEFORE YOU INSULT!

👍: 0 ⏩: 0

XgameoverX In reply to Doomrider911 [2007-07-22 18:59:21 +0000 UTC]

LOL

👍: 0 ⏩: 0

XgameoverX [2007-07-21 20:20:21 +0000 UTC]

just realize i wasnt waching oyu !

👍: 0 ⏩: 1

Doomrider911 In reply to XgameoverX [2007-07-22 01:19:03 +0000 UTC]

lol

👍: 0 ⏩: 1

XgameoverX In reply to Doomrider911 [2007-07-22 18:59:33 +0000 UTC]

i know some one that does dont remmber who

👍: 0 ⏩: 0