Ground Slide?(Castlevania)
#1
Posted 02 March 2012 - 10:05 AM
I am working on my first game(platformer) and I am trying to make a ground slide like in Castlevania games for my character, so he can slide under projectiles and in tight spaces. I wish to have it so when I hold down(duck variable= 1) and press my jump key(z), he moves forward a short distance, and can not slide again untill the current slide is finished. I tried this
Z key press event:
If duck= 1
execute code:
if image_xscale= 1
x+= 5
if image_xscale= -1
x+= -5
with this he barely slides forward, as if my code says "x+=1". I tried changing it all the way up to "x+=10" and he still barely moves. I am pretty sure this has to do with the z key being a "key press" event and not a "keyboard" one, but if changed not only will he continue to slide untill you release z(if not forever), you will be able to hold the jump button and he will constantly jump, which is not wanted. Is there a way to have the player move forward a set distance, and then stop when a "slide" is executed? I have been looking at other posts and tutorials on things that look like they may help me with no luck.
If anyone can offer advice on this, could you please? Sorry for my inexperience.
Thanks
#2
Posted 02 March 2012 - 11:00 AM
I can't imagine why changing the value won't change how far he moves, but I can say why he only moves for one step. You only tell it to move your character 5 pixels once. To do what you're after it will take more than a single event.Hi guys.
I am working on my first game(platformer) and I am trying to make a ground slide like in Castlevania games for my character, so he can slide under projectiles and in tight spaces. I wish to have it so when I hold down(duck variable= 1) and press my jump key(z), he moves forward a short distance, and can not slide again untill the current slide is finished. I tried this
Z key press event:
If duck= 1
execute code:
if image_xscale= 1
x+= 5
if image_xscale= -1
x+= -5
with this he barely slides forward, as if my code says "x+=1". I tried changing it all the way up to "x+=10" and he still barely moves. I am pretty sure this has to do with the z key being a "key press" event and not a "keyboard" one, but if changed not only will he continue to slide untill you release z(if not forever), you will be able to hold the jump button and he will constantly jump, which is not wanted. Is there a way to have the player move forward a set distance, and then stop when a "slide" is executed? I have been looking at other posts and tutorials on things that look like they may help me with no luck.
If anyone can offer advice on this, could you please? Sorry for my inexperience.
Thanks
Basically, when you're sliding you want the player to have no control over the character's movement, until the slide is finished. During that time, the character should slide at [x] speed, for [y] steps. After [y] steps, the player should be back in control. In order to do this you need 2 things:
1: A variable for sliding/control. Say, when your character is created, set sliding=0. When Z is pressed and duck=1, change it so slide=1, and...
2: An alarm for sliding. Say you use alarm[0], and you want to slide for 15 steps, 5 pixels each step. Right after slide=1 in your Z event, have it set alarm[0]=15. In the alarm[0] event, have it set slide=0 again.
You just need a step event that checks if slide=1, and if it is, it moves the character however many pixels you want.
Now this part might be the hardest: You have to stop the player from moving, changing sprites, and attacking while slide=1. This means going back to that code and adding a check variable to make sure slide=0 before you allow movement and such.
I should also note, that since you're doing a Castlevania game, there may be many reasons you won't be able to move. While whipping, your character can't move, just like sliding. You might choose to have a variable canmove=[0 or 1] so you can disable player control for more than just sliding later on.
#3
Posted 03 March 2012 - 10:36 AM
I can't imagine why changing the value won't change how far he moves, but I can say why he only moves for one step. You only tell it to move your character 5 pixels once. To do what you're after it will take more than a single event.
Basically, when you're sliding you want the player to have no control over the character's movement, until the slide is finished. During that time, the character should slide at [x] speed, for [y] steps. After [y] steps, the player should be back in control. In order to do this you need 2 things:
1: A variable for sliding/control. Say, when your character is created, set sliding=0. When Z is pressed and duck=1, change it so slide=1, and...
2: An alarm for sliding. Say you use alarm[0], and you want to slide for 15 steps, 5 pixels each step. Right after slide=1 in your Z event, have it set alarm[0]=15. In the alarm[0] event, have it set slide=0 again.
You just need a step event that checks if slide=1, and if it is, it moves the character however many pixels you want.
Now this part might be the hardest: You have to stop the player from moving, changing sprites, and attacking while slide=1. This means going back to that code and adding a check variable to make sure slide=0 before you allow movement and such.
I should also note, that since you're doing a Castlevania game, there may be many reasons you won't be able to move. While whipping, your character can't move, just like sliding. You might choose to have a variable canmove=[0 or 1] so you can disable player control for more than just sliding later on.
Thanks a ton! But there is one problem... Once he starts sliding, if I keep pressing the Z key even after letting go of down, he keeps sliding forever and there are no pauses between the slides. Is there a way to create a pause after a slide is finished, so if I am pressing the Z key repeatedly and he is sliding he will still stop for a second? I think by mashing the Z key while sliding I keep changing alarm 0's steps back to 15, causing the slide to never end. How can I get Alarm 0's steps to not reset when I push Z while he is sliding?
Thanks alot for the reply
#4
Posted 05 March 2012 - 09:54 AM
I can't imagine why changing the value won't change how far he moves, but I can say why he only moves for one step. You only tell it to move your character 5 pixels once. To do what you're after it will take more than a single event.
Basically, when you're sliding you want the player to have no control over the character's movement, until the slide is finished. During that time, the character should slide at [x] speed, for [y] steps. After [y] steps, the player should be back in control. In order to do this you need 2 things:
1: A variable for sliding/control. Say, when your character is created, set sliding=0. When Z is pressed and duck=1, change it so slide=1, and...
2: An alarm for sliding. Say you use alarm[0], and you want to slide for 15 steps, 5 pixels each step. Right after slide=1 in your Z event, have it set alarm[0]=15. In the alarm[0] event, have it set slide=0 again.
You just need a step event that checks if slide=1, and if it is, it moves the character however many pixels you want.
Now this part might be the hardest: You have to stop the player from moving, changing sprites, and attacking while slide=1. This means going back to that code and adding a check variable to make sure slide=0 before you allow movement and such.
I should also note, that since you're doing a Castlevania game, there may be many reasons you won't be able to move. While whipping, your character can't move, just like sliding. You might choose to have a variable canmove=[0 or 1] so you can disable player control for more than just sliding later on.
Thanks a ton! But there is one problem... Once he starts sliding, if I keep pressing the Z key even after letting go of down, he keeps sliding forever and there are no pauses between the slides. Is there a way to create a pause after a slide is finished, so if I am pressing the Z key repeatedly and he is sliding he will still stop for a second? I think by mashing the Z key while sliding I keep changing alarm 0's steps back to 15, causing the slide to never end. How can I get Alarm 0's steps to not reset when I push Z while he is sliding?
Thanks alot for the reply
Sorry for the long wait on the reply.
You need to factor in one more thing... if you're already sliding, you don't want to be able to start sliding again! Make sure slide=0 in the slide code.
You should be able to make another alarm, say alarm[1]=5 in the alarm[0] event. You also need to use a variable that isn't slide, which stops the player from moving. (or just sliding, if you want.) Set that canmove=0 when the player starts sliding (you can just use this from now on to stop the player from moving, instead of the slide variable) and in the alarm[1] event, set it to 1.
The point is, adding the second alarm that is set at the end of alarm[0] lets you say for a short time the character cannot move. Doing this would help keep players from sliding around the level because it's faster than walking, and it would make sliding more strategic, because you have a short moment of immobility after a slide.
I also highly recommend changing things around so that the variable canmove is the only special circumstance in your movement checks. That way, if you want to make the player immobile, it's always the same variable, and slide only controls if you're sliding at the time.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











