User Tools

Site Tools


en:tutorials:orxscroll:introduction-orxscroll

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:tutorials:orxscroll:introduction-orxscroll [2020/08/31 11:10 (5 years ago)] – ↷ Links adapted because of a move operation iarwainen:tutorials:orxscroll:introduction-orxscroll [2024/05/04 18:46 (11 months ago)] (current) – Update to be closer to the latest version of Scroll and its integration with orx hcarty
Line 2: Line 2:
 ===== What is Scroll? ===== ===== What is Scroll? =====
  
-Scroll is a small set of C++ files that allow you to use the object-oriented features of C++ when using Orx.+Scroll is a C++ convenience layer built on top of orx.
  
 ===== Features ===== ===== Features =====
  
-  * Scroll supports “object binding” to custom classes. This means when a Scroll Object is created, it can automatically be set to use a C++ of choice for its implementation. This makes it easy to implement behavior that is specific to certain object types. +  * Scroll supports “object binding” to custom classes. This means when an orx object is created, it can automatically be set to use a C++ class choice for its implementation. This makes it easy to implement behavior that is specific to certain object types. 
-  * Additionally, binding object types to classes makes it easy to handle events on an object-specific basis. For example, each type of game object can have its own OnCreate function which is called whenever an object of that type is created+  * Additionally, binding object types to classes makes it easy to handle events on an object-specific basis. For example, each type of game object can have its own ''OnCreate'' function which is called whenever an object of that type is created.
-  * Scroll supports saving and loading of .map files for easier Scene management. Scroll includes an embedded [[en:tutorials:orxscroll:maps-in-scrolled|Map Editor called ScrollEd]].+
  
-===== Before You Begin ===== +{{page>snippets:init_new_orx_scroll_project&nofooter&noeditbutton}}
- +
-This tutorial assumes proficiency with Orx. In particular, you should be comfortable [[en:tutorials:orxscroll:creating_your_own_scroll_project_using_init|creating a new Orx project]] as a standalone application.+
  
 You should also be familiar with the concepts of inheritance and polymorphism and how to use them in C++. You should also be familiar with the concepts of inheritance and polymorphism and how to use them in C++.
Line 18: Line 15:
 ===== Trouble? ===== ===== Trouble? =====
  
-If you encounter trouble at runtime, check the console log output or debug assertions for error messages. Make sure your Orx config .ini file is loading at runtime and is complete. At a minimum, the config file must define the Display, MainViewport, and MainCamera sections.+If you encounter trouble at runtime, check the console log output or debug assertions for error messages. Make sure your Orx config .ini file is loading at runtime and is complete. At a minimum, the config file must define the ''Display''''MainViewport'', and ''MainCamera'' sections.
  
-If you have any trouble following this tutorial, just ask in the “Help Request” section of the Orx forums. http://orx-project.org/forum+If you have trouble following this tutorial, please reach out in the [[https://discord.com/channels/522167736823185418/717481561783664681|#support channel]] on Discord.
  
 ===== Getting the Sources ===== ===== Getting the Sources =====
  
-Getting started with Scroll is easy. Scroll is maintained in a [[https://github.com/orx/scroll|GitHub repository]]. +Getting started with Scroll is easy. Scroll is included with orx and included by default when initializing a new project.
- +
-You can clone the latest version of Scroll with this command: +
- +
-<code>git clone https://github.com/orx/scroll</code> +
- +
-Otherwise, you can download the source code directly from GitHub here: https://github.com/orx/scroll/archive/master.zip+
  
 ===== Creating the Project ===== ===== Creating the Project =====
  
-You can find instructions for this here: [[en:tutorials:orxscroll:creating_your_own_scroll_project_using_init|creating a new Orx project]]+You can find instructions for creating a new project here: [[en:tutorials:orxscroll:creating_your_own_scroll_project_using_init|creating a new Orx project]].
- +
-Then, extract the Scroll files to their own directory. Add that directory to the include path of the Orx project.+
  
 ===== About the Scroll class ===== ===== About the Scroll class =====
  
-The Scroll class is the main class in a Scroll project. It is contained in Scroll.h/Scroll.inl. This class is where the game is initialized and the “main loop” runs. You don’t use the Scroll class directly, though. Instead, you create your own class deriving from it+The Scroll class is the main class in a Scroll project. It is contained in ''Scroll.h''/''Scroll.inl''. This class is where the game is initialized and the “main loop” runs. You don’t use the Scroll class directly, though. Instead, ''init'' creates a class deriving from it in new projects.
- +
-===== Deriving from the Scroll class ===== +
- +
-To derive from the Scroll class, first create the interface for the derived class. Add a new header file to the project called OrxScroll.h. Add the following code to it: +
- +
-<code c> +
-#ifndef __ORXSCROLL_H_ +
-#define __ORXSCROLL_H_ +
- +
-//! Includes +
-// The following define skips compilation of ScrollEd (map editor) for now +
-#define __NO_SCROLLED__ +
-#include "Scroll.h" +
- +
-//! OrxScroll class +
-class OrxScroll : public Scroll<OrxScroll> +
-+
-public: +
- +
-private: +
-    //! Initialize the program +
-    virtual orxSTATUS Init (); +
-    //! Callback called every frame +
-    virtual orxSTATUS Run (); +
-    //! Exit the program +
-    virtual void      Exit (); +
-}; +
- +
-#endif // __ORXSCROLL_H_ +
-</code> +
- +
-This class interface should look familiar to anyone who has created a standalone application in Orx. In particular, note the existence of the same Init, Run, and Exit functions. +
- +
-Now, let’s create the implementation. Add a new file called OrxScroll.cpp to your project and add the following code: +
- +
-<code c> +
-//! Includes +
-// The following define/undef is done only once in the project. It should be +
-// done before including the interface of the class deriving from +
-// Scroll (as follows). +
-#define __SCROLL_IMPL__ +
-#include "OrxScroll.h" +
-#undef __SCROLL_IMPL__ +
- +
-orxSTATUS OrxScroll::Init () +
-+
-    orxSTATUS result = orxSTATUS_SUCCESS; +
- +
-    return result; +
-+
- +
-orxSTATUS OrxScroll::Run () +
-+
-    orxSTATUS result = orxSTATUS_SUCCESS; +
- +
-    return result; +
-+
- +
-void OrxScroll::Exit () +
-+
-+
- +
-int main (int argc, char **argv) +
-+
-  // Executes game +
-  OrxScroll::GetInstance ().Execute (argc, argv); +
- +
-  // Done! +
-  return EXIT_SUCCESS; +
-+
-</code>+
  
 ===== Run It ===== ===== Run It =====
  
-You can now build and run your project. The Init, Run, and Exit functions will work in the normal way and you can apply all your knowledge of Orx in this class.+You can now build and run your project. The ''Init''''Run'', and ''Exit'' functions will work in the normal way and you can apply all your knowledge of Orx in this class.
  
 ===== What’s the Big Deal? ===== ===== What’s the Big Deal? =====
Line 122: Line 40:
  
 The [[en:tutorials:orxscroll:binding-orxscroll|next tutorial]] will introduce object creation (the Scroll way) and object binding. The [[en:tutorials:orxscroll:binding-orxscroll|next tutorial]] will introduce object creation (the Scroll way) and object binding.
 +
en/tutorials/orxscroll/introduction-orxscroll.1598897428.txt.gz · Last modified: 2020/08/31 11:10 (5 years ago) by iarwain