Be a Supporter!

As : Platformer

  • 8,546 Views
  • 55 Replies
New Topic Respond to this Topic
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
As : Platformer May. 28th, 2006 @ 03:08 PM Reply

What you will be making- http://denvish.net/u..mer%20Code%20001.swf

As: Main

Preperation
Draw your character. Convert it into a movieclip, and make sure the + is on the bottem middle.
Make your ground and convert that into a movieclip. Give it the instance name of "ground" without the quotes. The ground can be anything, make it all in one movieclip., The code checks for walls and ceiling and floors by itself. Lucky you.

The Script
Click on your character, and go to actions. Now copy and paste this into him.
The // start a comment, they dont affect the script

//made by pyro111
// thanks to Vengance for helping
onClipEvent (load) {
grav = 0;
// sets falling speed
speed = 7;
// sets movement speed
jumpHeight = 15;
// sets height that you can jump
scale = _xscale;
// sets size
slowfall = .8;
// sets glide
}
onClipEvent (enterFrame) {
// happens every frame
grav++;
// makes you fall faster
_y += grav;
// makes your _y go up by the varaible grav
while (_root.ground.hitTest(_x, _y, true)) {
// when this is touching the ground
_y--;
// makes the y keep on going up, this enables slopes
grav = 0;
// make it so you dont fall
}
if (Key.isDown(68)) {
// when the d key is down
_x += speed;
// makes the x go up by the speed
_xscale = scale;
// makes it face right
if (_root.ground.hitTest(_x, _y+3, true)) {
// if it is touching the ground
this.gotoAndStop(1);
// goes to frame 1
} else {
// otherwise
this.gotoAndStop(2);
// stops at frame 2
}
} else if (Key.isDown(65)) {
// if that isnt happening and the a key is pressed
_x -= speed;
// makes the x go gown by the speed
_xscale = -scale;
// makes it face left
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
// see other code for movign right
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79)) {
// if this is touching the ground and o isnt pressed
this.gotoAndStop(3);
// stops at frame 3
}
}
if (Key.isDown(83)) {
// if the s key is down
grav *= slowfall;
// slows down the gravity by multiplying it by the slowfall varialbe
}
if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68)) {
// if 0 is down, and a s d w arent
this.gotoAndStop(4);
// goes to frame 4
}
if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true)) {
// if w is pressed and it is touching the ground
grav = -jumpHeight;
// makes gravity negative jumpheight, causes jump
_y -= 4;
// makes the y go up by 3
this.gotoAndStop(2);
// stops on frame 2
}
if (_root.ground.hitTest(_x+(_width/2), _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2), _y-((_height/6)*4), true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2), _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2), _y-((_height/6)*4), true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height, true)) {
grav = 2;
}
// these all check for 2 points along the sides and top, to see if it is hitting a wall
}

How It Works
Well, first off the code makes the player go down by gravity. Gravity goes up every second, making the player fall faster. When the player touches the ground, gravity is reset to zero.

Then when the player presses the W key. Gravity is at negititve jump height. So the player will go up. But because gravity is goin up, the jump goes down. so gravity will be -14, -13, -12, -11, ect. that means it is going up. then it hits 0, and then 1, 2,3 and the player starts to fall again.

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to As : Platformer May. 28th, 2006 @ 03:16 PM Reply

Hey, i wanted to to a platformer thread >:|


BBS Signature
GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As : Platformer May. 28th, 2006 @ 03:18 PM Reply

You aren't very good with multiple hittests, huh.


BBS Signature
DX14
DX14
  • Member since: Oct. 4, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As : Platformer May. 28th, 2006 @ 04:14 PM Reply

WOW, i think this is a great attempt at a platformer, and u dont get stuck with boring old squares for the ground, thx for that!!!

D.

Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As : Platformer May. 29th, 2006 @ 08:43 AM Reply

At 5/28/06 03:18 PM, -Gust- wrote: You aren't very good with multiple hittests, huh.

What do you mean? I could have done it differntly, but I didnt. And I have never seen you say something nice. You also have no flash, and I havent seen any of your code, so I have no idea how good you are.

Chaz
Chaz
  • Member since: Sep. 27, 2005
  • Offline.
Forum Stats
Member
Level 23
Game Developer
Response to As : Platformer May. 29th, 2006 @ 11:24 AM Reply

Pertty good, but if you draw a curve, and jump and hassle it a bit he falls right through it. Pretty nice though, like someone above says I guess it beats just plain old blocks.


BBS Signature
Trunks
Trunks
  • Member since: Jul. 31, 2005
  • Offline.
Forum Stats
Member
Level 22
Musician
Response to As : Platformer May. 30th, 2006 @ 04:16 PM Reply

At 5/29/06 08:43 AM, pyro111 wrote:
At 5/28/06 03:18 PM, -Gust- wrote: You aren't very good with multiple hittests, huh.
What do you mean? I could have done it differntly, but I didnt. And I have never seen you say something nice. You also have no flash, and I havent seen any of your code, so I have no idea how good you are.

Of course he has no examples, he is a poser. He does not have much knowledge with AS. Trust me, he tried out for a flash team I am a part of as an Actionscripter, said he had examples ready that he wouldn't show us, flamed us, and got deleted. He came back and said that he had a flu and was bored, and was sorry. That is like saying if I had the power to kill everyone, I killed everyone because I was bored. It doesn't make much sense. We rejected him, and he has been hating us ever since. And, furthermore, the example he DID end up giving us was stolen.


Check out my band by clicking my sig!

BBS Signature
djdarran
djdarran
  • Member since: May. 22, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 05:04 PM Reply

Awesome script. I've been looking for this type of scipt. You must have some ggod flash. :-D

djdarran
djdarran
  • Member since: May. 22, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 05:14 PM Reply

how do u change it so u press LEFT arrow key instead of D RIGHT arrow key instead of s and UP arrow key instead of whatever it is?

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to As : Platformer May. 30th, 2006 @ 05:15 PM Reply

Pfft, I bet I could top this engine in ten minutes, tops!

but not tonight; I'm tired

BBS Signature
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 05:44 PM Reply

At 5/30/06 05:15 PM, _Paranoia_ wrote: Pfft, I bet I could top this engine in ten minutes, tops!

but not tonight; I'm tired

Well I see how it is. Conisdering I made it in like 10 minutes. But whatever.

2g4gzus
2g4gzus
  • Member since: Mar. 20, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 06:53 PM Reply

according to someone who sounds more important than you, you're roughly the least trustable person on the planet. Either this took you about 200 years, or you stole it, and either way theres not a single thing that would help a beginner with platform game making, besides the ground.

Chaz
Chaz
  • Member since: Sep. 27, 2005
  • Offline.
Forum Stats
Member
Level 23
Game Developer
Response to As : Platformer May. 30th, 2006 @ 07:11 PM Reply

At 5/30/06 06:53 PM, 2g4gzus wrote: according to someone who sounds more important than you, you're roughly the least trustable person on the planet. Either this took you about 200 years, or you stole it, and either way theres not a single thing that would help a beginner with platform game making, besides the ground.

What the --?


BBS Signature
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 07:22 PM Reply

At 5/30/06 06:53 PM, 2g4gzus wrote: according to someone who sounds more important than you, you're roughly the least trustable person on the planet. Either this took you about 200 years, or you stole it, and either way theres not a single thing that would help a beginner with platform game making, besides the ground.

Ok, I have no idea who you are, but what the hell is wrong with you?
Who is this person who sounds more reliable than me? I have never even talked to you!

This didnt take me 200 years, because it wasnt that hard to make! I didnt steal it, what makes you think that?

And what wont help a begginer? The ground is the whole platform game!

What are you on? According to your posts you know nothing about actionscript. So just leave.

Chaz
Chaz
  • Member since: Sep. 27, 2005
  • Offline.
Forum Stats
Member
Level 23
Game Developer
Response to As : Platformer May. 30th, 2006 @ 07:24 PM Reply

At 5/30/06 07:22 PM, pyro111 wrote: talk

I posted earlier about the ground, that was my error. I'm just backing that this is a great engine.


BBS Signature
djdarran
djdarran
  • Member since: May. 22, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 07:32 PM Reply

How do you change the controls? Like from a s d w to left up and down?

Chaz
Chaz
  • Member since: Sep. 27, 2005
  • Offline.
Forum Stats
Member
Level 23
Game Developer
Response to As : Platformer May. 30th, 2006 @ 07:35 PM Reply

At 5/30/06 07:32 PM, djdarran2 wrote: How do you change the controls? Like from a s d w to left up and down?

replace wherever is says 65 or whatever to Key.UP and Key.Down , same with Key.LEFT and Key.RIGHT

Understand?


BBS Signature
djdarran
djdarran
  • Member since: May. 22, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 08:00 PM Reply

At 5/30/06 07:35 PM, -Chaz- wrote:
At 5/30/06 07:32 PM, djdarran2 wrote: How do you change the controls? Like from a s d w to left up and down?
replace wherever is says 65 or whatever to Key.UP and Key.Down , same with Key.LEFT and Key.RIGHT

Understand?

Thanks

djdarran
djdarran
  • Member since: May. 22, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 09:12 PM Reply

Wheres the script line that tells A to move it left?

Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As : Platformer May. 30th, 2006 @ 09:20 PM Reply

if (Key.isDown(68)) {
// when the d key is down
_x += speed;
// makes the x go up by the speed
_xscale = scale;

Read the comments that tell you aht the code does. Btw- = 65, B=66, C=67, and so on.

seel
seel
  • Member since: Jun. 27, 2005
  • Offline.
Forum Stats
Member
Level 21
Musician
Response to As : Platformer Jun. 4th, 2006 @ 11:32 AM Reply

At 5/30/06 06:53 PM, 2g4gzus wrote: according to someone who sounds more important than you, you're roughly the least trustable person on the planet. Either this took you about 200 years, or you stole it, and either way theres not a single thing that would help a beginner with platform game making, besides the ground.

Lol dont be surprised if 2g4gzus is -gust-s alt :)

Anyways good game engine pyro! worked pretty good.

flash-flood01
flash-flood01
  • Member since: Dec. 26, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As : Platformer Jun. 8th, 2006 @ 04:28 AM Reply

if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68)) {
// if 0 is down, and a s d w arent
this.gotoAndStop(4);
// goes to frame 4
}

whats that for?

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As : Platformer Jun. 8th, 2006 @ 11:18 AM Reply

If you want to know how good Gust is at actionscript, I can assure you he's better than you, and many other flash regs.

At 5/30/06 05:44 PM, pyro111 wrote: Well I see how it is. Conisdering I made it in like 10 minutes. But whatever.

Lol I hate when people try to look serious and intelligent towards sarcasm. We all know you made it in a lot more than 10 minutes, even typing it would take 10 minutes, but we don't care how long it took you as long as it's good. Paranoia was just messing around, perhaps it was not sarcasm but he wasn't exactly serious.


BBS Signature
Shroome
Shroome
  • Member since: Mar. 19, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As : Platformer Jun. 8th, 2006 @ 11:24 AM Reply

How do I make the little + go to the bottom?


BBS Signature
flash-flood01
flash-flood01
  • Member since: Dec. 26, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As : Platformer Jun. 9th, 2006 @ 09:14 PM Reply

At 6/8/06 11:24 AM, daaadddoo wrote: How do I make the little + go to the bottom?

What do you mean?

MadGiraffe
MadGiraffe
  • Member since: Jan. 7, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to As : Platformer Jun. 9th, 2006 @ 09:19 PM Reply

At 6/9/06 09:14 PM, flash_flood01 wrote:
At 6/8/06 11:24 AM, daaadddoo wrote: How do I make the little + go to the bottom?
What do you mean?

I think he's talking about the mc centerpoint.

Go inside the mc and drag everything in there up.
If it has multiple frames, use the onionskinning multiple frame editing option.

Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As : Platformer Jul. 2nd, 2006 @ 03:11 PM Reply

I made the script better(less buggy, better hitTets), and I also added in water (slows you down walking and falling).

To add water, just draw it and give it the instance name of water.

// made by pyro111
// help by Vengance
// updated on July 2, 2006
onClipEvent (load) {
var hp:Number = 100;
var maxhp:Number = 100;
var grav:Number = 0;
var speed:Number = 5;
var jumpHeight:Number = 12;
var slow:Number = .7;
// sets water falling speed
var slowspd:Number = speed/1.5;
// sets water walking speed
var setspeed:Number = speed;
var scale:Number = _xscale;
var ex:Number = 5;
// makes hitTests better, change for a closer hitTest (warning, more buggy if smaller)
var dam:Number = 25;
this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
if (_root.water.hitTest(_x, _y, true)) {
if (grav>0) {
grav *= slow;
}
speed = slowspd;
} else {
speed = setspeed;
}
if (Key.isDown(68)) {
_x += speed;
_xscale = scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else if (Key.isDown(65)) {
_x -= speed;
_xscale = -scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79) && !Key.isDown(73)) {
this.gotoAndStop(3);
}
}
if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68) && !Key.isDown(73)) {
this.gotoAndStop(5);
}
if (Key.isDown(73) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68) && !Key.isDown(79)) {
this.gotoAndStop(4);
}
if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
this.gotoAndStop(2);
}
if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-((_height/6)*4), true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-((_height/6)*4), true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height, true)) {
grav = 1;
}
}

deadpool15
deadpool15
  • Member since: Jul. 26, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As : Platformer Jul. 26th, 2006 @ 10:24 AM Reply

neh! these always fuck me off when i try it out my player always just falls staright through the ground

Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As : Platformer Jul. 26th, 2006 @ 11:45 AM Reply

At 7/26/06 10:24 AM, deadpool15 wrote: neh! these always fuck me off when i try it out my player always just falls staright through the ground

The ground's insance name needs to be ground. Otherwise it wont work.

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to As : Platformer Jul. 26th, 2006 @ 02:11 PM Reply

At 6/8/06 11:18 AM, -Toast- wrote: Paranoia was just messing around, perhaps it was not sarcasm but he wasn't exactly serious.

I'm never serious :)

omg hows that for a late reply?

BBS Signature