Windows Animate Movement 2d platform help

Y

yza

Guest
Hi there

I need all codes to implement animated movements for obj_player

i want keyboard
vk_left
vk_right
vk_down
vk_space
vk_Letter // for attack

now..., what i would like ....
///////////////////////////////////////////// vk_space
when I press the space key just once, I mean not to hold key, i want to change sprite from sprite_stand to sprite_jump and the animations of sprite i want to continue ,because this animation happens, these sprite exchanges, not when I keep press key_vkspace so I would like to press once and run all sprite animation of (sprite_jump) only if it does not touch obj_wall and then when return to the ground to change sprite in sprite_stand

and also if i press right key space key I want to continue jumping with the animation sprite_jump and to move to the right
///////////////////////////////////// end

////////////////////////////vk_Letter
like at vk_space I want to hit, run the animation only when I press once not when I keep press

I am waiting for your help because only my account was approved on steam direct steam work and I need to finish and publish the game
 

Attachments

TsukaYuriko

☄️
Forum Staff
Moderator
Which part of this do you need help with? What have you tried so far? Where did you get stuck?

The opening post sort of sounds like you expect us to just do all the work for you, which I'm afraid is not what this community is for... you gotta put in some effort on your own. We're only here to help with that. ;)
 

Joe Ellis

Member
If you need to finish and publish the game, my heart is filled with dread for you. I don't know what lead you to be expecting to release a game, when you can't even make one. I'm not being horrible but you need to start at the beginning and just learn stuff. The stuff you're talking about is pretty easy, maybe some parts are quite specific, and I have advice for those, but at this point it looks like you need to learn basic things about the player moving.
Unless I've mistaken what you were saying and you do have basic things working, and were just being really specific about what you want.
 
Y

yza

Guest
I have advanced knowledge of design and logic programming but not for the animation player's movements, there was no need to publish this comment, I could even give you some codes for the animation movements but I said it was easier for me to come with yours.
 

Joe Ellis

Member
Sorry I didn't want to offend you, I was just being honest and trying to help you. Well let's forgot about that and talk about the stuff you want to do.

My favourite way of programming the player is by using state scripts, like idle, running, jumping, attacking, hurt, landing from a jump.
Cus this lets you only check for certain key presses per state, like while jumping it doesn't need to check for vk_space, and maybe would perform a different attack while in the air.
To make the player perform it's state script, you just need to put "script_execute(state)" in it's step event.
Some things like collision, or the actual movement: "x += hsp; y += vsp" that will be the same in any state can be put in the step event, before or after the state is executed, depending which order is best for that certain thing.

You always need to make sure there is a condition that will end the current state and return to the idle state, so while jumping it will check for ground collision and set the state to "player_land" and the sprite to the landing animation, and for most other states (attacking, hurt, landing) it will check that the animation has finished.
There are a few ways to check the animation has finished, you can use the animation_end event, or I prefer to ask:
Code:
if ++time > 1 / image_speed
&& image_index < 1
{
time = 0
state = state_player_idle
sprite_index = spr_player_idle
image_index = 0
}
The (1 / image_speed) gives the amount of steps it takes for 1 animation frame, so once the animation has finished, image_index will be 0 or 0.002 or something, and the only thing needed to stop it from thinking it's finished when the state is first set is to use the "time" variable, and if time > the length of 1 frame, it must have run through the whole animation. So if you use this method, it's important that you make sure to set time and image_index to 0 when you change the state.

You can do these things without using states, but I never do so I'd rather let someone else explain about that.
I recommend using states mainly cus it simplifies the player's step event alot, and results in alot less conditions
 
Top