I suppose you *could* use all that math, making all sorts of calculations and what not. I find it easier to just let AppGameKit do the heavy lifting for me. Now I don't know what your 2D game looks like, but if it's a tilemap you're rotating, then set the sprite's offset according to where it lies from the middle coords of the screen. Subtracting its position from the center of the screen to find each tile's offset. For instance, a tile at [3,2] at 32px in size would normally be positioned at [96,64] in the world. So set it's offset; [320-96, 240-64] (assuming a 640x480 resolution) Then rotating is a simple matter of rotating every sprite by the same amount with no re-positioning needed. Same principle for scrolling the map, just position every tile by the same offset values. Since technically every sprite is positioned at the same coordinates, the center of the screen, they're just offset from the center.
Quick demo, easier to see than explain. The only somewhat complicated part is where I commented
// update new rows. When scrolling your map, this is where you determine which outer row or column needs updated with new tiles. Unless you don't want to use the viewport method and just display the entire map, then you don't even need to worry about this at all.
setVirtualResolution(640,480)
#CONSTANT VIEW_WIDTH = 24
#CONSTANT VIEW_HEIGHT = 24
base = createSprite(loadImage("PathAndObjects.png"))
setSpriteAnimation(base, 32, 32, 256)
dim viewport[VIEW_WIDTH, VIEW_HEIGHT]
for y = 0 to VIEW_HEIGHT
for x = 0 to VIEW_WIDTH
viewport[x,y] = cloneSprite(base)
tx = x*32 - 80
ty = y*32 - 160
ox = 320 - tx
oy = 240 - ty
setSpriteOffset(viewport[x,y], ox, oy)
setSpritePositionByOffset(viewport[x,y], 320, 240)
setSpriteFrame(viewport[x,y], random(1,256))
next x
next y
setSpriteVisible(base, 0)
repeat
// Up
if getRawKeyState(38) = 1
inc vy
if vy > 32
vy = vy - 32
// update new rows
endif
setViewportPosition(0, vy)
endif
// Down
if getRawKeyState(40) = 1
dec vy
if vy < 32
vy = vy + 32
// update new rows
endif
setViewportPosition(0, vy)
endif
// Left
if getRawKeyState(37) = 1
dec angle
setViewportAngle(angle)
endif
// Right
if getRawKeyState(39) = 1
inc angle
setViewportAngle(angle)
endif
sync()
until getRawKeyPressed(27) = 1
end
function setViewportPosition(vx, vy)
for y = 0 to VIEW_HEIGHT
for x = 0 to VIEW_WIDTH
setSpritePositionByOffset(viewport[x,y], 320+vx, 240+vy)
next x
next y
endfunction
function setViewportAngle(angle)
for y = 0 to VIEW_HEIGHT
for x = 0 to VIEW_WIDTH
setSpriteAngle(viewport[x,y], angle)
next x
next y
endfunction
"I like offending people, because I think people who get offended should be offended." - Linus Torvalds