User Tools

Site Tools


en:tutorials:clock

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
en:tutorials:clock [2010/11/01 05:58 (10 years ago)]
iarwain Inputs are handled through the main clock
en:tutorials:clock [2018/02/14 08:46 (2 years ago)] (current)
Line 9: Line 9:
 for demonstration only.)) for demonstration only.))
  
-The first clock runs at 0.01s per tick (100 Hzand the second one at 0.2s per tick (5 Hz).+The first clock runs at 100 Hz and the second one at 5 Hz.
  
 If you press the arrow keys up, down and right, you can alter the time stretching of the first clock. If you press the arrow keys up, down and right, you can alter the time stretching of the first clock.
Line 32: Line 32:
 <code c>​orxCLOCK *pstClock1, *pstClock2; <code c>​orxCLOCK *pstClock1, *pstClock2;
  
-pstClock1 = orxClock_Create(orx2F(0.01f),​ orxCLOCK_TYPE_USER);+pstClock1 = orxClock_CreateFromConfig("​Clock1"​);
  
-pstClock2 = orxClock_Create(orx2F(0.2f),​ orxCLOCK_TYPE_USER);</​code>​+pstClock2 = orxClock_CreateFromConfig("​Clock2"​);</​code>​
  
-Note that we gave the type ''​orxCLOCK_TYPE_USER''​ to be able to retrieve it if we don't store it, from any place in our game code. +And in config ​we simply have:
-Actually, any value higher than this one is valid. The ones lesser than this are reserved for engine internal use.+
  
-Now we'll use the same update callback on both clocks. However, we'​ll ​given them different context so that the first clock callback registration applies to our first object, and the second one on the other object:+<code ini>​[Clock1] 
 +Frequency = 100 
 + 
 +[Clock2] 
 +Frequency = 5</​code>​ 
 + 
 +//NB: By default the core clock will use a maximized DT (cf. [[en:​orx:​config:​settings_main:​main#​render_module|orx'​s render module settings]]) which means that the core clock and user created clocks, even based on the same frequency, might get out of sync due to extreme lag ((when dragging the window by its title bar, for example)). If you want to keep all your user-created clocks in sync with the core one, you can either ask for no maximized DT for the core clock in the render module config section **or** set the same maximized DT on your user clock with the orxClock_SetModifier() function.//​ 
 + 
 +Now we'll use the same update callback on both clocks. However, we'​ll ​give them different context so that the first clock callback registration applies to our first object, and the second one on the other object:
  
 <code c>​orxClock_Register(pstClock1,​ Update, pstObject1, orxMODULE_ID_MAIN,​ orxCLOCK_PRIORITY_NORMAL);​ <code c>​orxClock_Register(pstClock1,​ Update, pstObject1, orxMODULE_ID_MAIN,​ orxCLOCK_PRIORITY_NORMAL);​
Line 116: Line 123:
 ===== Resources ===== ===== Resources =====
  
-Source code: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/​tutorial/​src/02_Clock/​02_Clock.c|02_Clock.c]]+Source code: [[https://bitbucket.org/orx/orx/src/default/​tutorial/​src/​02_Clock.c|02_Clock.c]]
  
-Config file: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/​tutorial/​bin/​02_Clock.ini|02_Clock.ini]]+Config file: [[https://bitbucket.org/orx/orx/src/default/​tutorial/​bin/​02_Clock.ini|02_Clock.ini]]
  
 +Video: [[http://​www.youtube.com/​watch?​v=l9GuYhbtPzw|Video by acksys]]
en/tutorials/clock.1288591104.txt.gz · Last modified: 2017/05/30 07:50 (3 years ago) (external edit)