Because I have A LOT OF SetViewport / DrawImage Commands in my game source I tought of a possibilty To overwrite those two Blitzfunctions, but I have some problems with the math how To calculate the news coords.
The source should look something like this
I know that other commands (like DrawRect etc...) won't use the viewport, but that doesn't matter for my case...
The source should look something like this
SuperStrict Graphics 640,480,0 'Viewport coords Global vx:Float, vy:Float, vw:Float, vh:Float Local t:TImage = LoadImage ("gfx/mainmenu.png") While(1) Cls SetViewport 200,200,100,100 DrawImage t,20,20 Flip Wend Function SetViewport( x:Float, y:Float, width:Float, height:Float ) vx = x vy = y vw = width vh = height End Function Function DrawImage(image:TImage, x:Float, y:Float, frame:Int=0) 'Calculate new coords, I don't know how to calculate them Local rx:Float = vx - x Local ry:Float = vy - y Local rw:Float = vw Local rh:Float = vh 'Recalculate x/y coord x = ??? y = ??? ccDrawImageArea(image,x,y,rx,ry,rw,rh,frame) End Function
I know that other commands (like DrawRect etc...) won't use the viewport, but that doesn't matter for my case...