User Tools

Site Tools


en:guides:beginners:viewport_and_camera

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:guides:beginners:viewport_and_camera [2018/06/27 08:21 (7 years ago)] – external edit 127.0.0.1en:guides:beginners:viewport_and_camera [2024/11/17 02:31 (5 months ago)] (current) – Fixes and alignment to newer orx. sausage
Line 5: Line 5:
 A viewport is the rectangle that we can view the game world through. And a camera allows us to see all or part of that world at a time. A viewport is the rectangle that we can view the game world through. And a camera allows us to see all or part of that world at a time.
  
-Take a look at your MyGame.ini and you'll see that a ''[Viewport]'' section has already been specified for you.+Take a look at your MyGame.ini and you'll see that a ''[MainViewport]'' section has already been specified for you.
  
 <code=ini> <code=ini>
-[Viewport]+[MainViewport]
 Camera             = MainCamera Camera             = MainCamera
 </code> </code>
Line 14: Line 14:
 Let's give our game a blue sky as a background, by adding the ''BackgroundColor'' property to the config: Let's give our game a blue sky as a background, by adding the ''BackgroundColor'' property to the config:
  
-<code=ini> +<code=ini [highlight_lines_extra="3"]
-[Viewport]+[MainViewport]
 Camera            = MainCamera Camera            = MainCamera
 BackgroundColor   = (0, 180, 255) BackgroundColor   = (0, 180, 255)
Line 35: Line 35:
 Let's change the screen width and height so that it makes working through the tutorial easier (and easier to take screenshots :) ): Let's change the screen width and height so that it makes working through the tutorial easier (and easier to take screenshots :) ):
  
-<code=ini>+<code=ini [highlight_lines_extra="2,3"]>
 [MainCamera] [MainCamera]
 FrustumWidth    = 800 FrustumWidth    = 800
Line 44: Line 44:
 </code> </code>
  
-A frustum width and height does not have to be the same size as your screen, but for our game, we want it to be. So the ''ScreenWidth'' and ''ScreenHeight'' values from the ''[Display]'' section are being inherited from the ''FrustumWidth'' and ''FrustumHeight'' values, as you can see at:+A frustum width and height does not have to be the same size as your screen, but for our game, we want it to be. So the ''ScreenWidth'' and ''ScreenHeight'' values can be added to the ''[Display]'' section and are being inherited from the ''FrustumWidth'' and ''FrustumHeight'' values:
  
 <code ini> <code ini>
Line 59: Line 59:
 { {
  
-    orxViewport_CreateFromConfig("Viewport");+    orxViewport_CreateFromConfig("MainViewport");
 </code> </code>
  
Line 65: Line 65:
  
  
-The "Viewport" string parameter specified in that function is the same name as the ''[Viewport]'' section in the config.+The "MainViewport" string parameter specified in that function is the same name as the ''[MainViewport]'' section in the config.
  
-Because the camera was specified in the ''[Viewport]'' section, we do not need to create a camera in code.+Because the camera was specified in the ''[MainViewport]'' section, we do not need to create a camera in code.
  
-Final thing for this step is to name our game. This name will show in the window title. Set this with the ''Title'' property in the ''[Display]'' section. Also while you are here, set the ''Smoothing'' to false:+Final thing for this step is to name our game. This name will show in the window title. Set this with the ''Title'' property in the ''[Display]'' section. Also while you are here, set the ''Smoothing'' to false, and Decoration to true which means to make a standard window:
  
-<code=ini>+<code=ini [highlight_lines_extra="4,6,7"]>
 [Display] [Display]
 ScreenWidth     = @MainCamera.FrustumWidth ScreenWidth     = @MainCamera.FrustumWidth
Line 77: Line 77:
 Title           = Platform Hero Title           = Platform Hero
 FullScreen      = false FullScreen      = false
 +Decoration      = true
 Smoothing       = false Smoothing       = false
 VSync           = true VSync           = true
Line 86: Line 87:
 [Display] [Display]
 Title           = Platform Hero (Debug) Title           = Platform Hero (Debug)
-ShowFPS         = true 
 </code> </code>
  
en/guides/beginners/viewport_and_camera.1530112900.txt.gz · Last modified: 2018/06/27 08:21 (7 years ago) by 127.0.0.1