00:00
00:00
Newgrounds Background Image Theme

Zombiehit 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!

As: Movement on slopes

15,079 Views | 53 Replies
New Topic Respond to this Topic

Response to As: Movement on slopes 2006-02-24 13:07:00


i have problem with script!

when i made vCam moveing with the hero, and when hero is falling on ground, he is bouncing on ground o_O

whats the problem?

Response to As: Movement on slopes 2006-02-24 14:27:45


the hero is maybe moving up and down really fast(kinda... many times a frame) and the cam is trying to follow him so it shakes as hell. I had this problem too.

Maybe you should try to make your movement whit:
_root._x
_root._y

these will move the stage as good as the camera.

Stage.width
and
Stage.height

can strech the stage.

example:
_root._x -= 2;

will move everything left, so make your hero move 2 to the right and he will stay in the middle of the screen.

Response to As: Movement on slopes 2006-02-24 14:41:07


hmm, this reminds me. has there been any tutorials on sliding? As in, almost the same as this but showing how the ball can realistically roll down slopes on its own? i could probably make one if needed.
(ive been wanting to make a tut on something for a while but it seems everything has already been covered)


BBS Signature

Response to As: Movement on slopes 2006-02-24 16:09:52


At 2/24/06 02:27 PM, Louissi wrote: something about shakin

hmm... i don't know but i tryied move only cam and hero was like...

when i moved can up, he was a lil bit goin up
when i moved can down, he was a lil bit goin down
and then he was goin back to him last position 0.0

Response to As: Movement on slopes 2006-02-24 16:19:29


At 2/24/06 04:09 PM, Zielak wrote: can

damn! i meant cam ^^

Response to As: Movement on slopes 2006-02-25 13:18:25


ok... i tryied what you said Louissi but you wrong :(

any suggestions?

Response to As: Movement on slopes 2006-03-06 21:09:44


At 7/29/05 10:22 AM, -dELta- wrote: A few comments: dont use a while loop: just use a for loop of lets say 10 max this way it restricts the steepness of slope the player can walk up and stops the player floating up a wall sorta speak: youll also need a safe guard that if it cant reach the top of the ground before the loop ends to not alloow it to move otherwise the player walks through walls:

you can also make a more realistic looking walk by doing the same again but down so that the player actually walks down the slopes not bounces down, again a safe guard but this time it only means if he doesnt reach the ground before the loop ends that he is floating in the air ans is falling/jumping

How is the code supposed to look like with for instead of while? I didn't really understand what you said?

And also, how do I make it so that the player goes to the walking animation, standing thing, jumping animation, etc, when I press the button that makes it do that thing?


sockpuppetclock

BBS Signature

Response to As: Movement on slopes 2006-03-17 22:18:12


*bookmarked*


aquaticmole.

BBS Signature

Response to As: Movement on slopes 2006-03-21 20:53:11


At 9/19/05 09:27 PM, JCesta wrote: how do you make an "invisible" movie clip???

you go to the "alphas" thing in flash,after you've selected the movieclip, and make it totaly transparent (at least i think thats how you do it....i don't have flash right now...my third trial version ended not too long ago...)

Response to As: Movement on slopes 2006-03-23 12:06:54


finaly someone had to do it!

Response to As: Movement on slopes 2006-03-27 14:07:42


At 9/19/05 09:27 PM, JCesta wrote: how do you make an "invisible" movie clip???

in onClipEvent(load) section put:

_visible = false;

now i don't have any problems (like i said above ^)
i made it invisible and its workin fine :D

Response to As: Movement on slopes 2006-03-27 14:33:38


At 3/6/06 09:09 PM, bigexplosions wrote: How is the code supposed to look like with for instead of while? I didn't really understand what you said?

well, replace the while, with for(var somevar:Number = 0; somevar < 10; somevar++)

and instead of incrementing player position, just test their position add somevar, if its succesful move player if not, dont

Response to As: Movement on slopes 2006-03-27 14:39:57


At 3/27/06 02:33 PM, -dELta- wrote: well, replace the while, with for(var somevar:Number = 0; somevar < 10; somevar++)

and instead of incrementing player position, just test their position add somevar, if its succesful move player if not, dont

i can do for loops and all and i kinda get it but i just cant seem to get it to work :( is there any chance of you showing how the code will actually look

sorry for bugging you delta, you probally have better things to do XD

Response to As: Movement on slopes 2006-03-27 14:58:17


Well I've been working on a similar engine as this, alot of me wishes I had seen this thread before starting, but I have a little different way of getting these effects.
Here's an example
http://img89.imagesh..php?image=bla7et.swf

I know not perfect, but it's up to numbers tweaking now. All the code requires is to be put onto your character MC and naming your level "ground" and here is the code. It's only commented for my use so I appologize ahead of time, but I thought ya'll might like to have another option.

onClipEvent(load){
grav=2;
speed=0;
jump=10;
jumpa=0;
maxjump=30;
rollspeed=.8;
}
onClipEvent(enterFrame){
_y+=grav;
grav+=.3;
speed-=.3;
if(speed>10){
speed=10;
}
if(speed<0){
speed=0;
}
if(rollspeed>4){
rollspeed=4;
}
if (grav>20){
grav=20;
}
while (_root.ground.hitTest(_x,_y,true)){
_y-=.2;
grav=0;
jumpa=0;
jump=10;
}
if (Key.isDown(Key.RIGHT)){
speed+=1;
rMove=true;
lMove=false;
}
if(_root.ground.hitTest(_x,_y-30,true)){
jumpa=maxjump;
_y+=.2;
}
if ((rMove) and (!_root.ground.hitTest(_x+15,_y-15,true)))
{
_x+=speed;
body._rotation+=speed;
move=true;
} else if ((lMove) and (!_root.ground.hitTest(_x-15,_y-15,true)))
{
_x-=speed;
body._rotation-=speed;
move=true;
} else {move=false}
if (Key.isDown(Key.LEFT)){
speed+=1
lMove=true;
rMove=false;
}
if((Key.isDown(Key.UP)) and (jumpa<maxjump)){
_y-=jump;
jumpa++;
jump-=.3;
}
//rollhitTest
if((_root.ground.hitTest(_x+15,_y-2,true)) and (!_root.ground.hitTest(_x-15,_y-2,true))){
_x-=rollspeed;
rollspeed+=.5;
body._rotation-=rollspeed;
roll=true;
} else if((_root.ground.hitTest(_x-15,_y-2,true)) and (!_root.ground.hitTest(_x+15,_y-2,true))){
_x+=rollspeed;
rollspeed+=.5;
body._rotation+=rollspeed;
roll=true;
} else {
rollspeed=.8;
roll=false;
}
if(_x>300){
if(move){
_x-=speed;
_root.ground._x-=speed;
}
if(roll){
_x-=rollspeed;
_root.ground._x-=rollspeed;
}
}
if(_x<100){
if(move){
_x+=speed;
_root.ground._x+=speed;
}
if(roll){
_x+=rollspeed;
_root.ground._x+=rollspeed;
}
}
if (_y>300){
_y-=grav;
_root.ground._y-=grav;
}
if (_y<100){
_y+=jump;
_root.ground._y+=jump;
}
}
onClipEvent(keyUp){
if(Key.getCode() == Key.UP){
jumpa = maxjump;
}
}


Our growing dependence on laws only shows how uncivilized we are.

Response to As: Movement on slopes 2006-03-27 15:00:38


i like the way you "roll down" the hills instead of just staying there.

Response to As: Movement on slopes 2006-03-27 15:06:22


I should add you'll need to change some of the math in the hitTests if your MC is a different size then the one I used, that should save some noobs. Also I adjusted the MC so the _x,_y position is sitting bottom center.


Our growing dependence on laws only shows how uncivilized we are.

Response to As: Movement on slopes 2006-05-20 22:00:10


Does this work will walls aswell?

Response to As: Movement on slopes 2006-10-20 15:26:02


_root.Hero._y--
//while the ground touches GoUP, make the hero go up

I kind of undestand the code, but i don't understand how does the ground not get that hitText box around it.
I hope i managed to make myself clear.

Response to As: Movement on slopes 2006-11-14 18:59:44


My only problem is that I am trying to make a game just like Paintball-The Game By Claxor, but if you have the action script for the ground it wont work. The reason it won't work is because when they draw a path, it isn't an actual object on the main timeline, it is character created. So all my other stuff has to have the collision detection on the character and then when it says something like if (_root.ground.hitTest(_x, _y, true)) {, I have to delet the ground part because like I said the drawn lines are not an actual object. Is there any way some one could help me?
Original Character Script this is the reason that I looked at your tutorial because it can't walk up slopes.

onClipEvent (load) {
y = jump=0;
speed = 5;

}
onClipEvent (enterFrame) {
xmax = this.getBounds(_root).xMax;
xmin = this.getBounds(_root).xMin;
ymax = this.getBounds(_root).yMax;
if (Key.isDown(Key.RIGHT) &&(xmax+speed, _y, true)) {
_x += speed;
this.gotoAndStop("run")
}else{gotoAndStop("idle")
if (Key.isDown(Key.LEFT) && (xmin-speed, _y, true)) {
_x -= speed;
}
this.gotoAndPlay("walk")
}
if (_root.hitTest(_x, ymax-(y/2), true)) {
jump = true;
y = 0;
} else {
y -= 2;
jump = false;
}
if (jump && Key.isDown(Key.SPACE)) {
y = 13;
this.gotoAndStop("jump")

}
_y -= y;
}
onClipEvent(load) {
speed = 10;
counter = 0;
minLimit = -5;
maxLimit = Stage.width + 5;
}
onClipEvent(enterFrame) {
if(Key.isDown(Key.LEFT)) {
this._x -= speed;
}else if(Key.isDown(Key.RIGHT)) {
this._x += speed;
}
if(this._x < counter) {
counter = counter -10;
_root.map._x += speed;
}else {
counter = 0;
}
if(this._x > Stage.width) {
_root.map._x -= speed;
}
if(this._x >= maxLimit) {
this._x -= speed;
}
if(this._x <= minLimit) {
this._x += speed;
}
}

If possible please help me. The game is on my website here

<http://www.kewlhotrod.bravehost.com/games2.h tm>
The current game that I have loaded now is a wee bit better but that should be all you need. THX!


BBS Signature

Response to As: Movement on slopes 2006-12-01 17:19:13


Yeah, my character falls right through the 'ground'

Response to As: Movement on slopes 2007-04-15 08:39:04


Sweet tutorial.. However.. Is there a way to make any WALLS for this?
I made a few, but they have this wierd 'bounce' effect which pushes the player away whenever you touch them. Is there a simple way to make the player just simply STOP whenever he touches a wall?
Thanks!

(looking for a very simple code, I can place on wall pieces, nothing complicated)

Response to As: Movement on slopes 2008-02-20 13:30:34


These are all horrible ways to make a platformer I'm sorry to say. Unneccessarily long script, buggy engine. I bet I could code a much better one in much less script.


BBS Signature

Response to As: Movement on slopes 2008-02-20 14:33:55


At 2/20/08 01:30 PM, Hoeloe wrote: These are all horrible ways to make a platformer I'm sorry to say. Unneccessarily long script, buggy engine. I bet I could code a much better one in much less script.

i agree 100%. this tutorial is alright, gets a bit boring, and more importantly, it focuses too much on the code than the logic.

this is just a bunch of 'if's. any coder can code this, even a pure beginner. once you know that you just need to check for a hittest then everything else falls into place, like gravity. there are mathematical equations that can be used if you want a more user-effecient game... but this tutorial isnt anything new.

i would be interested if it had some math involved.

Response to As: Movement on slopes 2010-08-09 14:36:54


joelasticot you are king