This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:tutorials:orxscroll:binding-orxscroll [2024/05/05 01:16 (19 months ago)] – Update to latest orx and Scroll revisions hcarty | en:tutorials:orxscroll:binding-orxscroll [2025/11/30 14:33 (27 hours ago)] (current) – Update ini template to match latest orx, Scroll, and the linked repository hcarty | ||
|---|---|---|---|
| Line 42: | Line 42: | ||
| < | < | ||
| <code ini> | <code ini> | ||
| - | ; binding-of-objects | + | ; BindingOfObjects |
| [Display] | [Display] | ||
| ; FullScreen = false + Decoration = false + no dimension -> Borderless FullScreen | ; FullScreen = false + Decoration = false + no dimension -> Borderless FullScreen | ||
| Title = The Binding of Objects | Title = The Binding of Objects | ||
| + | IconList | ||
| FullScreen | FullScreen | ||
| Decoration | Decoration | ||
| Line 57: | Line 58: | ||
| [Resource] | [Resource] | ||
| - | Texture | + | Texture |
| - | Sound = bundle: # bundle:binding-of-objects.obr # ../ | + | Font = bundle: # bundle: |
| + | Sound = bundle: # bundle:BindingOfObjects.obr # ../ | ||
| + | |||
| + | [Bundle] | ||
| + | ExcludeList | ||
| + | |||
| + | [Clock] | ||
| + | AllowSleep | ||
| + | |||
| + | [Config] | ||
| + | DefaultParent | ||
| + | |||
| + | [Default] | ||
| + | KeepInCache | ||
| + | Pivot = center | ||
| [Input] | [Input] | ||
| Line 66: | Line 81: | ||
| KEY_UP | KEY_UP | ||
| KEY_DOWN | KEY_DOWN | ||
| + | |||
| + | [Main] | ||
| + | ViewportList | ||
| [MainViewport] | [MainViewport] | ||
| Line 72: | Line 90: | ||
| [MainCamera] | [MainCamera] | ||
| - | FrustumWidth | + | FrustumWidth |
| - | FrustumHeight | + | FrustumHeight |
| - | FrustumFar | + | FrustumFar |
| FrustumNear | FrustumNear | ||
| - | Position | + | Position |
| + | ; Using a unique proxy object, sharing the same name | ||
| + | OnCreate | ||
| [Scene] | [Scene] | ||
| Line 204: | Line 224: | ||
| { | { | ||
| // Set initial movement direction | // Set initial movement direction | ||
| - | m_direction = Direction::SOUTH; | + | m_direction = SOUTH; |
| // Get movement speed from config value | // Get movement speed from config value | ||
| m_movementSpeed = orxConfig_GetFloat(" | m_movementSpeed = orxConfig_GetFloat(" | ||
| Line 261: | Line 281: | ||
| m_timeSinceDirectionChange = 0; | m_timeSinceDirectionChange = 0; | ||
| // Pick random number between bounds of Direction enum | // Pick random number between bounds of Direction enum | ||
| - | orxU32 randomNum = orxMath_GetRandomU32(0, | + | orxU32 randomNum = orxMath_GetRandomU32(0, |
| // Update object' | // Update object' | ||
| m_direction = static_cast< | m_direction = static_cast< | ||
| Line 297: | Line 317: | ||
| </ | </ | ||
| - | Add the following lines to '' | + | Add the following lines to '' |
| <code c> | <code c> | ||
| Line 355: | Line 375: | ||
| void Hero:: | void Hero:: | ||
| { | { | ||
| - | // Always | + | // Use movement input to initialize |
| - | orxVECTOR speed = orxVECTOR_0; | + | orxVECTOR speed = { |
| + | // Vector' | ||
| + | // be 0.0 if the inputs are either inactive or both equally active. | ||
| + | orxInput_GetValue(" | ||
| + | // Vector' | ||
| + | // be 0.0 if the inputs are either inactive or both equally active. | ||
| + | orxInput_GetValue(" | ||
| + | 0.0}; | ||
| - | if (orxInput_IsActive(" | + | |
| + | | ||
| { | { | ||
| - | | + | |
| - | } | + | |
| - | else if (orxInput_IsActive(" | + | |
| - | { | + | |
| - | | + | |
| - | } | + | |
| - | else if (orxInput_IsActive(" | + | |
| - | { | + | |
| - | | + | |
| - | } | + | |
| - | else if (orxInput_IsActive(" | + | |
| - | { | + | |
| - | speed.fY = m_movementSpeed; | + | |
| } | } | ||
| + | |||
| + | // Scale the raw input vector by the our movement speed | ||
| + | orxVector_Mulf(& | ||
| + | |||
| + | // Update our speed | ||
| SetSpeed(speed, | SetSpeed(speed, | ||
| } | } | ||
| Line 386: | Line 407: | ||
| The code should be almost self-explanatory. The hero's movement speed will be pulled from its config value. The update function (called every frame) sets the speed of the character based on what keyboard arrow is pressed. The '' | The code should be almost self-explanatory. The hero's movement speed will be pulled from its config value. The update function (called every frame) sets the speed of the character based on what keyboard arrow is pressed. The '' | ||
| - | You have to modify the '' | + | You have to modify the '' |
| Try to do those things yourself. If you need help, though, here are the lines to add: | Try to do those things yourself. If you need help, though, here are the lines to add: | ||