beefviper

XMLGameEngine - game.xml

Sep 20th, 2020 (edited)
272
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <game>
  2.     <window title="Pong" width="1280" height="720" background="color.black" fullscreen="false" framerate="60" />
  3.     <variables>
  4.         <variable name="margin" value="30" />
  5.         <variable name="radius" value="10" />
  6.         <variable name="width" value="30" />
  7.         <variable name="height" value="150" />
  8.         <variable name="step" value="2" />
  9.   </variables>
  10.     <objects>
  11.         <object name="logo">
  12.             <sprite src="shape.circle(radius)" />
  13.             <position x="screen.width.center - radius" y="screen.height.center - radius" />
  14.             <velocity x="0" y="0" />
  15.             <actions>
  16.                 <action start="state.playing" />
  17.             </actions>
  18.         </object>
  19.         <object name="ball">
  20.             <sprite src="shape.circle(radius)" />
  21.             <position x="screen.width.center - radius" y="screen.height.center - radius" />
  22.             <velocity x="random.range(-10,10)" y="random.range(-5,5)" />           
  23.         </object>
  24.         <object name="paddle1">
  25.             <sprite src="shape.rectangle(width,height)" />
  26.             <position x="screen.left + margin" y="screen.height.center - height / 2" />
  27.             <velocity x="0" y="0" />
  28.             <collision enabled="true" />
  29.             <actions>
  30.                 <action name="up" value="move.up(step)" />
  31.                 <action name="down" value="move.down(step)" />
  32.             </actions>             
  33.         </object>
  34.         <object name="paddle2">
  35.             <sprite src="shape.rectangle(width,height)" />
  36.             <position x="screen.right - margin - width" y="screen.height.center - height / 2" />
  37.             <velocity x="0" y="0" />
  38.             <collision enabled="true" />
  39.             <actions>
  40.                 <action name="up" value="move.up(step)" />
  41.                 <action name="down" value="move.down(step)" />
  42.             </actions>             
  43.         </object>
  44.     </objects> 
  45.     <states>
  46.         <state name="mainmenu">
  47.             <show object="logo" />
  48.             <inputs>
  49.                 <input action="logo.action.start" button="enter" />
  50.             </inputs>
  51.         </state>
  52.         <state name="settings">
  53.             <show object="logo" />
  54.             <inputs>
  55.                 <input action="game.unpause" button="escape" />
  56.             </inputs>
  57.         </state>
  58.         <state name="playing">
  59.             <show object="ball" />
  60.             <show object="paddle1" />
  61.             <show object="paddle2" />
  62.             <inputs>
  63.                 <input action="paddle1.action.up" button="q" />
  64.                 <input action="paddle1.action.down" button="z" />
  65.                 <input action="paddle2.action.up" button="up" />
  66.                 <input action="paddle2.action.down" button="down" />
  67.             </inputs>
  68.         </state>
  69.         <state name="paused">
  70.             <show object="logo" />
  71.             <inputs>
  72.                 <input action="game.start" button="spacebar" />
  73.             </inputs>
  74.         </state>
  75.     </states>
  76. </game>
  77.  
RAW Paste Data