User Tools

Site Tools


en:tutorials:objects:frame

Differences

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

Link to this comparison view

Next revision
Previous revision
en:orx:tutorials:frame [2009/07/23 15:04 (15 years ago)] – created iarwainen:tutorials:objects:frame [2022/12/06 13:38 (16 months ago)] (current) iarwain
Line 1: Line 1:
-====== Frame tutorial ======+====== Object Transformations ======
  
 ===== Summary ===== ===== Summary =====
  
-See previous [[en:orx:tutorials#Basic|basic tutorials]] for more info about basic object creation and clock handling.+See previous basic tutorials for more info about [[object|basic object creation]] and [[..:clocks:clock|clock handling]].
  
 All objects' positions, scales and rotations are stored in ''orxFRAME'' structures.\\ All objects' positions, scales and rotations are stored in ''orxFRAME'' structures.\\
Line 9: Line 9:
  
 In this tutorial, we have four objects that we link to a common parent ((an empty object, with no visual)) and a fifth one which has no parent.\\ In this tutorial, we have four objects that we link to a common parent ((an empty object, with no visual)) and a fifth one which has no parent.\\
-The first two children are implicitely created using the object's config property ''ChildList'' whereas the two others are created and linked in code (for didactic purposes).\\+The first two children are implicitly created using the object's config property ''ChildList'' whereas the two others are created and linked in code (for didactic purposes).\\
 The invisible parent object will follow the mouse cursor. Left shift and left control keys will respectively scale up and down the parent object, where as left and right clicks will apply a rotation to it.\\ The invisible parent object will follow the mouse cursor. Left shift and left control keys will respectively scale up and down the parent object, where as left and right clicks will apply a rotation to it.\\
 All these transformations will affect its four children. All these transformations will affect its four children.
Line 17: Line 17:
 ===== Details ===== ===== Details =====
  
-As with the [[en:orx:tutorials#Basic|previous tutorials]], we begin by loading our config file and creating a viewport.+As with the previous tutorials, we begin by creating a viewport.
  
-<code c>orxConfig_Load("../03_Frame.ini"); +<code c>orxViewport_CreateFromConfig("Viewport");</code>
- +
-orxViewport_CreateFromConfig("Viewport");</code>+
  
 We then create our parent object. We then create our parent object.
Line 36: Line 34:
 and link them manually. and link them manually.
  
-<code c>pstObjectList[0] = orxObject_CreateFromConfig("Object0"); +<code c>orxOBJECT *pstObject; 
-pstObjectList[1] = orxObject_CreateFromConfig("Object1"); +orxObject_CreateFromConfig("Object0"); 
-pstObjectList[2] = orxObject_CreateFromConfig("Object2"); +pstObject = orxObject_CreateFromConfig("Object1"); 
- +orxObject_SetParent(pstObject, pstParentObject); 
-orxObject_SetParent(pstObjectList[1], pstParentObject); +pstObject = orxObject_CreateFromConfig("Object2"); 
-orxObject_SetParent(pstObjectList[2], pstParentObject);</code>+orxObject_SetParent(pstObject, pstParentObject); 
 +</code>
  
 Here, ''Object0'' is our static object: the only one that won't be linked to our ''ParentObject''. Here, ''Object0'' is our static object: the only one that won't be linked to our ''ParentObject''.
Line 47: Line 46:
 Please note that when we create and link manually objects in code, it's our responsability to delete them. On the contrary, ''Object3'' and ''Object4'' will be automatically deleted when ''ParentObject'' will be deleted. Please note that when we create and link manually objects in code, it's our responsability to delete them. On the contrary, ''Object3'' and ''Object4'' will be automatically deleted when ''ParentObject'' will be deleted.
  
-We then create a 100Hz clock and register our ''Update'' function to it. This function is where we'll manage the inputs to scale/rotate the ''ParentObject'' and make sure it'll follow our mouse cursor.+We then look for the main clock and register our ''Update'' function to it. This function is where we'll manage the inputs to scale/rotate the ''ParentObject'' and make sure it'll follow our mouse cursor. ((Remember to always use the main clock for callbacks that will handle inputs!))
  
-<code c>pstClock = orxClock_Create(orx2F(0.01f), orxCLOCK_TYPE_USER);+<code c>pstClock = orxClock_Get(orxCLOCK_KZ_CORE);
  
 orxClock_Register(pstClock, Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);</code> orxClock_Register(pstClock, Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);</code>
Line 66: Line 65:
  
 The only thing left to do is to apply scale and rotation according to our inputs.\\ The only thing left to do is to apply scale and rotation according to our inputs.\\
-In our case, we defined the following inputs in [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/bin/03_Frame.ini|03_Frame.ini]]: ''RotateLeft'', ''RotateRight'', ''ScaleUp'' and ''ScaleDown''.\\+In our case, we defined the following inputs in [[https://github.com/orx/orx/blob/master/tutorial/bin/03_Frame.ini|03_Frame.ini]]: ''RotateLeft'', ''RotateRight'', ''ScaleUp'' and ''ScaleDown''.\\
  
 Let's see how we handle them. First, the rotations. Let's see how we handle them. First, the rotations.
Line 94: Line 93:
 //NB:// //NB://
  
-  * //We could have used config values instead of constants for the rotation and scale values. This way, we could change them without having to recompile and even update them in real time by pressing// ''BackSpace''. ((default key in orx's launcher for config reload))+  * //We could have used config values instead of constants for the rotation and scale values. This way, we could change them without having to recompile and even update them in real time by using the interactive console.//
   * //As we use the clock's DT for the rotations, they will benefit from time consistency ((they won't depend on frame rate and they will be time-stretchable)). Unfortunately, that won't be the case for the scales. (Which is usually something we really don't want!)//   * //As we use the clock's DT for the rotations, they will benefit from time consistency ((they won't depend on frame rate and they will be time-stretchable)). Unfortunately, that won't be the case for the scales. (Which is usually something we really don't want!)//
  
 ===== Resources ===== ===== Resources =====
  
-Source code: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/src/03_Frame/03_Frame.c|03_Frame.c]] +Source code: [[https://github.com/orx/orx/blob/master/tutorial/src/03_Frame.c|03_Frame.c]]
- +
-Config file: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/bin/03_Frame.ini|03_Frame.ini]]+
  
 +Config file: [[https://github.com/orx/orx/blob/master/tutorial/bin/03_Frame.ini|03_Frame.ini]]
en/tutorials/objects/frame.1248386677.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)