Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CAN someone please get the graphics in this to work?
#3
Suggested changes/tweaks to the code below.  Be certain to read over the comments for the reasons for everything.

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)

'Note that DECLARE SUB as above isn't needed for QB64 programs


' 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)

'Note:  Change these to SHARED so the colors carry though the SUB
Dim Shared As _Unsigned Long PlayerColor, TapeColor, OxideTapeColor, RollerColor

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 = Input$(1) 'use of input$(1) stops endless loop and reduces CPU usage
Loop Until KeyPress <> ""

Cls
Print "Select Tape Length:"
Print "1) 10 minutes."
Print "2) 15 minutes."
Print "3) 30 minutes."
Print "4) 60 minutes."
Print "5) 90 minutes."
Print "6) 120 minutes."

Do
    KeyPress = Input$(1) 'use of input$(1) stops endless loop and reduces CPU usage
    Select Case KeyPress 'have length match actual input type length
        Case "1": TapeLength = 10
        Case "2": TapeLength = 15
        Case "3": TapeLength = 30
        Case "4": TapeLength = 60
        Case "5": TapeLength = 90
        Case "6": TapeLength = 120
    End Select
Loop Until TapeLength > 0

Cls
Print "Select Speed Mode (N: Normal, F: Fast, S: Slow, L: Long Play, E: Extra Long Play): "
Do
    KeyPress = Input$(1) 'again, swap to input$(1) to reduce loop CPU usage
    Select Case KeyPress 'add the lower case input values
        Case "N", "n": SpeedMode = "Normal"
        Case "F", "f": SpeedMode = "Fast"
        Case "S", "s": SpeedMode = "Slow"
        Case "L", "l": SpeedMode = "Long Play"
        Case "E", "e": SpeedMode = "Extra Long Play"
    End Select
Loop Until SpeedMode <> ""

Cls
Print "Choose Tape Type (1: Standard Brown, 2: Metal Oxide Red-Brown): "
Do
    KeyPress = Input$(1) 'you get the drill here by now
    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

    ' 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
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

    ' 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

    ' 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, 300), CurrentTapeColor, CurrentTapeColor

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

    ' 5?? Draw **animated tape strip moving through rollers**
    Line (300, 300)-(250, 150 + TapeWobble), CurrentTapeColor
    Line (250, 150 + TapeWobble)-(550, 150 + TapeWobble), CurrentTapeColor
    Line (550, 150 + TapeWobble)-(500, 300), CurrentTapeColor

    ' 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
Reply


Messages In This Thread
RE: CAN someone please get the graphics in this to work? - by SMcNeill - 05-07-2025, 11:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  simple 3d starfield & wireframe or vector graphics revisited madscijr 5 281 01-31-2026, 09:41 PM
Last Post: Pete
  Does _base64decode$ and _inflate$ work when used together? Dav 5 538 11-21-2025, 06:59 AM
Last Post: Pete
  Cursor is showing low in graphics screen PhilOfPerth 2 599 11-06-2024, 07:50 AM
Last Post: PhilOfPerth
  Even robocopy doesn't work krovit 3 968 08-15-2024, 11:36 AM
Last Post: mdijkens
  GetWindowTextW - can you get it to work? TerryRitchie 12 2,987 06-11-2024, 11:17 AM
Last Post: SpriggsySpriggs

Forum Jump:


Users browsing this thread: 1 Guest(s)