ForumsProgramming ForumPlatformers.

29 7184
Gfitz07
offline
Gfitz07
203 posts
Nomad

I know i have posted something like this before, but this time its different. I need to know how to make a character walk on rough terrain and jump on to more rough terrain and he doesnt float. I also need the screen to follow him. Please help me!

I am using AS2 by the way.

  • 29 Replies
LonLonRanch
offline
LonLonRanch
172 posts
Nomad

Where exactly are you stuck at? If you want to make a platformer you have to take it in pieces, you can't just say "I want to make a platformer, now how do I do that?" Have you worked on character movement at all? What pieces are you missing?

Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

There is another thread about irregular colision, take a look
http://armorgames.com/community/thread/2269181/need-help

I'd recommend Using a separate movieclip on your character feet for colision detection, so you can have a smaller hitbox than your character

The screen following you'll have to move the whole background instead of your character o create the impressions of scrolling

Gfitz07
offline
Gfitz07
203 posts
Nomad

i created the movement and the screen follows him. but he just floats above the platform and when he jumps he falls through it.

Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

What's your code for the colision? Is your plataform too thin?

Gfitz07
offline
Gfitz07
203 posts
Nomad

if (Key.isDown(Key.UP)) {
jumping = true;
} else {
if (_root.man.hitTest(_x, _y+height/2, true)) {
jumping = false;
}
}

I am making it so the ground jumps instead of the player to make it easier. This is only the collision part and the platform cannot be to thin.

IQAndreas
offline
IQAndreas
299 posts
Peasant

What is the code inside of the jumping method?

Gfitz07
offline
Gfitz07
203 posts
Nomad

onClipEvent (load) {
jumping = false;
jumpspeed = 7;
gravity = 0.5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
jumping = true;
} else {
if (_root.man.hitTest(_x, _y+height/2, true)) {
jumping = false;
}
}
if (jumping == true) {
this._y += jumpspeed;
jumpspeed -= gravity;

} else {
jumpspeed = 7;
gravity = 0.5;
}
if (Key.isDown(Key.LEFT)) {
this._x += 5;
}
if (Key.isDown(Key.RIGHT)) {
this._x -= 5;
}
}

here is the entire script for the platform.

IQAndreas
offline
IQAndreas
299 posts
Peasant

So does this work just fine jumping without the platforms, using only the bottom of the stage as the stop for the gravity?

I am still looking over the code now, but I would recommend that you set the registry point (or whatever it is called, where that little cross cursor is) of the movie clip at the feet of the main character, right in the middle of the character horizontally.

I can draw a diagram of what I mean if I'm not making myself clear enough.

Gfitz07
offline
Gfitz07
203 posts
Nomad

nope i tried that and it didn't work. I know there isnt anything wrong with the player script bcause there isnt anything on thre that effects the platform. He only fall through when he jumps unless i change this:

if (_root.man.hitTest(_x, _y+height/2, true)) {

to this:

if (_root.man.hitTest(this)) {

but either way he floats on top

IQAndreas
offline
IQAndreas
299 posts
Peasant

Ah. I see what it does now. Interesting.

One thing that confuses me is this line:
if (_root.man.hitTest(_x, _y+height/2, true))

Is _x, _y, and height here referring to the stage, the platform, or the man?

Where on the stage is the man located? On the left most side, or in the center? At the bottom of the screen, or in the center?

Also, are all platforms considered one movie clip, or is each platform a separate movie clip?

Depending on these answers, I think I know the problem.

Gfitz07
offline
Gfitz07
203 posts
Nomad

the _x and _y are referring to the platform

in the center

All the platforms are one movie clip

IQAndreas
offline
IQAndreas
299 posts
Peasant

Ah. Now I see where the problem lies. Let me draw up a diagram real quick.

IQAndreas
offline
IQAndreas
299 posts
Peasant

[URL=http://img412.imageshack.us/my.php?image=programminghelpjpgfh9.png][IMG]http://img412.imageshack.us/img412/2370/programminghelpjpgfh9.png[/IMG][/URL]

If I understand the hitTest function properly, I think it might be smarter to change your code around a bit.

I'll tell you what to do in the next post in a few seconds.

IQAndreas
offline
IQAndreas
299 posts
Peasant

Oops. I think the forums are case sensitive. Let's try this.

http://img412.imageshack.us/img412/2370/programminghelpjpgfh9.png

Gfitz07
offline
Gfitz07
203 posts
Nomad

ok thanks. but it still hasnt helped me much. Like should i change the _y+height/2 to just _y?

Showing 1-15 of 29