Windows Code Check

J

JesterLuciferDeath

Guest
Hello! I am running into a few barriers, and and to get this ran through someone who knows what they're doing.

There are some codes I knowingly know are causing errors, and commented them out.
I'm unsure how my code is doing, and whether my code is correct.

What I'm Looking For: You know the Zelda Top-Down games? How the attack animations end, ect?
That's what I'm attempting to do. I know the 'attack animations' work through testing them out.

Right now my attack 'swipes' look like crap, but that's besides the point of what I'm trying to do. Those are tests.

Any help would be appreciated. And yes I am trying tutorials, right now HeartBeast (https://www.youtube.com/channel/UCrHQNOyU1q6BFEfkNq2CYMA) is the only one with the 'Top-Down Game' style I've been looking for.


Scripts | 'scr_get_input':
/// scr_get_input

// Move Down

if (keyboard_check (ord('S'))) && (place_free (x,y+3))
{
y += 3
sprite_index = death_down
image_speed = 1/7
}

// Move Up
if (keyboard_check (ord('W'))) && (place_free (x,y-3))
{
y -= 3
sprite_index = death_up
image_speed = 1/7
}

// Move Right
if (keyboard_check (ord('D'))) && (place_free (x,x+3))
{
x += 3
sprite_index = spr_death
image_speed = 1/7
}

// Move Left
if (keyboard_check (ord('A'))) && (place_free (x,x-3))
{
x -= 3
sprite_index = death_left
image_speed = 1/7
}

// Attack

attack_key = keyboard_check_pressed(vk_space);


Scripts | 'script_attack_state':
/// script_attack_state

image_speed = 1/2;

switch (sprite_index) {

case death_up:
sprite_index = animation_attkupsprte;
break;

case death_down:
sprite_index = animation_attkdownsprte;
break;

case death_left:
sprite_index = animation_attkleftsprte;
break;

case spr_death:
sprite_index = animation_attkrightsrpte;
break;
}



Scripts | 'scr_move_state' (Commented out for Error):
/// scr_move_state

scr_get_input();

// Filler move script

// Get the axis

// var xaxis = ('D' - 'A');
// var yaxis = ('S' - 'W');

// Get direction
// var dir = point_direction(0, 0, xaxis, yaxis);

// Length

/*
if (xaxis == 0 && yaxis = 0) {
len = 0;
} else {
len = spd;
}


// Speed
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);

// Move
phy_position_x += hspd;
phy_position_y += vspd;



// Control the sprite

image_speed = sign(len)*.2;

if (len == 0) image_index = 0;

if (vspd > 0) {
sprite_index = death_down;
} else if (vspd < 0) {
sprite_index = death_up;
}

if (hspd > 0) {
sprite_index = spr_death;
} else if (hspd < 0) {
sprite_index = death_left;
}

*/
// Attack

Objects | Characters | 'player_death' | Create:
//Variables
/*
firing = false
rateOfFire = 20;
image_speed = 1/7
facing = 1
*/
scr_get_input();
state = scr_move_state;


Objects | Characters | 'player_death' | Step:

/// Other code

/*
// Move Down
if (keyboard_check (ord('S'))) && (place_free (x,y+3))
{
y += 3
sprite_index = death_down
image_speed = 1/7
}

// Move Up
if (keyboard_check (ord('W'))) && (place_free (x,y-3))
{
y -= 3
sprite_index = death_up
image_speed = 1/7
}

// Move Right
if (keyboard_check (ord('D'))) && (place_free (x,x+3))
{
x += 3
sprite_index = spr_death
image_speed = 1/7
}

// Move Left
if (keyboard_check (ord('A'))) && (place_free (x,x-3))
{
x -= 3
sprite_index = death_left
image_speed = 1/7
}
*/

/*

// Attack

attack_key = keyboard_check_pressed(vk_space);

if (attack_key){
image_index = 0;
script_execute(script_attack_state);
}

*/

scr_get_input();
script_execute(state);

Objects | Characters | 'player_death' | Animation End:
(Commented out due to Error)

/// Change back to moving.

/*
if (state == script_attack_state){
state = scr_move_state;

}
*/
 

obscene

Member
If you have a problem, you need to explain exactly what is happening and exactly what you want to happen.

"I'm unsure how my code is doing, and whether my code is correct." <- Doesn't really tell us anything.
 
J

JesterLuciferDeath

Guest
If you have a problem, you need to explain exactly what is happening and exactly what you want to happen.

"I'm unsure how my code is doing, and whether my code is correct." <- Doesn't really tell us anything.
I'm trying to make the Animation to end when it "completes" ex. Sprite: animation_deathattk(all directions) get to their final frame.

Is that more detailed?
 

obscene

Member
Ok so when image_index>=image_number image_speed=0

However there are probably so many things else to consider here. When you don't press a key at all what happens now? Does your character walk in place? Do you want the player to continue and finish moving in a direction until the animation is complete?
 
D

DekuNut

Guest
deleting all the commented code I'm left with this:

Scripts | 'scr_get_input':
/// scr_get_input

// Move Down

if (keyboard_check (ord('S'))) && (place_free (x,y+3))
{
y += 3
sprite_index = death_down
image_speed = 1/7
}

// Move Up
if (keyboard_check (ord('W'))) && (place_free (x,y-3))
{
y -= 3
sprite_index = death_up
image_speed = 1/7
}

// Move Right
if (keyboard_check (ord('D'))) && (place_free (x,x+3))
{
x += 3
sprite_index = spr_death
image_speed = 1/7
}

// Move Left
if (keyboard_check (ord('A'))) && (place_free (x,x-3))
{
x -= 3
sprite_index = death_left
image_speed = 1/7
}

// Attack

attack_key = keyboard_check_pressed(vk_space);


Scripts | 'script_attack_state':
/// script_attack_state

image_speed = 1/2;

switch (sprite_index) {

case death_up:
sprite_index = animation_attkupsprte;
break;

case death_down:
sprite_index = animation_attkdownsprte;
break;

case death_left:
sprite_index = animation_attkleftsprte;
break;

case spr_death:
sprite_index = animation_attkrightsrpte;
break;
}


Scripts | 'scr_move_state' (Commented out for Error):
/// scr_move_state

scr_get_input();


Objects | Characters | 'player_death' | Create:
//Variables

scr_get_input();
state = scr_move_state;

Objects | Characters | 'player_death' | Step:


/// Other code

scr_get_input();
script_execute(state);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Objects | Characters | 'player_death' | Step:

/// Other code

scr_get_input();
script_execute(state);

First off you are basically calling the same code twice here.

Second, every step, you're constantly looping back and checking to see if you're holding a movement key. Looking at how you handle movement and animation:

if (keyboard_check (ord('S'))) && (place_free (x,y+3))
{
y += 3
sprite_index = death_down
image_speed = 1/7
}

As long as you are holding the 'S' key, every step you will be setting the sprite_index to the first frame of death_down. You aren't giving the program enough time to cycle through the animation.
 
J

JesterLuciferDeath

Guest
Ok so when image_index>=image_number image_speed=0

However there are probably so many things else to consider here. When you don't press a key at all what happens now? Does your character walk in place? Do you want the player to continue and finish moving in a direction until the animation is complete?
I want the character to stop doing it's attack animation in a set time, as it just keeps looping.

Video:
 
J

JesterLuciferDeath

Guest
deleting all the commented code I'm left with this:

Scripts | 'scr_get_input':
/// scr_get_input

// Move Down

if (keyboard_check (ord('S'))) && (place_free (x,y+3))
{
y += 3
sprite_index = death_down
image_speed = 1/7
}

// Move Up
if (keyboard_check (ord('W'))) && (place_free (x,y-3))
{
y -= 3
sprite_index = death_up
image_speed = 1/7
}

// Move Right
if (keyboard_check (ord('D'))) && (place_free (x,x+3))
{
x += 3
sprite_index = spr_death
image_speed = 1/7
}

// Move Left
if (keyboard_check (ord('A'))) && (place_free (x,x-3))
{
x -= 3
sprite_index = death_left
image_speed = 1/7
}

// Attack

attack_key = keyboard_check_pressed(vk_space);


Scripts | 'script_attack_state':
/// script_attack_state

image_speed = 1/2;

switch (sprite_index) {

case death_up:
sprite_index = animation_attkupsprte;
break;

case death_down:
sprite_index = animation_attkdownsprte;
break;

case death_left:
sprite_index = animation_attkleftsprte;
break;

case spr_death:
sprite_index = animation_attkrightsrpte;
break;
}


Scripts | 'scr_move_state' (Commented out for Error):
/// scr_move_state

scr_get_input();


Objects | Characters | 'player_death' | Create:
//Variables

scr_get_input();
state = scr_move_state;

Objects | Characters | 'player_death' | Step:


/// Other code

scr_get_input();
script_execute(state);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Objects | Characters | 'player_death' | Step:

/// Other code

scr_get_input();
script_execute(state);

First off you are basically calling the same code twice here.

Second, every step, you're constantly looping back and checking to see if you're holding a movement key. Looking at how you handle movement and animation:

if (keyboard_check (ord('S'))) && (place_free (x,y+3))
{
y += 3
sprite_index = death_down
image_speed = 1/7
}

As long as you are holding the 'S' key, every step you will be setting the sprite_index to the first frame of death_down. You aren't giving the program enough time to cycle through the animation.


Hmm... I will indeed check this out
 

obscene

Member
When you attack, you must begin either an alarm or a timer which is much simpler. Let's say every time you press the attack button, set the variable "attack" to equal the length of time you want the attack to last.




Code:
if input
{
  if attack==0 attack=8 // Check to see if attack is done before starting a new one.
}

if attack
{
  // Use attack animations
  attack--;
}
else
{
  // Use normal animations
}
 
J

JesterLuciferDeath

Guest
When you attack, you must begin either an alarm or a timer which is much simpler. Let's say every time you press the attack button, set the variable "attack" to equal the length of time you want the attack to last.




Code:
if input
{
  if attack==0 attack=8 // Check to see if attack is done before starting a new one.
}

if attack
{
  // Use attack animations
  attack--;
}
else
{
  // Use normal animations
}

So, the numbers being in seconds; say I want it to last 15 seconds and make the attack about 6 fps (I have like 20 frames so I'm thinking that can go through the entire animation, but that's just me doing math in like a second).
I'd do:
Code:
if input {
   if attack == 0 (should I put 'and', 'or', or '&&'?) attack = 15
}

if attack {
   attack--; (i'm guessing I put a number in the --)
}
else {
   state = scr_move_state;
}
 
J

JesterLuciferDeath

Guest
Hey. Hey you this is a bit off topic, but how did you make such sexy lens flares in Orphan? I'm not entirely looking for an answer btw. For real though keep up the good work. It looks so good, there's an upcoming GDC talk from the creators of Inside, and Limbo it covers graphics, and I think it's worth viewing. I need to find it though.

EDIT: Found it http://schedule.gdconf.com/session/low-complexity-high-fidelity-inside-rendering
I'm sure it's worth viewing, but I'd like the topic to stay on point.
 
J

JesterLuciferDeath

Guest
So, the numbers being in seconds; say I want it to last 15 seconds and make the attack about 6 fps (I have like 20 frames so I'm thinking that can go through the entire animation, but that's just me doing math in like a second).
I'd do:
Code:
if input {
   if attack == 0 (should I put 'and', 'or', or '&&'?) attack = 15
}

if attack {
   attack--; (i'm guessing I put a number in the --)
}
else {
   state = scr_move_state;
}
um..?
 
Top