Slots app help needed

Monkey Forums/Monkey Beginners/Slots app help needed

Rollie(Posted 2014) [#1]
Import mojo
Function intToStr : String (anInteger)
If anInteger = 0 Then
Return "7"
End
If anInteger = 1 Then
Return "BELL"
End
If anInteger = 2 Then
Return "CHERRY"
End
End
Class Mygame Extends App
Global a:Int
Global b:Int
Global c:Int
Method OnCreate()
SetUpdateRate 0
a = monkey.random.Rnd(0,2)
b = monkey.random.Rnd(0,2)
c = monkey.random.Rnd(0,2)
End
Method OnRender()
Cls 0, 0, 0
SetColor 1,1,222
DrawText intToStr(a) , 2, 5
DrawText intToStr(b) , 27, 5
DrawText intToStr(c) , 52, 5
End
End
Function Main()
New Mygame()
End

--------------------
it never shows "CHERRY
and doesnt show up until i minimize & maximize the window context


Rollie(Posted 2014) [#2]
http://xgdev.com/misc/Slots.monkey.txt

above is the code with proper indetaiton


Nobuyuki(Posted 2014) [#3]
You can encapsulate code with this tag: [codebox]

try changing SetUpdateRate 0 to SetUpdateRate 60. Setting it to 0 is mainly for users who want to implement their own timing. Rnd() is max value exclusive. This means that to get it to produce the number 2, you have to set Rnd(3). This will produce every number between 0-3 except for 3.


Raul(Posted 2014) [#4]
also in order to generate random numbers you must first create a Seed.

Try using this code as seen in the therevills example:
http://www.monkey-x.com/Community/posts.php?topic=8173

	Local date:Int[] = GetDate()		
	Seed = date[5] + date[6]