This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:guides:beginners:viewport_and_camera [2018/06/27 12:21 (8 years ago)] – sausage | en:guides:beginners:viewport_and_camera [2025/09/30 17:26 (8 weeks ago)] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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 '' | + | Take a look at your MyGame.ini and you'll see that a '' |
| < | < | ||
| - | [Viewport] | + | [MainViewport] |
| Camera | Camera | ||
| </ | </ | ||
| Line 14: | Line 14: | ||
| Let's give our game a blue sky as a background, by adding the '' | Let's give our game a blue sky as a background, by adding the '' | ||
| - | < | + | < |
| - | [Viewport] | + | [MainViewport] |
| Camera | Camera | ||
| BackgroundColor | BackgroundColor | ||
| 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 :) ): | ||
| - | < | + | < |
| [MainCamera] | [MainCamera] | ||
| FrustumWidth | FrustumWidth | ||
| Line 44: | Line 44: | ||
| </ | </ | ||
| - | 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 '' | + | 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 '' |
| <code ini> | <code ini> | ||
| Line 53: | Line 53: | ||
| </ | </ | ||
| - | The viewport needs to be created when our game runs, so let's take a look at the MyGame.cpp code: | + | The viewport needs to be created when our game runs, so let's take a look at the MyGame.c code (for a C++ project, look for '' |
| - | <code=cpp> | + | <code=c> |
| orxSTATUS orxFASTCALL Init() | orxSTATUS orxFASTCALL Init() | ||
| { | { | ||
| - | | + | ... |
| + | orxConfig_PushSection(" | ||
| + | |||
| + | for(orxS32 i = 0, iCount = orxConfig_GetListCount(" | ||
| + | { | ||
| + | | ||
| + | } | ||
| </ | </ | ||
| - | Nice and simple. Our project already has this added. The Init() function runs once when your game first executes, and this is where the viewport is created. | + | Here the ''" |
| + | <code ini> | ||
| + | [Main] | ||
| + | ViewportList | ||
| + | </ | ||
| + | You could also called '' | ||
| + | < | ||
| + | orxSTATUS orxFASTCALL Init() | ||
| + | { | ||
| - | The "Viewport" | + | ... |
| + | |||
| + | orxViewport_CreateFromConfig("MainViewport"); | ||
| - | Because the camera was specified in the '' | + | </code> |
| - | Final thing for this step is to name our game. This name will show in the window title. Set this with the '' | + | The Init() function runs once when your game first executes, and this is where the viewport is created. |
| - | < | + | The " |
| + | |||
| + | Because the camera was specified in the '' | ||
| + | |||
| + | Final thing for this step is to name our game. This name will show in the window title. Set this with the '' | ||
| + | |||
| + | < | ||
| [Display] | [Display] | ||
| ScreenWidth | ScreenWidth | ||
| Line 77: | Line 100: | ||
| Title = Platform Hero | Title = Platform Hero | ||
| FullScreen | FullScreen | ||
| + | Decoration | ||
| Smoothing | Smoothing | ||
| VSync = true | VSync = true | ||
| Line 86: | Line 110: | ||
| [Display] | [Display] | ||
| Title = Platform Hero (Debug) | Title = Platform Hero (Debug) | ||
| - | ShowFPS | ||
| </ | </ | ||