LimitCameraBounds
LimitCameraBounds CameraIndex, x1, y1, x2, y2
 
Parameters:

    CameraIndex = The index of the camera you wish to limit
    x1 = The Left hand side limit
    y1 = The Top limit
    x2 = The Right hand side limit
    y2 = The Bottom limit
Returns: NONE
 

      LimitCameraBounds defines the bounds of cameras movement when LimitCamera is enabled. When camera limiting is enabled, the camera can not be able to move outside the bounds of the LimitCameraBounds region.




FACTS:


      * By default camera limiting is turned off when a camera is created. It can be activated using the LimitCamera command.




Mini Tutorial:


      This example creates a camera, then limits it's movement to within a region. The main Do/Loop allows the user to move the camera around, while being limited to the predefined region


  
; create camera 1.  Which will attach itself to
; the current surface, which will be the screen
; by default
  CreateCamera 1
  
; LImit the Cameras Movement To -100x,-100y, And 2100x, 2100y
  
  LimitCamera 1,true
  LimitCameraBounds 1,-100,-100,2100,2100
  
; Now redirect All gfx output to the Scene buffer, so the
; camera  has something To view.
  CaptureToScene
  
; draw some random gfx to the screen buffer
  For lp=0 To 50
     x=Rnd(2000)
     y=Rnd(2000)
     Size=Rnd(50)
     
     Select Rnd(1)
         Case 0
           ; draw a circle to the Scene
             CircleC x,y,size,1,RndRGB()
         Case 1
           ; draw a box to the Scene
             BoxC x,y,x+size,y+size,1,RndRGB()
     EndSelect
  Next
  
; Tell PB to retutrn to drawing GFX immediately
  DrawGFXImmediate
  
; Start a Do /loop
  Do
     
   ; Arrows to control camera
     If UpKey() Then MoveCamera 1,0,-5
     If DownKey() Then MoveCamera 1,0,5
     If LeftKey() Then MoveCamera 1,-5,0
     If RightKey() Then MoveCamera 1,5,0
     
   ; Draw the camera and whatever it can see from the
   ; scene buffer
     DrawCamera 1
     
   ; Display message
     SetCursor 0,0
     Print "Arrows to Move this camera"
     Print "Camera Xpos"+Str$(GetCameraX(1))
     Print "Camera Ypos"+Str$(GetCameraY(1))
     
   ; Show the user the screen.
     Sync
   ; Loop back to the DO statement
  Loop
  




This example would output.

  
  no Text Output
  

 
Related Info: LimitCamera | MoveCamera | PositionCamera | PositionCameraX | PositionCameraY :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com