Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CAN someone please get the graphics in this to work?
#4
Here is my fix:
Code: (Select All)
' QB64 Phoenix Edition Cassette Recorder Simulator with Proper Alpha and Case-Sensitive Variables
DECLARE SUB DrawTapePlayer (LeftReel AS INTEGER, RightReel AS INTEGER, TapeWobble AS INTEGER, TapeType AS INTEGER, Angle AS SINGLE)

' Create high-resolution graphics window
Dim ScreenID As Long
ScreenID = _NewImage(800, 600, 32) ' 800x600 resolution, 32-bit color mode
Screen ScreenID
_AutoDisplay ' Enables graphics rendering

' Define colors with Alpha Channel (fully opaque)
Dim Shared PlayerColor As _Unsigned Long
Dim Shared TapeColor As _Unsigned Long
Dim Shared OxideTapeColor As _Unsigned Long
Dim Shared RollerColor As _Unsigned Long

PlayerColor = _RGBA32(50, 50, 50, 255) ' Dark gray for the player casing
TapeColor = _RGBA32(139, 69, 19, 255) ' Standard brown tape
OxideTapeColor = _RGBA32(160, 82, 45, 255) ' Reddish-brown oxide tape
RollerColor = _RGBA32(245, 245, 220, 255) ' Off-white rollers

Dim TapeLength As Integer
Dim SpeedMode As String
Dim TapeType As Integer
Dim LeftReel As Integer
Dim RightReel As Integer
Dim TapeWobble As Integer
Dim KeyPress As String
Dim Angle As Single

Cls
_PrintString (50, 50), "Welcome to the QB64 Cassette Recorder Simulator!"
_PrintString (50, 70), "Press any key to continue..."
Do
    KeyPress = InKey$
Loop Until KeyPress <> ""

Cls
_PrintString (50, 50), "Select Tape Length press 1-9 for 10 X's tape length: " ' fixed for user
Do
    KeyPress = InKey$
    If KeyPress >= "0" And KeyPress <= "9" Then TapeLength = Val(KeyPress) * 10
Loop Until TapeLength > 0

_PrintString (50, 70), "Select Speed Mode (N: Normal, F: Fast, S: Slow, L: Long Play, E: Extra Long Play): "
Do
    KeyPress = UCase$(InKey$) ' add ucase$
    Select Case KeyPress
        Case "N": SpeedMode = "Normal"
        Case "F": SpeedMode = "Fast"
        Case "S": SpeedMode = "Slow"
        Case "L": SpeedMode = "Long Play"
        Case "E": SpeedMode = "Extra Long Play"
    End Select
Loop Until SpeedMode <> ""

_PrintString (50, 90), "Choose Tape Type (1: Standard Brown, 2: Metal Oxide Red-Brown): "
Do
    KeyPress = InKey$
    If KeyPress = "1" Then TapeType = 1
    If KeyPress = "2" Then TapeType = 2
Loop Until TapeType > 0

Cls
_PrintString (50, 50), "Loading Tape..."
Sleep 2

' Initial reel sizes
LeftReel = 80
RightReel = 20
TapeWobble = 0
Angle = 0

For i = 1 To TapeLength * 5
    Cls
    DrawTapePlayer LeftReel, RightReel, TapeWobble, TapeType, Angle
    'Sleep 1  ' why????

    ' Simulate tape winding: left reel shrinks, right reel grows
    If LeftReel > 20 Then
        LeftReel = LeftReel - 1
        RightReel = RightReel + 1
    End If

    ' Simulate slight tape wobble
    TapeWobble = Int(Rnd * 4) - 2

    ' Increase rotation angle
    Angle = Angle + 5
    If Angle >= 360 Then Angle = 0
    _Display ' no blinking from CLS
    _Limit 10 ' smoother than sleep 1
Next

_PrintString (50, 550), "Playback Complete!"

Sub DrawTapePlayer (LeftReel As Integer, RightReel As Integer, TapeWobble As Integer, TapeType As Integer, Angle As Single)
    ' Select tape color
    Dim CurrentTapeColor As _Unsigned Long
    If TapeType = 1 Then
        CurrentTapeColor = TapeColor
    Else
        CurrentTapeColor = OxideTapeColor
    End If

    ' ? **Layer Rendering: Back-to-Front**

    ' 1?? Draw **player frame (boxy shape)**
    Line (100, 100)-(700, 500), PlayerColor, BF

    ' 5?? Draw **animated tape strip moving through rollers**
    Line (300 - LeftReel, 300)-(240, 150 + TapeWobble), CurrentTapeColor
    Line (250, 140 + TapeWobble)-(555, 140 + TapeWobble), CurrentTapeColor
    Line (560, 150 + TapeWobble)-(500 + RightReel, 300), CurrentTapeColor


    ' 3?? **Convert polar coordinates to rectilinear** for rotation effect
    Dim X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer
    X1 = 300 + Cos(Angle * 3.14159 / 180) * LeftReel
    Y1 = 300 + Sin(Angle * 3.14159 / 180) * LeftReel
    X2 = 500 + Cos(Angle * 3.14159 / 180) * RightReel
    Y2 = 300 + Sin(Angle * 3.14159 / 180) * RightReel

    ' 4?? Draw **reels (shrinking/growing with playback)**
    Circle (300, 300), LeftReel, CurrentTapeColor
    Paint (300, 310), CurrentTapeColor, CurrentTapeColor

    Circle (500, 300), RightReel, CurrentTapeColor
    Paint (500, 310), CurrentTapeColor, CurrentTapeColor


    ' 2?? Draw **rollers (off-white)**, dividing player into thirds
    Circle (250, 150), 10, RollerColor
    Paint (250, 150), RollerColor, RollerColor

    Circle (550, 150), 10, RollerColor
    Paint (550, 150), RollerColor, RollerColor

    ' 6?? **Graphical text overlay at the end** (to avoid interference)
    _PrintString (50, 520), "Left Reel Size: " + LTrim$(Str$(LeftReel))
    _PrintString (450, 520), "Right Reel Size: " + LTrim$(Str$(RightReel))
End Sub

So tape reels look more realistic!

update, not quite something needs to be fixed with length of tape and how long it runs as reels max out before sim ends.
b = b + ...
Reply


Messages In This Thread
RE: CAN someone please get the graphics in this to work? - by bplus - 05-07-2025, 12:17 PM



Users browsing this thread: 1 Guest(s)