Create
Code
walkspeed=.35 //sets the speed of animation
image_speed=walkspeed
bounderies=sprite_width/2 //left and right bounderies for the room (half of the characters sprite widht recommended)
chr_speed=3 //speed of the character (more=faster)
jump=12 //sets the speed of the jump (more=higher)
maxheight=2 //maximum height to go on a sloped ground
fallspeed=.4 //how fast you fall (gravity)
onGround=false //tells if you are on the ground (don't change)
right=0 //turning variables (don't change)
left=0 //turning variables (don't change)
facedirection="right" //turning variables (don't change)
idlespeed=.1
Code
spriteIdle=argument0 //idle sprite
spriteWalk=argument1 //walk sprite
spriteJump=argument2 //jump sprite
Code
rightkey=vk_right
leftkey=vk_left
jumpkey=vk_up
Step
Code
if keyboard_lastkey=rightkey { //if you pressed the right key last
if left=0 { //if you are not moving left
image_xscale=1 //flips the image to face right
facedirection="right" //sets the variable direction (for bullet movement)
} //end if
} //end if
if keyboard_lastkey=leftkey{ //if you pressed the left key last
if right=0 { //if you are not moving right
image_xscale=-1 //flips the image to face left
facedirection="left" //sets the variable direction (for bullet movement)
} //end if
} //end if
if place_free(x,y+2) { //if there is no solid object below you
onGround=false //you are not on the ground
} else { //or if there is
onGround=true //you are on the ground
}
if onGround=false { //if you are not on the ground
gravity=fallspeed //sets the gravity
gravity_direction=270 //sets the direction (right=0, regular angles
}
if onGround=true { //if you are on the ground
gravity=0 //no more gravity
gravity_direction=0 //set the direction to the right to get rid of any bugs
}
if keyboard_check_released(rightkey) { //if you released the right arrow key
right=0 //you are not facing right anymore
}
if keyboard_check_released(leftkey) { //if you released the left arrow key
left=0 //you are not facing left anymore
}
if keyboard_check(vk_nokey) {
if onGround=true { //if you are on the ground
sprite_index=spriteIdle //sets the sprite
image_speed=idlespeed //sets the image speed
}
Добавлено (27.01.2011, 23:42)
---------------------------------------------
События клавиш надеюсь ненадо...