View Single Post
Seren

JCF Member

Joined: Feb 2010

Posts: 872

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Feb 6, 2013, 10:09 PM
Seren is offline
Reply With Quote
Quote:
Originally Posted by Gus View Post
Basic code for subdividing a level into mini-rooms, as in Oddworld games:

if (p.xPos > 0)
if (p.xPos < 640)
if (p.yPos > 0)
if (p.yPos < 480)
p.cameraFreeze(0, 0, false, true);
if (p.xPos > 640)
if (p.xPos < 1280)
if (p.yPos > 0)
if (p.yPos < 480)
p.cameraFreeze(640, 0, false, true);
if (p.xPos > 0)
if (p.xPos < 640)
if (p.yPos > 480)
if (p.yPos < 960)
p.cameraFreeze(0, 480, false, true);
if (p.xPos > 640)
if (p.xPos < 1280)
if (p.yPos > 480)
if (p.yPos < 960)
p.cameraFreeze(640, 480, false, true);

And so on ...
Or, instead of hundreds of lines for barely medium-sized SP levels, you can use this one-liner:
Code:
void onPlayer()
{
  p.cameraFreeze(p.xPos-p.xPos%640,p.yPos-p.yPos%480,false,true);
}
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.