• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

draw_sprite_part() need help

N

NoFontNL

Guest
I've read the manual, but I can't figure out how the function works.

I want to draw a sprite. 4 to the right and 4 down from the object his x and y position. But cut 4 from the bottom off. Can someone help me?
 

FrostyCat

Redemption Seeker
Post your code and an example of the result you want. From your description alone ("4 to the right and 4 down"), this is something draw_sprite() can already do, so I have no idea why you're even trying draw_sprite_part() to start with.
 
N

NoFontNL

Guest
Post your code and an example of the result you want. From your description alone ("4 to the right and 4 down"), this is something draw_sprite() can already do, so I have no idea why you're even trying draw_sprite_part() to start with.
draw_sprite_part(sprite_index,image_index,0,0,sprite_width,sprite_height-4,x+4,y+4);


4 to the right, 4 down, but cut 4 pixels off on the bottom
 
N

NoFontNL

Guest
That's exactly how it's done. What's wrong with it?
This is the full code I'm using:
Code:
if(!place_meeting(x+1,y+1,par_couele)){
    draw_sprite(sprite_index,image_index,x+4,y+4);
} else if(!place_meeting(x+1,y,par_couele)) {
    draw_sprite_part(sprite_index,image_index,0,0,sprite_width,sprite_height-4,x+4,y+4);
} else if(!place_meeting(x,y+1,par_couele)) {
    draw_sprite_part(sprite_index,image_index,0,0,sprite_width-4,sprite_height,x+4,y+4);
}
And I get this as result:
 

FrostyCat

Redemption Seeker
I think you have an issue with blocks being not aligned properly with each other. But in any case, I don't think this is the right way to do it. Shadowing is usually mediated through something else that draws under or over everything, not by things casting shadows.

An easy alternative is to use a separate obj_shadows that does this in its Draw event:
Code:
with (par_couele) {
  if (!(place_meeting(x+1, y, par_couele) && place_meeting(x, y+1, par_couele))) {
    draw_sprite(sprite_index, image_index, x+4, y+4);
  }
}
A more effective scheme would involve painting shadows to a surface and drawing only the surface all the time, then repaint the surface only when there is movement in things that cast a shadow. However, the details of that will depend on your project, so I won't go into that for now.
 
N

NoFontNL

Guest
It worked! Well, thank you very much! No more words needed.
 
Top