//////// The first part to control the player
// Movements
running = false;
if (keyboard_check(ord('A'))) {
x -= 3;
global.mage_left = true;
global.mage_right = false;
running = true;
}
if (keyboard_check(ord('D'))) {
x += 3;
global.mage_left = false;
global.mage_right = true;
running = true;
}
if (keyboard_check(ord('W'))) {
y -= 3;
running = true;
}
if (keyboard_check(ord('S'))) {
y += 3;
running = true;
}
// Attacks
if (keyboard_check(vk_right) || keyboard_check(vk_down)) {
attacking = true;
}
else { // Stop attacking
attacking = false;
speed = 0;
}
// Jumping
if (keyboard_check_pressed(vk_space)) {
// Put your jumping stuff here except setting sprites
}
//////// Then change the sprite according to those states
if (global.mage_jump) {
if (global.mage_left) {
sprite_index = Mage_jump_Left;
}
else if (global.mage_right) {
sprite_index = Mage_jump_Right;
}
}
else if (attacking) {
if (global.mage_left) {
sprite_index = Magic_Punch_Left;
}
else if (global.mage_right) {
sprite_index = Magic_Punch_Right;
}
}
else if (running) {
if (global.mage_left) {
sprite_index = Mage_Run_Left;
}
else if (global.mage_right) {
sprite_index = Mage_Run_Right;
}
}
else {
if (global.mage_left) {
sprite_index = Mage_Face_Left;
}
else if (global.mage_right) {
sprite_index = Mage_Face_Right;
}
}
Edited by Criminon, 19 March 2012 - 10:38 AM.











