PHP Code:
//#CLIENTSIDE
if (created) {
disabledefmovement;
}
if (timeout)
{
this.my = (keydown(2) - keydown(0))/2;
this.mx = (keydown(3) - keydown(1))/2;
if (!onwall(playerx + this.mx,playery))
playerx += this.mx;
if (!onwall(playerx,playery + this.my))
playery += this.my;
playery += 0.1;
timeout = 0.05;
}
// Script Corrected.
First off: Start every group with events... Basically, events are what happens for something to execute:
PHP Code:
if (timeout) // == Whenever the timeout var reaches 0, it calls a timeout event.
... and...
PHP Code:
this.my = keydown(2) - keydown(0);
Okay: Here, the principal is... Whenever up key is pressed, it returns a 1... Whenever down key is pressed, it returns a 1.
this.my = 1 - 0 = 1; That would make it go towards the right.
If no keys are pressed, this.my = 0;... If only the up key is pressed...
this.my = 0 - 1 = -1; So, it would go up.
Onwall tests the actual movement.
PHP Code:
playery += 0.1; // Here should be something that increases all the time:
Make it:
PHP Code:
if (!onwall(playerx,playery + this.grav))
this.grav = this.grav + 0.1;
else this.grav = 0;
playery += this.grav;
This is a very rough show on how it works... But well, basically, the force of gravity increases steadily everytime that the player can 'fall'.
The rest of the script works with the actual moving of the character.