So my question is how do I make this script work correctly for sprites larger than 16 pixels? UPDATE EDIT FOR ELABORATION: The script works just fine for sprites that are 16px wide. However, when a sprite is 32px wide, the script works only when the leftmost 16px are clipped, but not when the leftmost 8px or leftmost 24px are cut. I haven't tested with a 24px sprite yet. So in other words, it only works when half the sprite is clipped.
Sorry if the solution is too simple for Advanced Users forum, but I need someone that actually knows how to use draw_sprite_part_ext() to look over this.
By the way, "head" is jut a variable that stores a sprite_index, since for some twisted reason I felt like torturing myself by limiting base sprites to a height of 16px and anything taller than that would be drawn by code. ... Don't ask; it made sense to me back when I first started doing it.
//Emulate's NES limitations by clipping sprites (8x8) from metasprites on the left screen edge
if clip_sprites
{
//var _lbox,_left,_wide,_xspr;
_lbox=sprite_get_bbox(bbox_left);
if _lbox<view_xview
{
//Calculate partial sprite pixels outside leftmost view
_left=min(ceil((view_xview-_lbox)/8)*8,abs(sprite_width));
//Calculate remaining visible pixels for full sprite
_wide=sprite_width-_left*image_xscale;
//Calculate the x-coordinate for the partial sprite
_xspr=_lbox+_left;
draw_sprite_part_ext(sprite_index,-1,_left,0,_wide,sprite_height,_xspr,y-sprite_yoffset,image_xscale,image_yscale,c_white,1)
if object_index=obj_BonePillar
draw_sprite_part_ext(head,-1,_left,0,(sprite_get_width(head)*image_xscale-_left*image_xscale)*-1,sprite_get_height(head),_xspr,y-sprite_yoffset-sprite_get_height(head),image_xscale*-1,image_yscale,c_white,1);
}
else
//Hide the sprite if no partials are fully visible on the right
if _lbox+8>view_xview+view_wview
{
draw_sprite_ext(sprite_index,-1,x,y,0,0,0,0,0);
}
else
{
//Draw sprite as normal
draw_sprite_ext(sprite_index,-1,x,y,image_xscale,image_yscale,0,c_white,1);
if object_index=obj_BonePillar
draw_sprite_ext(head,-1,x,y-sprite_get_height(head),image_xscale*-1,image_yscale,0,c_white,1);
}
if head
{
_lbox = x+(sprite_get_bbox_left(head)-sprite_get_xoffset(head));
if _lbox<view_xview
{
//Calculate partial sprite pixels outside leftmost view
_left=min(ceil((view_xview-_lbox)/8)*8,abs(sprite_width));
//Calculate remaining visible pixels for full sprite
_wide=sprite_get_width(head)*image_xscale-_left*image_xscale;
//Calculate the x-coordinate for the partial sprite
_xspr=_lbox+_left;
draw_sprite_part_ext(head,-1,_left,0,_wide,sprite_get_height(head),_xspr,y-sprite_yoffset-sprite_get_yoffset(head),image_xscale,image_yscale,c_white,1)
}
else
if _lbox+8>view_xview+view_wview
{
draw_sprite_ext(sprite_index,-1,x,y,0,0,0,0,0);
}
else
{
//Draw sprite as normal
draw_sprite_ext(head,-1,x,y-sprite_yoffset,image_xscale,image_yscale,0,c_white,1);
}
}
}
else
{
//Draw sprites as normal
draw_sprite_ext(sprite_index,-1,x,y,image_xscale,image_yscale,0,c_white,1);
if head
if head=spr_BonePillar
draw_sprite_ext(head,-1,x,y-sprite_get_height(head),image_xscale*-1,image_yscale,0,c_white,1);
else
draw_sprite_ext(head,-1,x,y-sprite_yoffset,image_xscale,image_yscale,0,c_white,1);
}
Yes I know the draw_sprite_ext(sprite_index,-1,0,0,0,0,0) can be left out, but right now it's functioning as a placeholder. ... >_< And I know the sprites weren't deleted exactly in this way (it was hardcoded into the games themselves), but let's just consider this a learning experience for me. I'd appreciate any help on this matter. Thank you.
Edited by TheouAegis, 10 April 2012 - 05:42 PM.











