09-13-2024, 09:47 AM
Coin Flip Game
Borrowed Qwerky's coin images and some of Steve's LOC cutting tricks
Code: (Select All)
_Title "Coin Flip Game" 'b+ 2024-09-13 thanks Qwerky for Coin images
Randomize Timer: Screen _NewImage(800, 600, 32): _ScreenMove 250, 60
i& = _LoadImage("Obverse.png"): imgHead& = _NewImage(103, 103, 32): _PutImage , i&, imgHead&
i& = _LoadImage("Reverse.png"): imgTail& = _NewImage(103, 103, 32): _PutImage , i&, imgTail&
While _KeyDown(27) = 0
Locate 18, 20: Print "Your score"; score; "in"; flips; "flips."
Locate 20, 20: Input "Enter h for heads, t for tails any else quits "; ht$
If ht$ <> "h" And ht$ <> "t" Then End
If Rnd < .5 Then img& = imgHead& Else img& = imgTail&
If img& = imgTail& And ht$ = "t" Then score = score + 1
If img& = imgHead& And ht$ = "h" Then score = score + 1
flips = flips + 1: start = 1: fini = 0: stepper = -.02: cx = 180: cy = _Height - 50: dcy = -3
Do
For i = start To fini Step stepper
Cls: a = a + 1: cx = cx + .8: dcy = dcy + .009: cy = cy + dcy: If dcy = 0 Then dcy = -dcy
RotoZoom23d cx, cy, img&, i, 1, a: _Limit 240: _Display
Next
Swap start, fini: stepper = .02 * Sgn(fini - start)
If start = 0 Then If img& = imgHead& Then img& = imgTail& Else img& = imgHead&
Loop Until dcy > 2.50
Wend
Sub RotoZoom23d (centerX As Long, centerY As Long, Image As Long, xScale As Single, yScale As Single, DRotation As Single)
Dim As Single px(3), py(3), sinr, cosr ' thanks to James D Jarvis who fixed this on 2023/01/18
Dim As Long IW, IH, i, x2, y2
IW& = _Width(Image&): IH& = _Height(Image&)
px(0) = -IW& / 2 * xScale: py(0) = -IH& / 2 * yScale: px(1) = -IW& / 2 * xScale: py(1) = IH& / 2 * yScale
px(2) = IW& / 2 * xScale: py(2) = IH& / 2 * yScale: px(3) = IW& / 2 * xScale: py(3) = -IH& / 2 * yScale
sinr! = Sin(-0.01745329 * DRotation): cosr! = Cos(-0.01745329 * DRotation)
For i& = 0 To 3
x2& = (px(i&) * cosr! + sinr! * py(i&)) + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) + centerY
px(i&) = x2&: py(i&) = y2&
Next
_MapTriangle _Seamless(0, 0)-(0, IH& - 1)-(IW& - 1, IH& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MapTriangle _Seamless(0, 0)-(IW& - 1, 0)-(IW& - 1, IH& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub
bas and images in zip
Not a good round for predicting heads!
b = b + ...