User Tools

Site Tools


scratch

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
scratch [2018/12/12 13:44]
sausage
scratch [2021/02/02 01:24] (current)
Line 1: Line 1:
-Every program that is built using Orx contains a profiler tool. The Profiler ​is compiled-in when using either debug or release modes.+One of the unique features available within ​Orx is the ability to switch languages ​in game using locale features. While many game engines allow a user to program using locale to some degree, Orx lets you switch languages back and forth in real-time.
  
-The tool helps you diagnose bottlenecks ​and monitor performance ​and internal resources.+An example of this could be a graphical adventure game that features characters, onscreen text, digital speech, ​and music. Locale switching would allow you to completely switch out all graphics, text, speech ​and music with a single function call without altering the game-play.
  
-To show the profiler ​in your game or applicationadd the following ​to your config:+All data is defined by you, and so your regions or nations could be aliens/​humans,​ orcs/elves. You could even think of it as a kind of themeing. 
 + 
 +Its a pretty amazing feature that comes out of the box. 
 + 
 +This tutorial will be done in two steps: 
 + 
 +1. Create a simple ​game with  characters with their own look, speech and music. 
 +2. Add in a second locale, and be able to switch between them. 
 + 
 + 
 +Begin with a blank project created using init. 
 + 
 +Name your project something like the-conversation (or whatever you wish).  
 + 
 +Our game will be about two polite gentlemen having a conversation. They continually greet each other all day. 
 + 
 +Eventuallywe want to be able to switch their nationality,​ as the player may prefer ​to play the game in their own country and language. 
 + 
 +Assets 
 + 
 +Let's begin with the French assets, and build the French version first. 
 + 
 + 
 +Object 
 + 
 +Speech 
 + 
 +Music 
 + 
 + 
 +Delete the default config object and FX sections. We wont need those. 
 + 
 +Create the default ''​Person''​ object in the config ​with:
  
 [] []
  
-Although it makes more practical sense to toggle it on and off with a key stroke:+Create a second person from the first, but one that stands ​on the other side and faces the other way:
  
-Config 
 [] []
  
-Code+Next, create a ''​Scene''​ object that will be the root to hold all the other objects. Then place both Person objects in it's Childlist. 
 [] []
  
-Run your application again, and press the [] key to bring up your Profiler.+Create ​the scene in the game in codeThis will create all the child objects onscreen. You can just change the existing ''​Object''​ creation with ''​Scene'',​ from:
  
 +[]
  
-Profiler Layout+to:
  
-1) Thread Frame bar+[]
  
-This grey bar indicates which thread is currently selected. Most of Orx's tasks run on the main thread. There are other threads that handle things like streaming audio, resource requests and bitmap decompressing which run on other threads. Select your thread with the Page Up and Page Down keys. 
  
-The first value displayed is the amount of time in ms that it took to render the entire current frame. The second value shows the largest amount of time that a frame took to render in the last second. 
  
-2) The Meter Bar Panel +Create all the text objects ​to go onscreenYou will need text objects for:
-These coloured meter bars indicate how much time each Marker took to complete within ​the frame. The colours themselves correspond ​to the colours on each Markers in the Marker panels.+
  
-The bars are spread over four or more lines. ​The row of the bar corresponds to the level of the system. For example, the render task is on the top level, so sits in the top row. The orxSpawner_Update is three levels into the hierarchy and is therefore on the third row. + ​- ​The speech 
 + ​- ​The player instructions 
 + ​- ​The current language indicator
  
-3) Marker panel +Create these as:
-This panel shows all the Markers currently running in the frame. Markers represent important function calls. Each Marker contains three numbers.+
  
-The first is the amount of time in ms this Marker has taken to run in the current frame. The second number indicates the longest amount of time this Marker took to run in the last second.+[]
  
-The last number shows how many times this Marker was run in the frame.+And now place them into the scene by adding them to the Childlist:
  
-You can even add your own custom markers.+Next is the musicDefine it with:
  
-4) Secondary Marker panel +[]
-The Markers in this panel are not unique. The grey lines indicate functions that were called at some point - but not during the frame. So they will show having run 0x times.+
  
-The white lines indicate xxxx.+And add it to the scene with:
  
-5) Memory Panel +[]
-Each line represents a different type of memory. ​+
  
-The first group of numbers represents the number of live allocations and the second number ​is the max allocations in the past. +Next is the actual conversation. Define ​the speech with:
  
-The second group of numbers is the same, but is now representing the size of the memory allocations in Megabytes. ​+[]
  
-The last number shows the amount ​of transactions since the beginning of the application. A transaction is the allocating or de-allocating of memory.+Them using a timeline track switch on and off the alpha of the speech text object to make it appear/​disappear,​ move its position and play the sounds.
  
 +Compile and run. Our two French gentlemen will start having a lovely conversation.
  
  
 +That is the basic game. 
  
-Using the profiler 
  
-You can pause or unpause ​the profiler at any time using the `Space Bar`.+Now to make the game switchable to Australia mode. This is the easy part.
  
-Observe ​the running function call Markers. Currently there are no physics calls running in the engine. You can still interact with the demo in the background. If you click with the left mouse button you will spawn some physics objects.+Begin by defining ​the two languages for the game: French and Australian.
  
-Notice that the orxPhysics_ApplySimResult marker appears now in the Marker Panel. And there is a corresponding coloured meter bar for it in the Meter Bar Panel. Once all the objects have finished their lifetime ​and have disappeared,​ then the orxPhysics_ApplySimResult marker drops down to grey again and is no longer ​called.+[] 
 + 
 +Next, define those languages as sections containing your keys for the various assets or text: 
 + 
 +[] 
 + 
 +Finally go to each config and replace ​the absolute asset paths and text with the named keys from language sections. These keys are called ​using the special $ symbol:  
 + 
 +[]
  
 +Compile and run. Now you can switch between the two languages with the Space Bar. Everything in the game switches over in an instant. Pretty impressive stuff. ​
  
  
 +Acknowledgements,​ permissions and thanks
 +Accordion performance of Je Te Veux by Norimichi Nagasaka. Youtube channel is at: https://​www.youtube.com/​user/​VAccordion
 +Graphics by Trevor Brennan: http://​trevorbrennan.com
 +Thanks to FullyBugged,​ Dom M ad Matt R for the voices.
  
scratch.1544622259.txt.gz · Last modified: 2021/02/02 01:24 (external edit)