Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- intX = 0
- intY = 0
- operator = "+"
- function bepaalOperator()
- if Keys.newPress.A then
- operator = "+"
- elseif Keys.newPress.B then
- operator = "-"
- elseif Keys.newPress.X then
- operator = "*"
- elseif Keys.newPress.Y then
- operator = "/"
- end
- end
- function bepaalWaarde()
- if Keys.newPress.Up then
- intX = intX+1
- elseif Keys.newPress.Down then
- intX = intX-1
- elseif Keys.newPress.Left then
- intY = intY+1
- elseif Keys.newPress.Right then
- intY = intY-1
- end
- end
- --Deze functie zorgt voor de berekening
- function berekenSom(parX, parY)
- if operator == "+" then
- berekening = (parX + parY)
- elseif operator == "-" then
- berekening = (parX - parY)
- elseif operator == "*" then
- berekening = (parX * parY)
- elseif operator == "/" then
- berekening = (parX / parY)
- end
- return berekening
- end
- --Deze functie zorgt voor de zichtbare tekst op het scherm
- function drawScreen()
- screen.startDrawing()
- screen.print(SCREEN_UP,0,0,"Press START to stop")
- screen.print(SCREEN_UP,0,10,"Press A,B,X,Y to change the operator")
- screen.print(SCREEN_UP,0,20,"Press Arrow keys to change the variables")
- screen.print(SCREEN_DOWN,10,100,"x: "..intX)
- screen.print(SCREEN_DOWN,10,110,"y: "..intY)
- screen.print(SCREEN_DOWN,10,120,"operator: "..operator)
- screen.print(SCREEN_DOWN,10,130,"Het antwoord op de berekening is "..berekenSom(intX,intY))
- screen.stopDrawing()
- end
- while not Keys.newPress.Start do
- Controls.read()
- bepaalOperator()
- bepaalWaarde()
- drawScreen()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement