Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smallish Games
#20
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!


Attached Files
.zip   Coin Flip Game.zip (Size: 928.86 KB / Downloads: 11)
b = b + ...
Reply


Messages In This Thread
Smallish Games - by bplus - 04-25-2022, 10:55 PM
Smallish Games - by bplus - 06-12-2022, 12:01 AM
RE: Smallish Games - by johnno56 - 06-12-2022, 07:43 AM
RE: Smallish Games - by bplus - 01-12-2023, 11:48 PM
RE: Smallish Games - by PhilOfPerth - 01-13-2023, 01:25 AM
RE: Smallish Games - by bplus - 01-13-2023, 03:08 AM
RE: Smallish Games - by bplus - 03-01-2023, 05:19 AM
RE: Smallish Games - by PhilOfPerth - 03-01-2023, 06:49 AM
RE: Smallish Games - by bplus - 03-01-2023, 03:54 PM
RE: Smallish Games - by bplus - 07-14-2023, 08:11 PM
RE: Smallish Games - by bplus - 07-14-2023, 08:27 PM
RE: Smallish Games - by mnrvovrfc - 07-14-2023, 09:47 PM
RE: Smallish Games - by bplus - 05-03-2024, 06:35 PM
RE: Smallish Games - by bplus - 05-30-2024, 12:57 PM
RE: Smallish Games - by JRace - 05-31-2024, 03:44 AM
RE: Smallish Games - by bplus - 05-31-2024, 10:07 AM
RE: Smallish Games - by bplus - 07-17-2024, 05:24 PM
RE: Smallish Games - by Pete - 07-17-2024, 06:51 PM
RE: Smallish Games - by bplus - 09-12-2024, 07:09 PM
RE: Smallish Games - by bplus - 09-13-2024, 09:47 AM



Users browsing this thread: 3 Guest(s)