CW's solution seems good and not too CPU-consuming as far as AGS goes.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: ThreeOhFour on Mon 04/08/2014 08:02:07
Nice! I'm curious to see how you implemented this
//not the actual code in the module
DynamicSprite* s sprite= DynamicSprite.CreateFromExistingSprite(something.Graphic);
int width=s.Width;
int height=s.Height;
width = Game.SpriteWidth[something.Graphic];
height = Game.SpriteHeight[something.Graphic];
// Crops a sprite, but also works if the requested area is larger
// or OUTSIDE of the original sprite. The areas outside of the sprite will just be blank.
// (the original AGS "Crop" function leaves dirty pixels in the unhandled areas)
//
// IMPORTANT: This function only fixes the "x" coordinates, not the y coordinates.
// That means it works like the standard AGS "Crop" function regarding "y".
void CleanCrop(this DynamicSprite* , int x, int y , int w, int h)
{
if (x>=this.Width || x+w<0) { //if the requested area is fully outside of s
//we force-clear s to avoid dirty pixels from the RAM
DrawingSurface* ds = this.GetDrawingSurface();
ds.Clear();
ds.Release();
} else if (x+w>=this.Width || x < 0) { //if the requested area is partially outside of s2
//trick : we crop s THEN enlarge it to avoid dirty pixels from the RAM
if (x < 0) {
this.Crop(0, 0, w-x, this.Height);
this.ChangeCanvasSize(w, this.Height, -x, 0);
} else { //x+w>=s.Width
this.Crop(x, 0, this.Width - x, this.Height);
this.ChangeCanvasSize(w, this.Height, 0, 0);
}
} else { //the requested area is fully inside s2
this.Crop(x, 0, w, this.Height);
}
}
void Crop(DynamicSprite* s, int x, int y)
{
s.Crop(x,y,10,10);
//for testing I draw the cropped sprite onto the background at arbitrary location (160,100)
DrawingSurface* ds = Room.GetDrawingSurfaceForBackground();
ds.DrawImage(160, 100, s.Graphic, 0, s.Width, s.Height);
ds.Release();
s.Delete();
}
String s = "Line #1";
s = s.Append( "Line #2");
s = s.Append( "Line #3");
s = s.Append( "Line #4");
s = s.Append( "Line #5");
Quote from: Crimson Wizard on Tue 01/07/2014 19:37:32I believe you could do that witht he PEEK and POKE instructions, that were never explained in beginners and intermediate books, or terribly explained, as if the authors wanted to hide the concept of pointers.
Maybe Basic could do that? I couldn't find out how, and I have no idea even today.
Quote from: Gurok on Tue 01/07/2014 13:55:03
I think BASIC's going to feature pretty prominently in the answers here.
Quote from: Miez on Mon 30/06/2014 20:15:27
The shadows from the central hallway on the floor seem to be too divergent. .
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.101 seconds with 16 queries.