Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CAN someone please get the graphics in this to work?
#1
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 PlayerColor AS _UNSIGNED LONG
DIM TapeColor AS _UNSIGNED LONG
DIM OxideTapeColor AS _UNSIGNED LONG
DIM 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 (10, 15, 30, 45, 60, 90, 120 minutes): "
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 = INKEY$
    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
   
    ' 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
CAN someone please get the graphics in this to work? - by Dragoncat - 05-07-2025, 11:03 AM



Users browsing this thread: 1 Guest(s)