beefviper

XMLGameEngine - Pong.xml

May 26th, 2020
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.40 KB | None | 0 0
  1. <game>
  2.     <head>
  3.         <title>Pong</title>
  4.         <screen width="1280" height="720" background="color.black" fullscreen="false" />
  5.     </head>
  6.     <body>
  7.         <variables>
  8.             <variable name="margin" value="30" />
  9.             <variable name="radius" value="20" />
  10.             <variable name="width" value="30" />
  11.             <variable name="height" value="200" />
  12.         </variables>
  13.         <objects>
  14.             <object name="logo">
  15.                 <sprite src="shape.circle(radius)" />
  16.                 <position x="screen.width.center" y="screen.height.center" />
  17.                 <velocity x="0" y="0" />
  18.                 <actions>
  19.                     <action start="state.playing" />
  20.                 </actions>
  21.             </object>
  22.        
  23.             <object name="ball">
  24.                 <sprite src="shape.circle(radius)" />
  25.                 <position x="screen.width.center - radius" y="screen.height.center - radius" />
  26.                 <velocity x="rand(10)" y="rand(10)" />         
  27.             </object>
  28.            
  29.             <object name="paddle1">
  30.                 <sprite src="shape.rectangle(width,height)" />
  31.                 <position x="screen.left + margin" y="screen.height.center - height / 2" />
  32.                 <velocity x="0" y="0" />
  33.                 <collision enabled="true" />
  34.                 <movement horizontal="false" vertical="true" />
  35.             </object>
  36.            
  37.             <object name="paddle2">
  38.                 <sprite src="shape.rectangle(width,height)" />
  39.                 <position x="screen.right - margin - width" y="screen.height.center - height / 2" />
  40.                 <collision enabled="true" />
  41.                 <velocity x="0" y="0" />
  42.                 <movement up="true" down="true" left="false" right="false" />
  43.                 <actions>
  44.                     <action up="movement.up" />
  45.                     <action down="movement.down" />
  46.                 </actions>             
  47.             </object>
  48.         </objects> 
  49.        
  50.         <states>
  51.  
  52.             <state name="mainmenu">
  53.                 <show object="logo" />
  54.                 <inputs>
  55.                     <input action="logo.action.start" button="enter" />
  56.                 </inputs>
  57.             </state>
  58.  
  59.             <state name="settings">
  60.                 <show object="logo" />
  61.                 <inputs>
  62.                     <input action="game.unpause" button="escape" />
  63.                 </inputs>
  64.             </state>
  65.  
  66.             <state name="playing">
  67.                 <show object="ball" />
  68.                 <show object="paddle1" />
  69.                 <show object="paddle2" />
  70.                 <inputs>
  71.                     <input action="paddle1.action.up" button="q" />
  72.                     <input action="paddle1.action.down" button="z" />
  73.                     <input action="paddle2.action.up" button="up" />
  74.                     <input action="paddle2.action.down" button="down" />
  75.                 </inputs>
  76.             </state>
  77.  
  78.             <state name="paused">
  79.                 <show object="logo" />
  80.                 <inputs>
  81.                     <input action="game.start" button="spacebar" />
  82.                 </inputs>
  83.             </state>
  84.         </states>
  85.     </body>
  86. </game>
Add Comment
Please, Sign In to add comment