User Tools

Site Tools


en:guides:beginners:text_and_game_over

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:text_and_game_over [2015/10/28 19:35 (9 years ago)] – ↷ Links adapted because of a move operation sausageen:guides:beginners:text_and_game_over [2023/03/28 21:13 (12 months ago)] (current) iarwain
Line 15: Line 15:
 [ScoreObject] [ScoreObject]
 Graphic  = ScoreGraphic Graphic  = ScoreGraphic
-Position = (2020, 0)+Position = (-380-280, 0)
 </code> </code>
  
-Interesting to note the special Text definition. ScoreGraphic uses this instead of a texture from file. And the ScoreObject uses the graphic section as others before.+Interesting to note the special ''Text'' definition. ''ScoreGraphic'' uses this instead of a texture from file. And the ''ScoreObject'' uses the graphic section as others before.
  
 Now, in code, add a score variable and a scoreObject at the top of the file: Now, in code, add a score variable and a scoreObject at the top of the file:
Line 42: Line 42:
  
     orxCHAR formattedScore[6];     orxCHAR formattedScore[6];
-    orxString_Print(formattedScore, "%d", score);+    orxString_NPrint(formattedScore, sizeof(formattedScore), "%d", score);
  
     orxObject_SetTextString(scoreObject, formattedScore);     orxObject_SetTextString(scoreObject, formattedScore);
Line 48: Line 48:
 </code> </code>
  
-Add 250 points whenever a monster is hit with a bullet:+Add 250 points whenever a monster is hit with a bullet. Add UpdateScore() function calls to:
  
 <code=cpp> <code=cpp>
Line 66: Line 66:
 </code> </code>
  
-And of course, 1000 points bonus if the star is reached:+And of course, 1000 points bonus if the star is reached. Add the following code:
  
 <code=cpp> <code=cpp>
Line 86: Line 86:
 A final thing for the game will be to add a game over panel when the hero dies. For this, we'll have an object that gets created using a timeline track after a two second delay. First, a game over asset: A final thing for the game will be to add a game over panel when the hero dies. For this, we'll have an object that gets created using a timeline track after a two second delay. First, a game over asset:
  
-{{ tutorials:community:sausage:gameover.png?nolink |}}+{{ tutorials:tracks:gameover.png?nolink |}}
  
-Save this into the data/object folder as "gameover.png".+Save this into the ''data/texture'' folder as "gameover.png".
  
 Create a simple gameover graphic and object: Create a simple gameover graphic and object:
Line 95: Line 95:
 [GameOverGraphic] [GameOverGraphic]
 Texture = gameover.png Texture = gameover.png
 +Pivot   = center
  
 [GameOverObject] [GameOverObject]
 Graphic  = GameOverGraphic Graphic  = GameOverGraphic
-Position = (280250, -0.1)+Position = (00, -0.1)
 </code> </code>
  
-Create a timeline track with a single command to create the GameOverObject:+Create a timeline track with a single command to create the ''GameOverObject'':
  
 <code=ini> <code=ini>
Line 108: Line 109:
 </code> </code>
  
-Then finally in the physics handler code, when the hero is destroyed, create the timeline track. After a two second delay, the GameOverObject will be created on screen:+Then finally, change the physics handler code, so that when the hero is destroyed, create the timeline track. After a two second delay, the ''GameOverObject'' will be created on screen:
  
 <code=cpp> <code=cpp>
Line 114: Line 115:
     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 123: Line 124:
     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);
     orxObject_AddTimeLineTrack(scene, "PopUpGameOverTrack");     orxObject_AddTimeLineTrack(scene, "PopUpGameOverTrack");
Line 140: Line 141:
 </code> </code>
  
-And then set the variable on the  orxObject_CreateFromConfig("Scene") in the init() function:+And then set the ''scene'' variable on the  orxObject_CreateFromConfig("Scene") in the init() function:
  
 <code=cpp> <code=cpp>
Line 152: Line 153:
 Well friends, that's game over. If you reached the end here, great job! You've learned many of the major features of Orx. Well friends, that's game over. If you reached the end here, great job! You've learned many of the major features of Orx.
  
-If you need more help, go to the [[tutorials:by-subject-previous|tutorials]] section where many of these concepts are covered in greater detail.+If you need more help, go to the [[en:tutorials:main|tutorials]] section where many of these concepts are covered in greater detail
 + 
 +If you need quick examples, you can visit the [[en:examples:]] section and search by subject.
  
-If you need quick examplesyou can visit the [[examples]] section and search by subject.+If you get stuckplease post it to the [[http://orx-project.org/forum|forum]]and for general chat, come and join us over on [[https://orx-project.org/discord|Discord]]. Hope to see you there.
  
-If you get stuck, please post it to the [[http://orx-project.org/forum|forum]], and for general chat, come and join us over in [[https://gitter.im/orx/orx|gitter]]. Hope to see you there.+{{section>en:guides:beginners:toc&noheader&nofooter&noeditbutton}}
en/guides/beginners/text_and_game_over.1446086105.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)