The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsHey! I need some help for my character movement becaause it's very simple movement and i want more like friction, walk and run, etc.
This is the code, i hope answers.
onClipEvent (load) {
var grav:Number = 0;
// gravity
var speed:Number = 10;
// how fast you walk
var jumpHeight:Number = 15;
// how high you jump
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;
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+1, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else if (Key.isDown(65)) {
_x -= speed;
_xscale = -scale;
if (_root.ground.hitTest(_x, _y+1, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else {
if (_root.ground.hitTest(_x, _y+1, 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), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, 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), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
} i'm not understanding?
are you wanting us to rewrite your code to implement friction?
awww
At 12/20/09 04:13 AM, LostVoices wrote: are you wanting us to rewrite your code to implement friction?
This isn't even his code. I think this is Pyromaniac's older ones.
No. We're not going to do this for you, why should we? You haven't even bothered to make the basic code yourself, you've merely used copypasta. Instead, we'll help you how you should have helped yourself: "Friction is the decline of velocity, so I need a variable that controls the velocity of the object, and some statements that add to the velocity and decrease it when the movement keys are being held down and unpressed. I'll also need a cap for the velocity - or else the object will able to go so fast no-one will see it!"
Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
At 12/20/09 04:19 AM, Montycarlo wrote:At 12/20/09 04:13 AM, LostVoices wrote: are you wanting us to rewrite your code to implement friction?This isn't even his code. I think this is Pyromaniac's older ones.
i'm going to agree with you here, if it was his code and he could figure out Gravity and Walking in water speed there should be no problem with Friction / Acceleration
awww
Well, i just need an explanation for the friction/aceleration code.
Good job making a whole other thread instead of a response BTW
Anyways try and learn the code urself OP, its not really hard, and nobodys going to write out the whole code for you anyway. Try and learn from tutorials rather than just copying the code.
At 12/20/09 06:13 AM, Eviladrianin wrote: Well, i just need an explanation for the friction/aceleration code.
I gave you one. Clearly you don't read or put in any effort.
Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
Oh yeah! Finally i understand the friction!!
Thanks to all for your comments
At 12/20/09 06:13 AM, Eviladrianin wrote: Well, i just need an explanation for the friction/aceleration code.
Hey there! :)
so while you were sitting here pressing your browsers refresh button anxiously awaiting for someone to give you the code i thought to myself.. HEY.. wait why don't i go and research this for his, learn the code, then come back and teach him how to complete it :D
don't get me wrong i understand how much time it takes out of someone's busy schedule to press the refresh button and i commend you for it.
but while doing all this i did stumble across this helpful little link.
i hope this helps
awww
awww