Kingdaro

GameAPI Example

Dec 26th, 2011
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. shell.run('gameapi')
  2.  
  3. player = actor:new(1,10,'O')
  4.  
  5. --basic player movement
  6. function game.key(k)
  7.     if k==203 then --left
  8.         player:addX(-1)
  9.         player:setChar('<')
  10.     elseif k==205 then --right
  11.         player:addX(1)
  12.         player:setChar('>')
  13.     elseif k==200 then --up
  14.         player:addY(-1)
  15.         player:setChar('^')
  16.     elseif k==208 then --down
  17.         player:addY(1)
  18.         player:setChar('V')
  19.     end
  20. end
  21.  
  22. function game.update()
  23.     print "you could print the player's score here"
  24. end
  25.  
  26. game.start() --NEEDED
Advertisement
Add Comment
Please, Sign In to add comment