How do I pan (change ORIGIN) by dragging mouse...

Blitz3D Forums/Blitz3D Beginners Area/How do I pan (change ORIGIN) by dragging mouse...

hollifd(Posted 2016) [#1]
I want to implement panning by clicking the left mouse button and drag the contents on the screen in the direction that I drag the mouse. Currently, I am using the ORIGIN command to use keyboard keys to pan up,dn,left,right. Can someone show me how to drag the mouse and change the ORIGIN command to simulate panning?

Can someone show me using the short code below?

Graphics 800,600,16 
; Offset drawing options with origin command -200 in each direction 
Origin 200,-200 

; Wait for ESC to hit 
While Not KeyHit(1) 

; Draw an oval - SHOULD be at the exact center, but it isn't! 
Oval 400,300,50,50,1 

Wend



Rick Nasher(Posted 2016) [#2]
You'll see that it will display midscreen when omitting the Origin command.
Origin sets a new location from where to start drawing/calculating. So in this case 200+400=600 for x and 200+300=500 for y. That of course isn't the center of screen.

Don't know if this what you are after, but you could set up a larger screen area as a playfield and then move the smaller Viewport using MouseX and MouseY input and freezing the pointer to the center of screen using something like MoveMouse screenmidx,screenmidy.

Checkout the help on commands Viewport, MouseX, MouseY, MoveMouse.

BTW: there are a lot of cam control examples in the codearchives that will keep you from re-inventing the wheel. ;-)


RGR(Posted 2016) [#3]
And use Copy and Paste ;-)

The above example is the Origin Example of Blitz3D with one mistake:
You missed the - in front of the first 200
Origin -200,-200


The origin of the Oval is the left upper corner of a bounding box - to draw it centered you have to substract half of the diameter.

Graphics 800,600,32,2
MyOval 400,300,780,580,1
WaitKey()
End

Function MyOval(x#, y#, w#, h#, s)
Oval(x-w/2.0, y-h/2.0, w, h, s)
End Function