SOLVED draw_sprite_part: drawing from bottom to a rising top

Bentley

Member
When the player is spawned, I want draw_sprite_part to draw the player 1 pixel at a time. I want it to start at his feet, and rise until his head is drawn. In other words, I want to draw a 1 pixel high rectangular area at his feet (the bottom of the sprite), and increase the size of that rectangular area until it is at his head (the top of the sprite). The whole sprite will be drawn at the end.

The code I have draws him from his feet first, but draws his feet moving downward. I don't want his feet to move, and I want the rest of the sprite to be drawn upward from his feet.
Code:
var x1, y1, x2, y2;
x1 = 0;
x2 = sprite_width;
y1 = sprite_height - y_count; // Draw the sprite, 1 px at a time, starting from his feet and ending at his head
y2 = sprite_height;
draw_sprite_part(spr_player, 0, x1, y1, x2, y2, x, y);
if (y_count < sprite_height)
{
    y_count++;
}
Does anyone where I'm going wrong? Thanks for reading.
 
Last edited:

obscene

Member
Subtract y_count from y in your draw function. I think that would do it. If his feet are moving downward, subtracting a value each step should make them move back up to compensate.
 

Bentley

Member
Subtract y_count from y in your draw function. I think that would do it. If his feet are moving downward, subtracting a value each step should make them move back up to compensate.
Wow, that works. Thanks obscene. I would never have guessed that.
 
A

alib0ng0

Guest
Do you have some completed code for this please? - I'm trying to achieve a similar effect
 

Lady Glitch

Member
Do you have some completed code for this please? - I'm trying to achieve a similar effect
I advise you to re-read this thread :)
Code:
var x1, y1, x2, y2;
x1 = 0;
x2 = sprite_width;
y1 = sprite_height - y_count; // Draw the sprite, 1 px at a time, starting from his feet and ending at his head
y2 = sprite_height;
draw_sprite_part(spr_player, 0, x1, y1, x2, y2, x, y-y_count);
if (y_count < sprite_height)
{
   y_count++;
}
 
A

alib0ng0

Guest
I advise you to re-read this thread :)
Code:
var x1, y1, x2, y2;
x1 = 0;
x2 = sprite_width;
y1 = sprite_height - y_count; // Draw the sprite, 1 px at a time, starting from his feet and ending at his head
y2 = sprite_height;
draw_sprite_part(spr_player, 0, x1, y1, x2, y2, x, y-y_count);
if (y_count < sprite_height)
{
   y_count++;
}

Ok, my bad, I was trying to add it to the if statement - thanks!

Let's say I wanted to reverse this - i.e. start from the top how would that work?
 

Lady Glitch

Member
Let's say I wanted to reverse this - i.e. start from the top how would that work?
This should do it
Code:
y_count = sprite_height;
Code:
var x1, y1, x2, y2;
x1 = 0;
x2 = sprite_width;
y1 = 0;
y2 = sprite_height-y_count;
draw_sprite_part(spr_player, 0, x1, y1, x2, y2, x, y);
if (y_count > 0)
{
   y_count--;
}
 
Top