Difference between revisions of "AGIWiki/controller"

Jump to navigation Jump to search
361 bytes added ,  15:10, 25 October 2018
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Text replacement - "</source>" to "</syntaxhighlight>")
Tags: Mobile edit Mobile web edit
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{AGIWiki}}
{{AGIWiki}}
 
{{AGIWiki/Test commands}}
''This article refers controller-command. For information about Controllers as part of an AGI game, see [[AGIWiki/Controller|Controller]].''
''This article refers controller-command. For information about Controllers as part of an AGI game, see [[AGIWiki/Controller|Controller]].''


Line 22: Line 21:


== Example ==
== Example ==
<syntax type="C++">
<syntaxhighlight lang="cpp">
//build a simple menu structure
//build a simple menu structure
set.menu("File");
set.menu("Info");
set.menu.item("Save Game      &lt;F5&gt;", c2);
set.menu.item("About  ", c0);
set.menu.item("Restore Game  &lt;F7&gt;", c3);
set.menu.item("Help    ", c1);
set.menu("File");
set.menu.item("Save Game      <F5>", c2);
set.menu.item("Restore Game  <F7>", c3);
set.menu.item("-------------------", c20);
set.menu.item("Restart Game  <F9>", c4);
set.menu.item("-------------------", c20);
set.menu.item("Quit        <Alt Z>", c5);
//disable the separators
disable.item(c20);
 
//submit menu to agi
submit.menu()


//submit menu to agi
//create keyboard shortcuts
submit.menu()
set.key(0, 63, c2); // 'F5'
set.key(0, 65, c3); // 'F7'
set.key(0, 67, c4); // 'F9'
set.key(26, 0, c5); // 'Alt-Z'


//create keyboard shortcuts
//test for menu or keyboard selections
set.key(0, 63, c2); // 'F5'
if (controller(c2) {
set.key(0, 65, c3); // 'F7'
  //save game
  save.game();
}
if (controller(c3) {
  //restore game
  restore.game()
}
</syntaxhighlight>


//test for menu or keyboard selections
if (controller(c2) {
  //save game
  save.game();
}
if (controller(c3) {
  //restore game
  restore.game()
}
...
</syntax>
== Technical Information ==
== Technical Information ==


TrustedUser
2,147

edits

Navigation menu