User Tools

Site Tools


en:tutorials:physics:interaction-physics

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:orx:tutorials:community:grey:tutorial4 [2012/05/22 23:04 (12 years ago)] – [StandAlone.cpp] greyen:tutorials:physics:interaction-physics [2020/08/31 06:38 (4 years ago)] (current) – ↷ Page moved from en:tutorials:community:grey:interaction-physics to en:tutorials:physics:interaction-physics sausage
Line 1: Line 1:
- +====== Interaction, Controls and Physics! ======
-<code c> +
-"DO NOT FOLLOW THESE TUTORIALS OUT OF ORDER UNLESS YOU KNOW WHAT YOU ARE DOING!" :) +
- +
-Each tutorial assumes you have the COMPLETED code from the previous tutorial. +
-This is intentional, as it will teach you the -required- steps to making a project so you can do it yourself in the future! +
-</code> +
- +
-====== Tutorial 4: Interaction, Controls and Physics! ======+
  
  
 For this tutorial, we'll first add some keyboard controls, then later some physics. For this tutorial, we'll first add some keyboard controls, then later some physics.
  
-**You will need some new files [[http://grey.orx-project.org/tutorial_data/tutorial_4/tutorial4_data.zip|available here]].** 
  
 These, are added to our //data// folder, along with everything from tutorial 3. These, are added to our //data// folder, along with everything from tutorial 3.
Line 395: Line 386:
 <code c> <code c>
 // Here we add event handling for tutorial 4, Input! // Here we add event handling for tutorial 4, Input!
- case orxEVENT_TYPE_INPUT: +case orxEVENT_TYPE_INPUT: 
- +
- orxINPUT_EVENT_PAYLOAD* EventPayload = (orxINPUT_EVENT_PAYLOAD*)currentEvent->pstPayload; + orxINPUT_EVENT_PAYLOAD* EventPayload = (orxINPUT_EVENT_PAYLOAD*)currentEvent->pstPayload; 
-  + const orxCHAR* EventAct;
- const orxCHAR* EventAct+
-  +
- switch( currentEvent->eID ) +
-+
- // We don't want this any more, lets comment it out +
- //case orxINPUT_EVENT_ON: EventAct = "pressed down"; break;+
  
 + switch( currentEvent->eID )
 + {
 + // We don't want this any more, lets comment it out
 + //case orxINPUT_EVENT_ON: EventAct = "pressed down"; break;
  
- // NEW STUFF BELOW + // NEW STUFF BELOW 
- + case orxINPUT_EVENT_ON: 
- case orxINPUT_EVENT_ON: +
- + if( orxInput_IsActive( "SpawnBox" ) ) 
- if( orxInput_IsActive( "SpawnBox" ) ) + orxObject_CreateFromConfig( "DynamicBox" );
- orxObject_CreateFromConfig( "DynamicBox" );+
   
- EventAct = "pressed down"; + EventAct = "pressed down"; 
- break; + break; 
- }+ } 
 + // NEW STUFF ABOVE
  
- // NEW STUFF ABOVE + case orxINPUT_EVENT_OFF: EventAct = "released"; break; 
- + default: return orxSTATUS_SUCCESS; // Remember to 'early return' here, as there are more than just the two events we've specifically handled right now. 
- case orxINPUT_EVENT_OFF: EventAct = "released"; break; + }
- default: return orxSTATUS_SUCCESS; // Remember to 'early return' here, as there are more than just the two events we've specifically handled right now. +
- }+
    
- orxLOG("Input <%s> has been %s!", EventPayload->zInputName, EventAct ); + orxLOG("Input <%s> has been %s!", EventPayload->zInputName, EventAct ); 
- break; + break; 
- }+}
 </code> </code>
  
Line 488: Line 475:
  
 'World' refers to the coordinates all our objects live in, 'Screen' refers to the coordinates inside the window we're clicking on. 'World' refers to the coordinates all our objects live in, 'Screen' refers to the coordinates inside the window we're clicking on.
 +
 +<i>WARNING: There is a bug in the Visual Studio 2008 compiler where this function is mis-optimized and your game may crash at a random place.</i>
  
 Next we'll make a little change to our EventHandler. Next we'll make a little change to our EventHandler.
Line 537: Line 526:
  
 Compile, and try it out, and hopefully get distracted for the next 5 minutes like I was, so you don't notice that this tutorial is over! :D Compile, and try it out, and hopefully get distracted for the next 5 minutes like I was, so you don't notice that this tutorial is over! :D
- 
- 
- 
-====== See Also ====== 
-This article is part of a series!\\ 
-Series: [[en:orx:tutorials:community:grey|Grey's tutorials]]\\ 
-Prev: [[en:orx:tutorials:community:grey:Tutorial3|"Tutorial 3: Scene Loading and Animation."]]\\ 
-Next: (none)\\ 
  
en/tutorials/physics/interaction-physics.1337753090.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)