objPlayer [Create & Step]

[ITA]
Bene creato objPlayer, nella sezione Create ho dichiarato al momento le seguenti variabili:







Ho cercato di commentare più semplicemente possibile perché è facile che mi dimentichi da qui a lì il significato di certe variabili.
Ora, alcune di esse non sono ancora utilizzate nel codice, ma questo è un'altra storia.

Passiamo al codice contenuto in Step:











Qui ancora non ho preso la briga di commentare ma avviene questo:

Al movimento destra e sinistra viene applicata un'accelerazione e una decelerazione contenuta in un certo range di valore (tramite la funzione Clamp).
Poi viene applicato un controllo sulla verticale in maniera da applicare una gravità al salto.
Se viene premuto Up il giocatore salta e se si continua a tenere premuto Up, il giocatore esegue un salto più alto (somma le due variabili jump_height_ + jump_height_held_)

Infine un controllo determinare se c'è un muro che ostacola e ferma il giocatore sia in orizzontale che in verticale.

1° domanda:
come faccio a fare in modo che quando premo Up la prima volta a seconda di quanto lo tengo premuto, salti più in alto?

2° domanda:
come faccio a far eseguire il salto allungato (o salto doppio) in aria, senza che il giocatore (come è nel caso del mio codice) debba per forza toccare l'oggetto solido per eseguire l'azione?

Grazie tante!





[ENG]
Well I created objPlayer, into the Create section I declared the following vars:





I tried to comment the code to avoid my brain to burn down trying to remember all of them.
Now, some of them are not used yet.

Now the code inside Step section:




Here I'm a kind of lazy so I don't comment nothing but you can see what happen:

To right and left direction is applied an acceleration and deceleration conteined between a range of value (Clamp function).
The there is a gravity paramenter applied to the jump function and the vertical speed.
If key Up is pressed the player jumps and if that key is kept pressed, the player executes an higher jump/double jump (sum the two vars jump_height_ + jump_height_held_)

At the end a function check (both in horizontal and in vertical) if a wall (or a solid object) stuck'n'stop the player.

1° question:
How I can make the player jumps more higher as more long I press the Up key?

2° question:
How I can make the "double jump" in the air, without the player (as I coded now) needs to touch the ground to execute the action?

Many Thanks!


Commenti

Post più popolari