Verge needs...
Displaying 21-27 of 27 total.
prev 1 2
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Omni

...
How about this.

int grabx, graby;

void GrabSet()
{
if (entity.x[player] < 320) grabx = entity.x[player]-160; else grabx = 160;
if (entity.y[player] < 240) graby = entity.y[player]-120; else graby = 120;

if (entity.x[player]<0) grabx = 0;
if (entity.y[player]<0) graby = 0;
}


Then just grab the region (grabx, graby, grabx+320, graby+240).

I _think_ that should work.

Posted on 2005-12-20 19:54:01

resident

I'm sure it SHOULD, but I've obviously gone about it the inelegant way,

void screen_rescale()
{
int scr_img = NewImage(320, 240);
int x = entity.x[plr] - xwin;
int y = entity.y[plr] - ywin;

grabregion(x - 160, y - 120, x + 159, y + 119, 0, 0, screen, scr_img);
ScaleBlit(0, 0, ImageWidth(scr_img) * 2, ImageHeight(scr_img) * 2, scr_img, screen);
FreeImage(scr_img);
}

Posted on 2005-12-20 22:18:07 (last edited on 2005-12-20 22:25:00)

Omni

Incorporate your "-160" and "-120" into the X and Y assignments.

Perhaps this will work..

int x = entity.x[plr] - xwin - 160;
int y = entity.y[plr] - ywin - 120;

if (x < 0) x = 0;
if (y < 0) y = 0;

GrabRegion(x, y, x+319, y+239, 0, 0, screen, scr_img);

Posted on 2005-12-20 22:59:50

resident

Yeah, that fixes it. All I need now is to add similar bounds checks for the right and bottom of the map. Thanks Omni.

Posted on 2005-12-21 02:03:35

Overkill

Quote:
Originally posted by resident

I'm sure it SHOULD, but I've obviously gone about it the inelegant way,

void screen_rescale()
{
int scr_img = NewImage(320, 240);
int x = entity.x[plr] - xwin;
int y = entity.y[plr] - ywin;

grabregion(x - 160, y - 120, x + 159, y + 119, 0, 0, screen, scr_img);
ScaleBlit(0, 0, ImageWidth(scr_img) * 2, ImageHeight(scr_img) * 2, scr_img, screen);
FreeImage(scr_img);
}



If all you're doing is grabbing the middle of the screen, why not go:

void screen_rescale()
{
int scr_img = NewImage(320, 240);
// This is ALWAYS the center of the screen.
GrabRegion(ImageWidth(screen) - ImageWidth (scr_img) / 2,
ImageHeight(screen) - ImageHeight(scr_img) / 2,
ImageWidth(screen) + ImageWidth (scr_img) / 2,
ImageHeight(screen) + ImageHeight(scr_img) / 2,
0, 0, screen, scr_img);
ScaleBlit(0, 0, ImageWidth(scr_img) * 2, ImageHeight(scr_img) * 2, scr_img, screen);
FreeImage(scr_img);
}


Or do you want the scaling to ALWAYS be centered on the player, even when at the edge of the screen?

void screen_rescale()
{
int scr_img = NewImage(320, 240);
int x = entity.x[plr] - xwin;
int y = entity.y[plr] - ywin;

// Keep in bounds.
if (x < 0) x = 0;
if (x >= ImageWidth(screen)) x = ImageWidth(screen) - 1;
if (y < 0) y = 0;
if (y >= ImageHeight(screen)) y = ImageHeight(screen) - 1;

GrabRegion(x - ImageWidth (scr_img) / 2,
y - ImageHeight(scr_img) / 2,
x + ImageWidth (scr_img) / 2,
y + ImageHeight(scr_img) / 2,
0, 0, screen, scr_img);
ScaleBlit(0, 0, ImageWidth(scr_img) * 2, ImageHeight(scr_img) * 2, scr_img, screen);
FreeImage(scr_img);
}

Posted on 2005-12-21 07:06:07 (last edited on 2005-12-21 07:06:53)

resident

The latter. The intent is to basically make it act as closely as possible to V3's default 320x240 mode, only in 640x480. (I'm thinking a text heavy game, so the extra resolution would be good for readability's sake)

The problem with the first routine is, of course, that it's possible for the player entity to wander off of the screen. The problem with the second is that it doesn't seem to center properly on the player entity.

This MAY be in part due to my non-standard CHR file, which is 32x64 with a 16x16 hotspot centered at the base of the character, I'm not sure.

To be honest, it works "well enough" for me, but every version of the routine I've tried (including several variants of my own) doesn't work quite right, for reasons I don't quite understand, and it's bugging the hell out of me ;)

Posted on 2005-12-21 08:13:13 (last edited on 2005-12-21 08:25:10)

Omni

Overkill's second version also allows, if X = 0, for the Grabregion to grab X - ImageHeight(screen)/2, which would be in a negative range.

Incorporate that into the assignment _before_ the nonzero conditional. Can you maybe post a small zip of a test that we could look at? There should be an easy way to do this.

Posted on 2005-12-21 09:17:46


Displaying 21-27 of 27 total.
prev 1 2
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.