forums

TNT Basic Forums > Programming Q&A
Viewport Offset
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-01-2003 09:15

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Sorry about this, there's probably a really stupid mistake behind this, but oh well...

This line:

Set Viewport Offset 1,Max(Min(camerax,(Map Width*Map Tile Width)-Viewport Width(1)),0),Max(Min(cameray,(Map Height*Map Tile Height)-Viewport Height(1)),0)

Should, in theory, make sure that the viewport doesn't scroll offscreen. The position is based on CameraX and CameraY, then chooses the smallest value out of the camera position and the map length subtract the viewport length, then, from that, picks the highest number from the result and 0. Shouldn't that ensure that the viewport never gets out of the map bounds?

However, the viewport still manages to consistantly go out of the map bounds, causing an error...

12-01-2003 12:01

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

Try using the new Wrap command to force the viewport to stay in bounds, which will stop the errors, and then you can correct your formula by looking for certain patterns. It looks incomprehensible to me :-)

12-01-2003 22:34

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Set Viewport Offset 1,Max(Min(camerax,(Map Width*Map Tile Width)-Viewport Width(1)),0),Max(Min(cameray,(Map Height*Map Tile Height)-Viewport Height(1)),0)

Ok, well basically, it gets the desired x position (camerax), then

Min ( camerax , maximum value )

- So that should make sure that it's never above maximum value, then,

Max ( Min ( camerax , maximum value ) , minimum value )

- And that should make sure that the resulting value is never below the minimum value. The maximum value for the command is "(Map Width*Map Tile Width)-Viewport Width(1) and the minimum is 0. (Repeat for Y)

12-02-2003 22:31

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

Break the line down. Does it work if you ditch the max/min stuff and use if/then/else instead?

12-03-2003 07:26

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Fixed it...

It was actually a problem with the fact that my map was smaller than the viewport... ^_^;;

Thanks anyway...

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.