User Tools

Site Tools


en:guides:beginners:survival

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
guides:beginners:survival [2015/10/28 05:33 (9 years ago)] sausageen:guides:beginners:survival [2021/10/09 21:49 (3 years ago)] (current) – Fixed texture filename iarwain
Line 3: Line 3:
 Keeping alive is key in a platformer. The monsters need to be a threat to our hero. If a monster touches our hero, he should explode in a shower of bits. That's game over. Keeping alive is key in a platformer. The monsters need to be a threat to our hero. If a monster touches our hero, he should explode in a shower of bits. That's game over.
  
-For the explosion for our hero, let's use this object in the data/object folder:+For the explosion for our hero, let's use this object from the ''orx/tutorial/data/object'' folder in the Orx project:
  
 {{ :guides:beginners:plus.png?nolink |}} {{ :guides:beginners:plus.png?nolink |}}
Line 11: Line 11:
 <code=ini> <code=ini>
 [SparkGraphic] [SparkGraphic]
-Texture = +.png+Texture = plus.png
 Pivot   = center Pivot   = center
  
Line 24: Line 24:
 </code> </code>
  
-Each SparkObject will fly up and out in a random direction, random colours, sizes, and a random lifetime. 50 at a time should look good. Next, make a body for it so that it will fall back to earth:+Each ''SparkObject'' will fly up and out in a random direction, random colours, sizes, and a random lifetime. 50 at a time should look good. Next, make a body for it so that it will fall back to earth:
  
 <code=ini> <code=ini>
Line 38: Line 38:
 A pretty simple body and part - affected by gravity but not set to collide with anything. A pretty simple body and part - affected by gravity but not set to collide with anything.
  
-Finally, we'll make an empty hero exploder with a spawner that spawns out 50 SparkObject's:+<WRAP center round tip 80%> 
 +Note that giving each particle a body is an easy way to make objects fall to the ground, but it is also heavy and in-efficient. While we won't do it in this guide, an FX can also be a cheap way to make object fall down. See this tutorial if you would like to learn how: [[en:tutorials:spawners:electrical_sparks|Creating Electrical Sparks]] 
 +</WRAP> 
 + 
 +Finally, we'll make an empty hero exploder with a spawner that spawns out 50 ''SparkObject'''s:
  
 <code=ini> <code=ini>
Line 61: Line 65:
 </code> </code>
  
-Now to handle it in code:+Now to handle it in code, by adding the following at the bottom of the ''PhysicsEventHandler'' function:
  
 <code=cpp> <code=cpp>
Line 67: Line 71:
     orxString_Compare(senderObjectName, "MonsterObject") == 0     orxString_Compare(senderObjectName, "MonsterObject") == 0
 ){ ){
-    CreateExplosionAtObject(pstSenderObject, "HeroExploder");+    CreateExplosionAtObject(pstRecipientObject, "HeroExploder");
     orxObject_SetLifeTime(pstSenderObject, 0);     orxObject_SetLifeTime(pstSenderObject, 0);
     orxObject_Enable(pstRecipientObject, orxFALSE);     orxObject_Enable(pstRecipientObject, orxFALSE);
Line 75: Line 79:
     orxString_Compare(recipientObjectName, "MonsterObject") == 0     orxString_Compare(recipientObjectName, "MonsterObject") == 0
 ){ ){
-    CreateExplosionAtObject(pstRecipientObject, "HeroExploder"); +    CreateExplosionAtObject(pstSenderObject, "HeroExploder"); 
-    orxObject_SetLifeTime(pstSenderObject, 0);+    orxObject_SetLifeTime(pstRecipientObject, 0);
     orxObject_Enable(pstSenderObject, orxFALSE);     orxObject_Enable(pstSenderObject, orxFALSE);
 } }
 </code> </code>
  
-So if the hero and the monster touch, disable the hero and place a HeroExploder on top of him.+So if the hero and the monster touch, disable the hero and place a ''HeroExploder'' on top of him.
  
 Compile and run it: Compile and run it:
Line 92: Line 96:
  
 ---- ----
-Next: [[guides:beginners:text_and_game_over|Part 20 – Text and Game Over]].+Next: [[en:guides:beginners:text_and_game_over|Part 20 – Text and Game Over]]. 
 + 
 +{{section>en:guides:beginners:toc&noheader&nofooter&noeditbutton}}
en/guides/beginners/survival.1446035627.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)