For Baxslash - who first hinted at the possibility of this.
Basically you draw the screen as normal, then zoom out so that your entire world fits into a small portion of the screen and then you redraw that portion.
To do this demo, I had to put a load of stuff in which is nothing to do with the mechanics, but needed to show the effect.
Comments will show you the way.
No media required.
//
// Setup Code - most of this would be handled by your app and is not part of the demo
//
// Get Device Physical Resolution
devWidth = getDeviceWidth()
devHeight = getDeviceHeight()
// Convert to Minimum and Maximum
if devWidth > devHeight
devMin# = devHeight
devMax# = devWidth
else
devMin# = devWidth
devMax# = devHeight
endif
devAspect# = devMax# / devMin#
// Set Landscape Flag to an invalid value
devIsLandScape = -1
setOrientationAllowed( 1 , 1 , 1 , 1 )
// Set Size of World
worldSize = 1024
worldHalf = worldSize / 2.0
// Create Large Sprite for World Background
worldSprite = createSprite(0)
setSpriteSize( worldSprite , worldSize , worldSize )
setSpritePosition( worldSprite , 0 , 0 )
setSpriteDepth( worldSprite , 250 )
setSpriteColor( worldSprite , 0 , 255 , 0 , 255 )
fixSpriteToScreen( worldSprite , 0 )
// Create a load of random sprites within world
for i=1 to 100
nul = createSprite(0)
setSpriteSize( nul , random( 10 , 500 ) , random( 10 , 50 ))
setSpriteOffset( nul , getSpriteWidth( nul ) / 2.0 , getSpriteHeight( nul ) / 2.0 )
setSpritePositionByOffset( nul, random( 50 , worldSize - 50 ) , random( 50 , worldSize - 50 ))
setSpriteDepth( nul , 100 + i )
setSpriteColor( nul , random( 0 , 255 ) , random( 0 , 255 ) , random( 0 , 255 ) , 255 )
fixSpriteToScreen( nul , 0 )
next i
// Create a Sprite for Player
PlayerSprite = createSprite( 0 )
setSpriteSize( PlayerSprite , 100 , 100 )
setSpriteOffset( PlayerSprite , 50 , 50 )
setSpriteDepth( PlayerSprite , 50 )
fixSpriteToScreen( PlayerSprite , 0 )
loopCount = 0
// Set Size of minimap to be a quarter of display short edge
mapSize# = devMin# / 4.0
// Create a Sprite to show where the map goes - but put it behind everything
mapSprite = createSprite(0)
fixSpritetoScreen( mapSprite , 1 )
setSpriteSize( mapSprite , mapSize# , mapSize# )
setSpriteDepth( mapSprite , 1000 )
setSpriteColor( mapSprite , 255 , 0 , 0 , 255 )
do
// Check for back key (esc)
if getRawKeyState ( 27 ) > 0 then exit
// Check if Device is Landscape
newIsLandScape = (getOrientation() - 1) / 2
if newIsLandScape <> devIsLandScape
// this has changed
devIsLandScape = newIsLandScape
// Set Virtual Resolution to Match Orientation
if devIsLandScape
setVirtualResolution( devMax# , devMin# )
// Set Map Coordinates
MapX0# = 0
MapX1# = MapX0# + mapSize#
MapY0# = ( devMin# - mapSize# ) / 2.0
MapY1# = MapY0# + mapSize#
else
setVirtualResolution( devMin# , devMax# )
// Set Map Coordinates
MapY0# = 0
MapY1# = MapX0# + mapSize#
MapX0# = ( devMin# - mapSize# ) / 2.0
MapX1# = MapX0# + mapSize#
endif
setPrintSize( devMin# / 20 )
// Position Map Sprite
setSpritePosition( mapSprite , MapX0# , MapY0# )
endif
// Print Orientation
if devIsLandScape
print("Landscape")
else
print("Portrait")
endif
// Use loop counter to move player in circle over world
inc loopCount , 1
thisX# = cos( loopCount ) * worldHalf + worldHalf
thisY# = sin( loopCount ) * worldHalf + worldHalf
setSpritePositionByOffset( PlayerSprite , thisX# , thisY# )
// Follow Player with Scroll
setViewOffset( thisX# - getVirtualWidth() / 2.0 , thisY# - getVirtualHeight() / 2.0 )
setViewZoom( 1.0 )
// Set Map Sprite to flicker
setSpriteColor( mapSprite , random( 128 , 255) , random( 128 , 255) , random( 128 , 255) , 255 )
//
// Everything so far has been to set up something to look at and is not really part of the demo
// HERE STARTS THE DEMO CODE
//
// It uses MapX0#, MapY0, MapX1# and MapY1# as screen coordinates of the minimap
// and mapSize# as both the width and height of it
//
// Store current offsets and zoom to restore later
oldOffsetX# = getViewOffsetX()
oldOffsetY# = getViewOffsetY()
oldZoom# = getViewZoom()
// Set Scissor to the Full Display
setScissor( 0 , 0 , getVirtualWidth(), getVirtualHeight() )
// let AGK update it's stuff
Update( 0 )
// Render the Full Display
Render()
// Zoom Waaay out so that entire World area fits into the map size
thisZoom# = mapSize# / worldSize
setViewZoom( thisZoom# )
// Move the offset to position this tiny world into the map area
setViewOffset( -MapX0# / thisZoom# , -MapY0# / thisZoom# )
// Limit the render area to the portion of the display used by the map
setScissor( MapX0# , MapY0# , MapX1# , MapY1# )
// And Redraw again
Render()
// Swap the backbuffer
swap()
// Restore the old zoom and offsets
// (not really needed for this demo as they are set each frame anyway)
setViewOffset( oldOffsetX# , oldOffsetY# )
setViewZoom( oldZoom# )
loop
end