const int GameWidth =
cfg.Width*3 > cfg.Height*4 ? cfg.Width*3*320/(cfg.Height*4) : 320;
const int GameHeight =
cfg.Height*4 > cfg.Width*3 ? cfg.Height*4*240/(cfg.Width*3) : 240;
const float WidthScale = (float)cfg.Width / (float)GameWidth;
const float HeightScale = (float)cfg.Height / (float)GameHeight;
const bool CharLocalCoord320 = false;
const float CharGameWidth = CharLocalCoord320 ? 320.0 : (float)GameWidth;
const float CharGameLeft = ((float)GameWidth - CharGameWidth) / 2.0;
const float CharGameRight = CharGameLeft + CharGameWidth;
public &sdl.Rect scrrect;
scrrect.set(0, 0, cfg.Width, cfg.Height);
public &Camera
{
public &Stage
{
public int startx;
public int boundleft, boundright;
public int boundhigh;
public float verticalfollow;
public int tension, floortension;
public int overdrawlow;
public int localw, localh;
public float localscl, drawOffsetY;
public int zoffset;
public float ztopscale;
public void clear()
{
`startx = 0;
`boundleft = 0;
`boundright = 0;
`boundhigh = 0;
`verticalfollow = 0.2;
`tension = 50;
`floortension = 0;
`overdrawlow = 0;
`localw = 320;
`localh = 240;
`localscl = (float).GameWidth / (float)`localw;
`drawOffsetY = 0.0;
`zoffset = 0;
`ztopscale = 1.0;
}
}
public &Stage stg;
public bool zoom = false;
public float zoomMin = 5.0 / 6.0;
public float zoomMax = 15.0 / 14.0;
public float zoomSpeed = 12.0;
/float scale, minScale;
/float xOffset, yOffset;
/float x, y;
/float screenX, screenY;
/float xMin, xMax;
float zoff;
/float screenZoff;
/float boundL, boundR, boundH;
float zoomdelay;
float halfWidth;
public void init()
{
`boundL = (float)(`stg.boundleft - `stg.startx) * `stg.localscl;
`boundR = (float)(`stg.boundright - `stg.startx) * `stg.localscl;
`halfWidth = (float).GameWidth / 2.0;
`xMin = `boundL - `halfWidth / `baseScale();
`xMax = `boundR + `halfWidth / `baseScale();
branch{
cond `stg.verticalfollow > 0.0:
`boundH =
.m.min!float?(
0.0,
(float)`stg.boundhigh * `stg.localscl
+ (float).GameHeight - `stg.drawOffsetY
- (float).GameWidth * (float)`stg.localh / (float)`stg.localw);
else:
`boundH = 0.0;
}
if(`stg.boundhigh > 0) `boundH += (float)`stg.boundhigh * `stg.localscl;
float xminscl = (float).GameWidth/((float).GameWidth - `boundL + `boundR);
float yminscl = (float).GameHeight / (240.0 - .m.min!float?(0.0, `boundH));
`minScale =
.m.max!float?(`zoomMin)<, .m.min!float?(`zoomMax)<,
.m.max!float?(xminscl, yminscl);
`screenZoff =
(float)`stg.zoffset * `stg.localscl - `stg.drawOffsetY + 240.0
- (float).GameWidth * (float)`stg.localh / (float)`stg.localw;
}