The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 ViewsI'm no noob; I know how to program a normal 'sprite.dy = -7 and then affect sprite.dy++ every frame for gravity' jump, as seen in the majority of games, but I've hit a bit of a hurdle at the moment.
What I'm after is a retro - and quite rarely seen - fixed length and direction jump, like in the original Castlevania, or Faxanadu. And I'm in a world of hurt trying to figure out how to do it. I've tried searching google but I don't know any proper name for this sort of jump, so it's useless.
Any ideas? Links?
Thanks.
Actionscript 2 btw.
i don't....but jetpack paladin is awesome!
=]
i like to have fun with the girls.
I think I know what you mean - There is no transition between the uppermost point in the jump and when the character leaves the ground?
If so, simply store a Number variable and decrement it each frame if it is above 0. It serves as a timer for how much time is left in the 'current' jump. You could therefore set an offset to the y-value when the jump finishes and when it begins.
var jumpTimer:Number = 0;
var jumpOffset:Number = 25
if(jumpTimer > 0){
jumpTimer--;
if(!jumpTimer) y+= jumpOffset;
}else{
if(Key.isDown(Key.UP)){
jumpTimer = 10
y -= jumpOffset;
}
} Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
Argh - in my last post there is one too many spaces after one of the conditionals. Here is the functional code:
var jumpTimer:Number = 0;
var jumpOffset:Number = 25
if(jumpTimer > 0){
jumpTimer--;
if(!jumpTimer) y+= jumpOffset;
}else{
if(Key.isDown(Key.UP)){
jumpTimer = 10
y -= jumpOffset;
}
} Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
Yes that's sort of what I mean. But there IS some transition between the peak of the jump and the launch, it's just that at the peak the character seems to hover slightly before falling again.
It is the rate and timing of the climb, hover and drop I'm having dificulty with.
Thanks though.
Store a flag for jumping and detect when the y-velocity becomes positive. When so, set the y-velocity to 0 and don't apply gravity until a timer variable is 0 or less.
Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
At 8/3/10 08:27 AM, wagnerben wrote: i don't....but jetpack paladin is awesome!
=]
Thanks btw XD
And thanks for your help Montycarlo. This mess is made worse by the precision I'm trying to get into it. I'm looking currently at using an array to store the y axis movement for each frame of the jump, like so:
sprite.jumpPattern = [-7, -7, -5, -5, -3, -3, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 5, 5, 7, 7];
Might seem overly complicated but it seems to be working quite nicely.
Montycarlo's method will work better, because your going to have troubles when your jumping off a slope or onto one.