W
WizardBones
Guest
Hey guys, I'm an artist trying to get some controls worked out so I can work on game animations.
I am wondering how I could change animations with the up or down arrow buttons. A type of index perhaps? when you press up his aim animation will angled, press up again even more angled, and 3rd press he is aiming his max. And the obvious down would make him cycle back through animation index. until you reach final down aim. If you hold either up or down it will cycle through them all depending on the key pressed. I have NO idea how to even begin, remember I'm just an artist, not making a game yet persay, but I wanna see how my sprites look in action : )
I assume splitting the body in two sections, so walking will be separate, just want the character to arm as i press button, I see lots for follow mouse, but I am after a more old school approach, it suits my drawings. Contra or Ghost busters II for the NES are basically the same concept. Thanks for reading.
EDIT: Maybe not needed but I will add the code from the tutorial I been following, maybe familiar to you. but help make things work right if not
/// Platform Physics
var rkey = keyboard_check(vk_right);
var lkey = keyboard_check(vk_left);
var jkey = keyboard_check(vk_up);
// Check for ground
if (place_meeting(x, y+1, obj_solid)) {
vspd = 0;
// Jumping
if (jkey) {
vspd = -jspd;
sprite_index = spr_player_stand;
}
} else {
// Gravity
if (vspd < 10) {
vspd += grav;
}
}
// Moving Right
if (rkey) {
hspd = spd;
}
// Moving Left
if (lkey) {
hspd = -spd;
}
// Check for not moving
if ((!rkey && !lkey)|| (rkey && lkey)) {
hspd = 0;
}
// Horizotal collisions
if (place_meeting(x+hspd, y, obj_solid)) {
while (!place_meeting(x+sign(hspd), y, obj_solid)) {
x+= sign(hspd);
}
hspd = 0;
}
// Move Horrizontally
x += hspd;
// Vertical collisions
if (place_meeting(x, y+vspd, obj_solid)) {
while (!place_meeting(x, y+sign(vspd), obj_solid)) {
y+= sign(vspd);
}
vspd = 0;
}
// Move Vertically
y += vspd;
//Control The Sprites
/*if(vspd != 0)
{
sprite_index = spr_player_jump;
image_speed = 0;
//use the next line if you have a falling animation as well but the falling animation should be the second one
//image_index = y>yprevious;
}
else
{
*/
if(hspd != 0)
{
sprite_index = spr_player_walk;
image_speed = .3;
}
else if(hspd = 0)
{
sprite_index = spr_player_stand;
}
//}
if !(place_meeting(x,y+1, obj_solid)){sprite_index=spr_player_jump}
//Control the direction that the player is facing
if(hspd > 0)
{
image_xscale = 1;
}
else if (hspd < 0)
{
image_xscale = -1;
}
I am wondering how I could change animations with the up or down arrow buttons. A type of index perhaps? when you press up his aim animation will angled, press up again even more angled, and 3rd press he is aiming his max. And the obvious down would make him cycle back through animation index. until you reach final down aim. If you hold either up or down it will cycle through them all depending on the key pressed. I have NO idea how to even begin, remember I'm just an artist, not making a game yet persay, but I wanna see how my sprites look in action : )
I assume splitting the body in two sections, so walking will be separate, just want the character to arm as i press button, I see lots for follow mouse, but I am after a more old school approach, it suits my drawings. Contra or Ghost busters II for the NES are basically the same concept. Thanks for reading.
EDIT: Maybe not needed but I will add the code from the tutorial I been following, maybe familiar to you. but help make things work right if not
/// Platform Physics
var rkey = keyboard_check(vk_right);
var lkey = keyboard_check(vk_left);
var jkey = keyboard_check(vk_up);
// Check for ground
if (place_meeting(x, y+1, obj_solid)) {
vspd = 0;
// Jumping
if (jkey) {
vspd = -jspd;
sprite_index = spr_player_stand;
}
} else {
// Gravity
if (vspd < 10) {
vspd += grav;
}
}
// Moving Right
if (rkey) {
hspd = spd;
}
// Moving Left
if (lkey) {
hspd = -spd;
}
// Check for not moving
if ((!rkey && !lkey)|| (rkey && lkey)) {
hspd = 0;
}
// Horizotal collisions
if (place_meeting(x+hspd, y, obj_solid)) {
while (!place_meeting(x+sign(hspd), y, obj_solid)) {
x+= sign(hspd);
}
hspd = 0;
}
// Move Horrizontally
x += hspd;
// Vertical collisions
if (place_meeting(x, y+vspd, obj_solid)) {
while (!place_meeting(x, y+sign(vspd), obj_solid)) {
y+= sign(vspd);
}
vspd = 0;
}
// Move Vertically
y += vspd;
//Control The Sprites
/*if(vspd != 0)
{
sprite_index = spr_player_jump;
image_speed = 0;
//use the next line if you have a falling animation as well but the falling animation should be the second one
//image_index = y>yprevious;
}
else
{
*/
if(hspd != 0)
{
sprite_index = spr_player_walk;
image_speed = .3;
}
else if(hspd = 0)
{
sprite_index = spr_player_stand;
}
//}
if !(place_meeting(x,y+1, obj_solid)){sprite_index=spr_player_jump}
//Control the direction that the player is facing
if(hspd > 0)
{
image_xscale = 1;
}
else if (hspd < 0)
{
image_xscale = -1;
}
Last edited by a moderator: