Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import mojo
- Global tipo_pulsante: int[20]
- Global che_click=0
- Global fine_gioco=0
- Class Game Extends App
- Method OnCreate()
- SetUpdateRate 30
- End
- Method OnRender()
- Cls
- For Local x=0 To 2
- For Local y=0 To 2
- Local numero: Int=x+y*3
- Local xf:Float= DeviceWidth()
- Local yf:Float= DeviceHeight()
- Local dime: Float= yf*.33333333
- Local sposta_x=(xf-yf)*.5
- crea_pulsante(numero,sposta_x+dime*x,dime*y,dime,dime)
- Next
- Next
- controllo()
- End
- End
- Function Main()
- New Game()
- End
- Function crea_pulsante(num: Int,x: Int,y: Int,dx: Int,dy: Int)
- SetColor 200,200,200
- If (MouseX()>x And MouseX()<x+dx)
- If (MouseY()>y And MouseY()<y+dy)
- If (MouseDown(0) And fine_gioco=0)
- If (tipo_pulsante[num]=0)
- tipo_pulsante[num]=che_click+1
- che_click=1-che_click
- Endif
- endif
- SetColor 200,0,0
- Endif
- endif
- DrawRect x+1,y+1,dx-2,dy-2
- SetColor 255,255,255
- DrawRect x+3,y+3,dx-6,dy-6
- If tipo_pulsante[num]=1
- SetColor 0,255,0
- DrawOval x+15,y+15,dx-30,dy-30
- SetColor 255,255,255
- DrawOval x+17,y+17,dx-34,dy-34
- Endif
- If tipo_pulsante[num]=2
- SetColor 255,0,0
- DrawLine x+15,y+15,x+dx-15,y+dy-15
- DrawLine x+dx-15,y+15,x+15,y+dy-15
- Endif
- End Function
- Function controllo()
- fine_gioco=0
- For Local g=1 To 2
- For Local pos=0 To 2
- If (tipo_pulsante[pos*3]=g and tipo_pulsante[pos*3+1]=g and tipo_pulsante[pos*3+2]=g )
- fine_gioco=g
- Endif
- If (tipo_pulsante[0+pos]=g and tipo_pulsante[3+pos]=g and tipo_pulsante[6+pos]=g )
- fine_gioco=g
- Endif
- Next
- If (tipo_pulsante[0]=g and tipo_pulsante[4]=g and tipo_pulsante[8]=g )
- fine_gioco=g
- Endif
- If (tipo_pulsante[2]=g and tipo_pulsante[4]=g and tipo_pulsante[6]=g )
- fine_gioco=g
- Endif
- next
- If fine_gioco>0
- DrawText "Vince Giocatore "+fine_gioco,DeviceWidth/2,DeviceHeight/2,.5,.5
- Endif
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement