Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. intX = 0
  2. intY = 0
  3. operator = "+"
  4.  
  5. function bepaalOperator()
  6.     if Keys.newPress.A then
  7.         operator = "+"
  8.     elseif Keys.newPress.B then
  9.         operator = "-"
  10.     elseif Keys.newPress.X then
  11.         operator = "*"
  12.     elseif Keys.newPress.Y then
  13.         operator = "/" 
  14.     end
  15. end
  16.  
  17. function bepaalWaarde()
  18.     if Keys.newPress.Up then
  19.         intX = intX+1
  20.     elseif Keys.newPress.Down then
  21.         intX = intX-1
  22.     elseif Keys.newPress.Left then
  23.         intY = intY+1
  24.     elseif Keys.newPress.Right then
  25.         intY = intY-1  
  26.     end
  27. end
  28.    
  29. --Deze functie zorgt voor de berekening
  30. function berekenSom(parX, parY)
  31.     if operator == "+" then
  32.         berekening = (parX + parY)
  33.     elseif operator == "-" then
  34.         berekening = (parX - parY) 
  35.     elseif operator == "*" then
  36.         berekening = (parX * parY)
  37.     elseif operator == "/" then
  38.         berekening = (parX / parY)
  39.     end
  40.     return berekening
  41. end
  42.  
  43.  
  44. --Deze functie zorgt voor de zichtbare tekst op het scherm
  45. function drawScreen()
  46.     screen.startDrawing()
  47.     screen.print(SCREEN_UP,0,0,"Press START to stop")
  48.     screen.print(SCREEN_UP,0,10,"Press A,B,X,Y to change the operator")
  49.     screen.print(SCREEN_UP,0,20,"Press Arrow keys to change the variables")
  50.    
  51.     screen.print(SCREEN_DOWN,10,100,"x: "..intX)
  52.     screen.print(SCREEN_DOWN,10,110,"y: "..intY)
  53.     screen.print(SCREEN_DOWN,10,120,"operator: "..operator)
  54.     screen.print(SCREEN_DOWN,10,130,"Het antwoord op de berekening is "..berekenSom(intX,intY))
  55.     screen.stopDrawing()
  56. end
  57.  
  58. while not Keys.newPress.Start do
  59.     Controls.read()
  60.     bepaalOperator()
  61.     bepaalWaarde()
  62.     drawScreen()
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement