Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
  Scrollers On Timers
Posted by: Hemulius - 08-30-2022, 11:02 AM - Forum: Programs - Replies (4)

Made some experiments with On Timer() and with the help of Terry Ritchie´s awesome tutorials it turned out quite graphical, so here are the results. Since there is no measured "update" based on passed time, you might want to adjust timer rates for your system. So far, program seems to function as expected but few questions remain. How much workload timers can actually carry? Is there technical limitations to expand use of timers, similarly that I´ve already used them?

Hope you have as much fun to play around with it, as I had writing it. More like a learning journey Smile
   

Code: (Select All)
_TITLE "Scrollers On Timers"
'Created by Hemulius Aug 2022 with QB64 Phoenix Edition version 3.0.0 x64
'
'Controls:
' Esc to quit
' Left mouse button to stop scroller
' Right mouse button to restore default speed
' Mouse wheel up and down to increase and decrease scrolling speed
' Mouse wheel button to set current speed as new default speed
'
'$static
OPTION BASE 0
OPTION _EXPLICIT
OPTION _EXPLICITARRAY
SCREEN _NEWIMAGE(640, 480, 32) ': _FULLSCREEN

COMMON SHARED system_stop AS LONG: system_stop& = &B0 'System running flag

TYPE software_surface_data 'Temporary surfaces for graphics creation
    background AS LONG
    ship AS LONG
    wave1 AS LONG
    wave2 AS LONG
    wave3 AS LONG
    wave4 AS LONG
    wave5 AS LONG
    beach AS LONG
    palm1 AS LONG
    palm2 AS LONG
    palm3 AS LONG
END TYPE

TYPE hardware_surface_data 'Hardware surfaces for drawing to screen
    background AS LONG
    ship AS LONG
    wave1 AS LONG
    wave2 AS LONG
    wave3 AS LONG
    wave4 AS LONG
    wave5 AS LONG
    beach AS LONG
    palm1 AS LONG
    palm2 AS LONG
    palm3 AS LONG
END TYPE

TYPE colordata '= _RGB32() values
    background1 AS LONG
    background2 AS LONG
    background3 AS LONG
    background4 AS LONG
    wave1 AS LONG
    wave2 AS LONG
    wave3 AS LONG
    wave4 AS LONG
    wave5 AS LONG
    beach AS LONG
    ship AS LONG
    palm AS LONG
END TYPE

TYPE parameterdata
    position AS SINGLE
    shipx AS SINGLE
    shipy AS SINGLE
    shipr AS INTEGER
    shipadd AS SINGLE
    wave1x AS SINGLE
    wave1y AS SINGLE
    wave1r AS INTEGER
    wave2x AS SINGLE
    wave2y AS SINGLE
    wave2r AS INTEGER
    wave3x AS SINGLE
    wave3y AS SINGLE
    wave3r AS INTEGER
    wave4x AS SINGLE
    wave4y AS SINGLE
    wave4r AS INTEGER
    wave5x AS SINGLE
    wave5y AS SINGLE
    wave5r AS INTEGER
    beachx AS SINGLE
    beachy AS SINGLE
    palm1x AS SINGLE
    palm2x AS SINGLE
    palm3x AS SINGLE
    palmy AS SINGLE
    speed AS SINGLE
    speed_default AS SINGLE
END TYPE

REDIM software_surface(3) AS software_surface_data
REDIM hardware_surface(3) AS hardware_surface_data
REDIM colors(3) AS colordata
REDIM parameters(3) AS parameterdata

REDIM scroller0_wavedata!(127) 'Wave patterns
REDIM scroller1_wavedata!(127)
REDIM scroller2_wavedata!(127)
REDIM scroller3_wavedata!(127)


'--------= START =--------
set_defaults: create_graphics
free_software_surfaces
_DISPLAYORDER _HARDWARE

DIM controls_timer: controls_timer = _FREETIMER
DIM scrolling_timer: scrolling_timer = _FREETIMER
DIM drawing_timer: drawing_timer = _FREETIMER

DIM controls_rate AS SINGLE: controls_rate! = 0.1000 'User interaction, decrease for less input lag
DIM scrolling_rate AS SINGLE: scrolling_rate! = 0.0100 'Modify values, increase to slow down
DIM drawing_rate AS SINGLE: drawing_rate! = 0.0010 'Draw graphics, increase to decreases frame rate

'Heart of the program pulsing at _rate!
ON TIMER(controls_timer, controls_rate!) controls
ON TIMER(scrolling_timer, scrolling_rate!) scrolling
ON TIMER(drawing_timer, drawing_rate!) drawing

TIMER(controls_timer) ON: TIMER(scrolling_timer) ON: TIMER(drawing_timer) ON

DO: _LIMIT 200: LOOP UNTIL system_stop& = &B1 'Main loop

TIMER(controls_timer) OFF: TIMER(scrolling_timer) OFF: TIMER(drawing_timer) OFF
TIMER(controls_timer) FREE: TIMER(scrolling_timer) FREE: TIMER(drawing_timer) FREE
free_hardware_surfaces
'---------= END =---------
SYSTEM


SUB controls
    SHARED parameters() AS parameterdata 'READ and WRITE parameters

    'Controls
    STATIC addspeed AS SINGLE: addspeed! = 0.0360026 'Speed change per mouse wheel turn
    STATIC kind_of_zero AS SINGLE: kind_of_zero! = 0.0000002 'To prevent glitches when scrolling is stopped at random time
    STATIC key_esc AS LONG: key_esc& = 27
    STATIC mouse_wheel_up AS LONG: mouse_wheel_up& = &B0
    STATIC mouse_wheel_down AS LONG: mouse_wheel_down& = &B0
    STATIC mouse_left_button AS LONG: mouse_left_button& = &B0 'Hold button to select over many
    STATIC mouse_right_button AS LONG: mouse_right_button& = &B0
    STATIC mouse_wheel_button AS LONG: mouse_wheel_button& = &B0
    STATIC mouse_yposition AS LONG: mouse_yposition& = 0 'Mouse Y coordinate

    IF _KEYDOWN(key_esc&) THEN system_stop& = &B1 'Esc to quit

    DO 'Read mouse
        mouse_yposition& = _MOUSEY
        IF _MOUSEWHEEL = -1 THEN mouse_wheel_up& = &B1
        IF _MOUSEWHEEL = 1 THEN mouse_wheel_down& = &B1
        IF _MOUSEBUTTON(1) THEN mouse_left_button& = &B1
        IF _MOUSEBUTTON(2) THEN mouse_right_button& = &B1
        IF _MOUSEBUTTON(3) THEN mouse_wheel_button& = &B1
    LOOP WHILE _MOUSEINPUT

    STATIC mouse_over_scroller AS INTEGER 'Determine mouse position
    IF mouse_yposition& < parameters(1).position! THEN
        mouse_over_scroller% = 0
    END IF
    IF (mouse_yposition& > parameters(1).position!) AND (mouse_yposition& < parameters(2).position!) THEN
        mouse_over_scroller% = 1
    END IF
    IF (mouse_yposition& > parameters(2).position!) AND (mouse_yposition& < parameters(3).position!) THEN
        mouse_over_scroller% = 2
    END IF
    IF (mouse_yposition& > parameters(3).position!) AND (mouse_yposition& < parameters(3).position! + parameters(1).position!) THEN
        mouse_over_scroller% = 3
    END IF

    IF mouse_left_button& = &B1 THEN 'Left to stop scroller
        parameters(mouse_over_scroller%).speed! = kind_of_zero!
        mouse_left_button& = &B0
    END IF

    IF mouse_right_button& = &B1 THEN 'Right to restore default speed
        parameters(mouse_over_scroller%).speed! = parameters(mouse_over_scroller%).speed_default!
        mouse_right_button& = &B0
    END IF

    IF mouse_wheel_button& = &B1 THEN 'Wheel button to set new default speed
        parameters(mouse_over_scroller%).speed_default! = parameters(mouse_over_scroller%).speed!
        mouse_wheel_button& = &B0
    END IF

    IF mouse_wheel_up& = &B1 THEN 'Wheel up to increase speed
        parameters(mouse_over_scroller%).speed! = parameters(mouse_over_scroller%).speed! + addspeed!
        mouse_wheel_up& = &B0
    END IF

    IF mouse_wheel_down& = &B1 THEN 'Wheel down to decrease speed
        parameters(mouse_over_scroller%).speed! = parameters(mouse_over_scroller%).speed! - addspeed!
        IF parameters(mouse_over_scroller%).speed! <= 0 THEN
            parameters(mouse_over_scroller%).speed! = kind_of_zero!
        END IF
        mouse_wheel_down& = &B0
    END IF
END SUB

SUB scrolling
    SHARED parameters() AS parameterdata 'READ and WRITE parameters

    SHARED scroller0_wavedata!()
    SHARED scroller1_wavedata!()
    SHARED scroller2_wavedata!()
    SHARED scroller3_wavedata!()

    STATIC waves_auto_speed AS SINGLE: waves_auto_speed! = 0.0380002
    STATIC left_limit AS SINGLE: left_limit! = -127.0 'Waves screen limitations
    STATIC right_limit AS SINGLE: right_limit! = 639.0
    STATIC last_index AS INTEGER: last_index% = 127 'Last index in wavedata array

    'Scrollers, using scroller 2 wavedata as common wave pattern
    STATIC scroller%
    FOR scroller% = 0 TO 3
        'Ship motion
        parameters(scroller%).shipx! = parameters(scroller%).shipx! - (parameters(scroller%).speed! / 2)
        IF parameters(scroller%).shipx! < -100 THEN parameters(scroller%).shipx! = right_limit!

        parameters(scroller%).shipy! = scroller2_wavedata!(parameters(scroller%).shipr%) + (parameters(scroller%).shipadd! + parameters(scroller%).position!)
        parameters(scroller%).shipr% = parameters(scroller%).shipr% - 1
        IF parameters(scroller%).shipr% < 0 THEN parameters(scroller%).shipr% = last_index%

        'Waves y motion, fixed y addition to place waves apart
        parameters(scroller%).wave1y! = scroller2_wavedata!(parameters(scroller%).wave1r%) + 40.0 + parameters(scroller%).position!
        parameters(scroller%).wave1r% = parameters(scroller%).wave1r% - 1
        IF parameters(scroller%).wave1r% < 0 THEN parameters(scroller%).wave1r% = last_index%

        parameters(scroller%).wave2y! = scroller2_wavedata!(parameters(scroller%).wave2r%) + 46.0 + parameters(scroller%).position!
        parameters(scroller%).wave2r% = parameters(scroller%).wave2r% - 1
        IF parameters(scroller%).wave2r% < 0 THEN parameters(scroller%).wave2r% = last_index%

        parameters(scroller%).wave3y! = scroller2_wavedata!(parameters(scroller%).wave3r%) + 56.0 + parameters(scroller%).position!
        parameters(scroller%).wave3r% = parameters(scroller%).wave3r% - 1
        IF parameters(scroller%).wave3r% < 0 THEN parameters(scroller%).wave3r% = last_index%

        parameters(scroller%).wave4y! = scroller2_wavedata!(parameters(scroller%).wave4r%) + 67.0 + parameters(scroller%).position!
        parameters(scroller%).wave4r% = parameters(scroller%).wave4r% - 1
        IF parameters(scroller%).wave4r% < 0 THEN parameters(scroller%).wave4r% = last_index%

        parameters(scroller%).wave5y! = scroller2_wavedata!(parameters(scroller%).wave5r%) + 80.0 + parameters(scroller%).position!
        parameters(scroller%).wave5r% = parameters(scroller%).wave5r% - 1
        IF parameters(scroller%).wave5r% < 0 THEN parameters(scroller%).wave5r% = last_index%

        'Waves x motion, fixed speed multiplyer to make each wave go faster than other
        parameters(scroller%).wave1x! = (parameters(scroller%).wave1x! - parameters(scroller%).speed!) - (waves_auto_speed! * 2)
        IF parameters(scroller%).wave1x! < left_limit! THEN parameters(scroller%).wave1x! = 0

        parameters(scroller%).wave2x! = (parameters(scroller%).wave2x! - parameters(scroller%).speed!) - (waves_auto_speed! * 4)
        IF parameters(scroller%).wave2x! < left_limit! THEN parameters(scroller%).wave2x! = 0

        parameters(scroller%).wave3x! = (parameters(scroller%).wave3x! - parameters(scroller%).speed!) - (waves_auto_speed! * 6)
        IF parameters(scroller%).wave3x! < left_limit! THEN parameters(scroller%).wave3x! = 0

        parameters(scroller%).wave4x! = (parameters(scroller%).wave4x! - parameters(scroller%).speed!) - (waves_auto_speed! * 8)
        IF parameters(scroller%).wave4x! < left_limit! THEN parameters(scroller%).wave4x! = 0

        parameters(scroller%).wave5x! = (parameters(scroller%).wave5x! - parameters(scroller%).speed!) - (waves_auto_speed! * 10)
        IF parameters(scroller%).wave5x! < left_limit! THEN parameters(scroller%).wave5x! = 0

        'Beach x motion
        parameters(scroller%).beachx! = parameters(scroller%).beachx! - parameters(scroller%).speed!
        IF parameters(scroller%).beachx! < left_limit! THEN parameters(scroller%).beachx! = 0

        'Palms x motion
        parameters(scroller%).palm1x! = parameters(scroller%).palm1x! - parameters(scroller%).speed!
        IF parameters(scroller%).palm1x! < left_limit! THEN parameters(scroller%).palm1x! = right_limit!

        parameters(scroller%).palm2x! = parameters(scroller%).palm2x! - parameters(scroller%).speed!
        IF parameters(scroller%).palm2x! < left_limit! THEN parameters(scroller%).palm2x! = right_limit!

        parameters(scroller%).palm3x! = parameters(scroller%).palm3x! - parameters(scroller%).speed!
        IF parameters(scroller%).palm3x! < left_limit! THEN parameters(scroller%).palm3x! = right_limit!
    NEXT
END SUB

SUB drawing
    SHARED hardware_surface() AS hardware_surface_data 'READ graphics
    SHARED parameters() AS parameterdata 'READ parameters

    STATIC index AS SINGLE: index! = 0
    STATIC value AS SINGLE: value! = 0
    STATIC x AS SINGLE: x! = 0
    STATIC y AS SINGLE: y! = 0
    STATIC tilesize AS SINGLE: tilesize! = 127
    STATIC tilecount AS SINGLE: tilecount! = 6 'Instead of 6, try 4 and add CLS after _DEST to draw partially
    value! = tilecount! * tilesize!
    _DEST 0 ': CLS

    STATIC scroller%
    FOR scroller% = 0 TO 3 'Draw scrollers

        FOR index! = 0 TO value! STEP tilesize!
            x! = index!
            y! = parameters(scroller%).position!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).background&
        NEXT

        x! = parameters(scroller%).shipx! 'Ship
        y! = parameters(scroller%).shipy!
        _PUTIMAGE (x!, y!), hardware_surface(scroller%).ship&

        FOR index! = 0 TO value! STEP tilesize! 'Waves
            x! = parameters(scroller%).wave1x! + index!
            y! = parameters(scroller%).wave1y!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).wave1&
        NEXT

        FOR index! = 0 TO value! STEP tilesize!
            x! = parameters(scroller%).wave2x! + index!
            y! = parameters(scroller%).wave2y!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).wave2&
        NEXT

        FOR index! = 0 TO value! STEP tilesize!
            x! = parameters(scroller%).wave3x! + index!
            y! = parameters(scroller%).wave3y!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).wave3&
        NEXT

        FOR index! = 0 TO value! STEP tilesize!
            x! = parameters(scroller%).wave4x! + index!
            y! = parameters(scroller%).wave4y!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).wave4&
        NEXT

        FOR index! = 0 TO value! STEP tilesize!
            x! = parameters(scroller%).wave5x! + index!
            y! = parameters(scroller%).wave5y!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).wave5&
        NEXT

        FOR index! = 0 TO value! STEP tilesize! 'Beach
            x! = parameters(scroller%).beachx! + index!
            y! = parameters(scroller%).beachy!
            _PUTIMAGE (x!, y!), hardware_surface(scroller%).beach&
        NEXT

        x! = parameters(scroller%).palm1x! 'Palms
        y! = parameters(scroller%).palmy!
        _PUTIMAGE (x!, y!), hardware_surface(scroller%).palm1&

        x! = parameters(scroller%).palm2x!
        y! = parameters(scroller%).palmy!
        _PUTIMAGE (x!, y!), hardware_surface(scroller%).palm2&

        x! = parameters(scroller%).palm3x!
        y! = parameters(scroller%).palmy!
        _PUTIMAGE (x!, y!), hardware_surface(scroller%).palm3&
    NEXT
    _DISPLAY
END SUB

SUB create_graphics
    SHARED colors() AS colordata 'READ colors
    SHARED software_surface() AS software_surface_data 'WRITE graphics

    SHARED scroller0_wavedata!()
    SHARED scroller1_wavedata!()
    SHARED scroller2_wavedata!()
    SHARED scroller3_wavedata!()

    STATIC palmtree%(137) 'Line drawing coordinates
    STATIC pirateship%(111)

    STATIC index AS SINGLE: index! = 0
    STATIC value AS SINGLE: value! = 0

    FOR index! = 0 TO 3
        software_surface(index!).background& = _NEWIMAGE(127, 100, 32) 'Backgrounds
    NEXT
    FOR index! = 0 TO 127
        FOR value! = 0 TO 16
            _DEST software_surface(0).background&: PSET (index!, value!), colors(0).background1&
            _DEST software_surface(1).background&: PSET (index!, value!), colors(1).background1&
            _DEST software_surface(2).background&: PSET (index!, value!), colors(2).background1&
            _DEST software_surface(3).background&: PSET (index!, value!), colors(3).background1&
        NEXT
    NEXT
    FOR index! = 0 TO 127
        FOR value! = 0 TO 16
            _DEST software_surface(0).background&: PSET (index!, value! + 16), colors(0).background2&
            _DEST software_surface(1).background&: PSET (index!, value! + 16), colors(1).background2&
            _DEST software_surface(2).background&: PSET (index!, value! + 16), colors(2).background2&
            _DEST software_surface(3).background&: PSET (index!, value! + 16), colors(3).background2&
        NEXT
    NEXT
    FOR index! = 0 TO 127
        FOR value! = 0 TO 16
            _DEST software_surface(0).background&: PSET (index!, value! + 32), colors(0).background3&
            _DEST software_surface(1).background&: PSET (index!, value! + 32), colors(1).background3&
            _DEST software_surface(2).background&: PSET (index!, value! + 32), colors(2).background3&
            _DEST software_surface(3).background&: PSET (index!, value! + 32), colors(3).background3&
        NEXT
    NEXT
    FOR index! = 0 TO 127
        FOR value! = 0 TO 16
            _DEST software_surface(0).background&: PSET (index!, value! + 48), colors(0).background4&
            _DEST software_surface(1).background&: PSET (index!, value! + 48), colors(1).background4&
            _DEST software_surface(2).background&: PSET (index!, value! + 48), colors(2).background4&
            _DEST software_surface(3).background&: PSET (index!, value! + 48), colors(3).background4&
        NEXT
    NEXT

    FOR index! = 0 TO 3 'Ships
        software_surface(index!).ship& = _NEWIMAGE(70, 50, 32)
    NEXT
    RESTORE pirateshipdata: FOR index! = 0 TO 111: READ value!: pirateship%(index!) = value!: NEXT

    _DEST software_surface(0).ship&: COLOR colors(0).ship&: LINE (pirateship%(0), pirateship%(1))-(pirateship%(2), pirateship%(3))
    _DEST software_surface(1).ship&: COLOR colors(1).ship&: LINE (pirateship%(0), pirateship%(1))-(pirateship%(2), pirateship%(3))
    _DEST software_surface(2).ship&: COLOR colors(2).ship&: LINE (pirateship%(0), pirateship%(1))-(pirateship%(2), pirateship%(3))
    _DEST software_surface(3).ship&: COLOR colors(3).ship&: LINE (pirateship%(0), pirateship%(1))-(pirateship%(2), pirateship%(3))

    FOR index! = 4 TO 111 STEP 2
        _DEST software_surface(0).ship&: LINE -(pirateship%(index!), pirateship%(index! + 1))
        _DEST software_surface(1).ship&: LINE -(pirateship%(index!), pirateship%(index! + 1))
        _DEST software_surface(2).ship&: LINE -(pirateship%(index!), pirateship%(index! + 1))
        _DEST software_surface(3).ship&: LINE -(pirateship%(index!), pirateship%(index! + 1))
    NEXT

    _DEST software_surface(0).ship&: PAINT (16, 26): PAINT (36, 8): PAINT (36, 25): PAINT (36, 39): PAINT (52, 20)
    _DEST software_surface(1).ship&: PAINT (16, 26): PAINT (36, 8): PAINT (36, 25): PAINT (36, 39): PAINT (52, 20)
    _DEST software_surface(2).ship&: PAINT (16, 26): PAINT (36, 8): PAINT (36, 25): PAINT (36, 39): PAINT (52, 20)
    _DEST software_surface(3).ship&: PAINT (16, 26): PAINT (36, 8): PAINT (36, 25): PAINT (36, 39): PAINT (52, 20)

    pirateshipdata: '0-3=line, 4-103=line-x,y pairs
    DATA 60,42,23,42,11,34,0,28,4,28,23,36,35,36,35,32,28,33,26,26,28,15,35,14,35,12,32,12,30,10,29,8,23,20,24,34
    DATA 17,29,6,27,29,6,31,2,35,2,35,0,36,0,36,2,43,2,42,7,43,11,36,12,36,14,44,13,42,22,44,33,36,32,36,36,48,36
    DATA 50,33,54,33,54,29,47,29,45,19,48,6,54,6,54,2,55,2,55,6,62,4,60,17,62,30,55,29,55,33,67,32,68,34,66,39,60,42

    'Waves
    FOR index! = 0 TO 3
        software_surface(index!).wave1& = _NEWIMAGE(127, 40, 32)
        software_surface(index!).wave2& = _NEWIMAGE(127, 40, 32)
        software_surface(index!).wave3& = _NEWIMAGE(127, 40, 32)
        software_surface(index!).wave4& = _NEWIMAGE(127, 40, 32)
        software_surface(index!).wave5& = _NEWIMAGE(127, 40, 32)
    NEXT
    FOR index! = 0 TO 127 'Scroller 0 waves
        FOR value! = scroller0_wavedata!(index!) TO 40
            _DEST software_surface(0).wave1&: PSET (index!, value!), colors(0).wave1&
            _DEST software_surface(0).wave2&: PSET (index!, value!), colors(0).wave2&
            _DEST software_surface(0).wave3&: PSET (index!, value!), colors(0).wave3&
            _DEST software_surface(0).wave4&: PSET (index!, value!), colors(0).wave4&
            _DEST software_surface(0).wave5&: PSET (index!, value!), colors(0).wave5&
        NEXT
    NEXT
    FOR index! = 0 TO 127 'Scroller 1 waves
        FOR value! = scroller1_wavedata!(index!) TO 40
            _DEST software_surface(1).wave1&: PSET (index!, value!), colors(1).wave1&
            _DEST software_surface(1).wave2&: PSET (index!, value!), colors(1).wave2&
            _DEST software_surface(1).wave3&: PSET (index!, value!), colors(1).wave3&
            _DEST software_surface(1).wave4&: PSET (index!, value!), colors(1).wave4&
            _DEST software_surface(1).wave5&: PSET (index!, value!), colors(1).wave5&
        NEXT
    NEXT
    FOR index! = 0 TO 127 'Scroller 2 waves
        FOR value! = scroller2_wavedata!(index!) TO 40
            _DEST software_surface(2).wave1&: PSET (index!, value!), colors(2).wave1&
            _DEST software_surface(2).wave2&: PSET (index!, value!), colors(2).wave2&
            _DEST software_surface(2).wave3&: PSET (index!, value!), colors(2).wave3&
            _DEST software_surface(2).wave4&: PSET (index!, value!), colors(2).wave4&
            _DEST software_surface(2).wave5&: PSET (index!, value!), colors(2).wave5&
        NEXT
    NEXT
    FOR index! = 0 TO 127 'Scroller 3 waves
        FOR value! = scroller3_wavedata!(index!) TO 40
            _DEST software_surface(3).wave1&: PSET (index!, value!), colors(3).wave1&
            _DEST software_surface(3).wave2&: PSET (index!, value!), colors(3).wave2&
            _DEST software_surface(3).wave3&: PSET (index!, value!), colors(3).wave3&
            _DEST software_surface(3).wave4&: PSET (index!, value!), colors(3).wave4&
            _DEST software_surface(3).wave5&: PSET (index!, value!), colors(3).wave5&
        NEXT
    NEXT

    FOR index! = 0 TO 3 'Beaches
        software_surface(index!).beach& = _NEWIMAGE(127, 40, 32)
    NEXT
    FOR index! = 0 TO 127
        FOR value! = scroller1_wavedata!(index!) TO 40 'Each beach is scroller1 type of wavedata
            _DEST software_surface(0).beach&: PSET (index!, value!), colors(0).beach&
            _DEST software_surface(1).beach&: PSET (index!, value!), colors(1).beach&
            _DEST software_surface(2).beach&: PSET (index!, value!), colors(2).beach&
            _DEST software_surface(3).beach&: PSET (index!, value!), colors(3).beach&
        NEXT
    NEXT

    FOR index! = 0 TO 3 'Palmtrees
        software_surface(index!).palm1& = _NEWIMAGE(127, 115, 32)
        software_surface(index!).palm2& = _NEWIMAGE(127, 115, 32)
        software_surface(index!).palm3& = _NEWIMAGE(127, 115, 32)
    NEXT
    RESTORE palmtreedata: FOR index! = 0 TO 137: READ value!: palmtree%(index!) = value!: NEXT

    _DEST software_surface(0).palm1&: COLOR colors(0).palm&: LINE (palmtree%(0), palmtree%(1))-(palmtree%(2), palmtree%(3))
    _DEST software_surface(1).palm1&: COLOR colors(1).palm&: LINE (palmtree%(0), palmtree%(1))-(palmtree%(2), palmtree%(3))
    _DEST software_surface(2).palm1&: COLOR colors(2).palm&: LINE (palmtree%(0), palmtree%(1))-(palmtree%(2), palmtree%(3))
    _DEST software_surface(3).palm1&: COLOR colors(3).palm&: LINE (palmtree%(0), palmtree%(1))-(palmtree%(2), palmtree%(3))

    FOR index! = 4 TO 136 STEP 2
        _DEST software_surface(0).palm1&: LINE -(palmtree%(index!), palmtree%(index! + 1))
        _DEST software_surface(1).palm1&: LINE -(palmtree%(index!), palmtree%(index! + 1))
        _DEST software_surface(2).palm1&: LINE -(palmtree%(index!), palmtree%(index! + 1))
        _DEST software_surface(3).palm1&: LINE -(palmtree%(index!), palmtree%(index! + 1))
    NEXT

    _DEST software_surface(0).palm1&: PAINT (35, 110)
    _DEST software_surface(1).palm1&: PAINT (35, 110)
    _DEST software_surface(2).palm1&: PAINT (35, 110)
    _DEST software_surface(3).palm1&: PAINT (35, 110)

    _DEST software_surface(0).palm2&: _PUTIMAGE (127, 0)-(0, 115), software_surface(0).palm1& 'Palm 2 is flipped to lean left
    _DEST software_surface(0).palm3&: _PUTIMAGE (10, 20)-(127, 115), software_surface(0).palm1& 'Palm 3 is resized

    _DEST software_surface(1).palm2&: _PUTIMAGE (127, 0)-(0, 115), software_surface(1).palm1&
    _DEST software_surface(1).palm3&: _PUTIMAGE (20, 25)-(127, 115), software_surface(1).palm1&

    _DEST software_surface(2).palm2&: _PUTIMAGE (127, 0)-(0, 115), software_surface(2).palm1&
    _DEST software_surface(2).palm3&: _PUTIMAGE (12, 15)-(127, 115), software_surface(2).palm1&

    _DEST software_surface(3).palm2&: _PUTIMAGE (127, 0)-(0, 115), software_surface(3).palm1&
    _DEST software_surface(3).palm3&: _PUTIMAGE (18, 30)-(127, 115), software_surface(3).palm1&

    palmtreedata: '0-3=line, 4-137=line-x,y pairs
    DATA 30,113,28,104,26,91,26,72,31,51,39,34,26,35,26,29,21,37,12,41,12,34,8,42,0,44,1,33,8,24,15,20,28,20,35,22,28,15,33,13,24,12,20,8,22
    DATA 6,14,4,12,2,23,0,35,3,40,9,43,20,48,10,52,6,62,4,66,5,60,10,54,11,58,13,54,17,50,17,52,19,50,22,60,18,68,16,77,18,84,24,83,28,77,28
    DATA 70,22,72,29,65,29,60,25,60,29,51,31,65,36,73,43,75,50,74,58,70,64,65,59,64,45,60,51,55,46,56,39,52,42,44,34,37,54,35,79,38,97,43,113,30,113
END SUB

SUB set_defaults
    SHARED colors() AS colordata 'WRITE values
    SHARED parameters() AS parameterdata 'WRITE values

    SHARED scroller0_wavedata!()
    SHARED scroller1_wavedata!()
    SHARED scroller2_wavedata!()
    SHARED scroller3_wavedata!()

    STATIC index AS SINGLE: index! = 0
    STATIC value AS SINGLE: value! = 0

    colors(0).background1& = _RGB32(238, 61, 121) 'Scroller 0 colors
    colors(0).background2& = _RGB32(239, 82, 119)
    colors(0).background3& = _RGB32(246, 120, 117)
    colors(0).background4& = _RGB32(249, 146, 111)
    colors(0).wave1& = _RGB32(0, 138, 162)
    colors(0).wave2& = _RGB32(0, 155, 170)
    colors(0).wave3& = _RGB32(0, 183, 197)
    colors(0).wave4& = _RGB32(46, 197, 215)
    colors(0).wave5& = _RGB32(115, 209, 221)
    colors(0).beach& = _RGB32(107, 11, 59)
    colors(0).ship& = colors(0).wave1&
    colors(0).palm& = colors(0).beach&

    colors(1).background1& = _RGB32(86, 90, 255) 'Scroller 1 colors
    colors(1).background2& = _RGB32(97, 100, 255)
    colors(1).background3& = _RGB32(108, 111, 255)
    colors(1).background4& = _RGB32(118, 121, 255)
    colors(1).wave1& = _RGB32(13, 38, 110)
    colors(1).wave2& = _RGB32(15, 45, 125)
    colors(1).wave3& = _RGB32(17, 58, 139)
    colors(1).wave4& = _RGB32(19, 72, 168)
    colors(1).wave5& = _RGB32(21, 87, 191)
    colors(1).beach& = _RGB32(0, 25, 124)
    colors(1).ship& = colors(1).wave1&
    colors(1).palm& = colors(1).beach&

    colors(2).background1& = _RGB32(137, 173, 113) 'Scroller 2 colors
    colors(2).background2& = _RGB32(113, 187, 137)
    colors(2).background3& = _RGB32(88, 202, 160)
    colors(2).background4& = _RGB32(63, 217, 184)
    colors(2).wave1& = _RGB32(15, 135, 221)
    colors(2).wave2& = _RGB32(39, 146, 221)
    colors(2).wave3& = _RGB32(64, 166, 221)
    colors(2).wave4& = _RGB32(89, 186, 221)
    colors(2).wave5& = _RGB32(114, 206, 221)
    colors(2).beach& = _RGB32(10, 82, 91)
    colors(2).ship& = colors(2).wave1&
    colors(2).palm& = colors(2).beach&

    colors(3).background1& = _RGB32(93, 55, 218) 'Scroller 3 colors
    colors(3).background2& = _RGB32(112, 58, 201)
    colors(3).background3& = _RGB32(126, 61, 181)
    colors(3).background4& = _RGB32(138, 62, 175)
    colors(3).wave1& = _RGB32(12, 88, 189)
    colors(3).wave2& = _RGB32(19, 99, 190)
    colors(3).wave3& = _RGB32(20, 116, 197)
    colors(3).wave4& = _RGB32(26, 144, 214)
    colors(3).wave5& = _RGB32(35, 169, 221)
    colors(3).beach& = _RGB32(75, 28, 96)
    colors(3).ship& = colors(3).wave1&
    colors(3).palm& = colors(3).beach&

    parameters(0).position! = 0.0 'Scroller 0 parameters, top left y position
    parameters(0).shipx! = 510.0
    parameters(0).shipy! = 0.0
    parameters(0).shipr% = 122 'R value is starting index in wavedata
    parameters(0).shipadd! = 9.0 'Ship fixed y addition so bottom of the ship stay below the lowest point of wave
    parameters(0).wave1x! = 0.0
    parameters(0).wave1y! = 0.0
    parameters(0).wave1r% = 0
    parameters(0).wave2x! = 0.0
    parameters(0).wave2y! = 0.0
    parameters(0).wave2r% = 5
    parameters(0).wave3x! = 0.0
    parameters(0).wave3y! = 0.0
    parameters(0).wave3r% = 10
    parameters(0).wave4x! = 0.0
    parameters(0).wave4y! = 0.0
    parameters(0).wave4r% = 15
    parameters(0).wave5x! = 0.0
    parameters(0).wave5y! = 0.0
    parameters(0).wave5r% = 20
    parameters(0).beachx! = 0.0
    parameters(0).beachy! = 100.0 + parameters(0).position!
    parameters(0).palm1x! = 180.0
    parameters(0).palm2x! = -40.0
    parameters(0).palm3x! = 450.0
    parameters(0).palmy! = 8 + parameters(0).position!
    parameters(0).speed! = 0.3360026
    parameters(0).speed_default! = 0.7380004

    parameters(1).position! = 120.0 'Scroller 1 parameters
    parameters(1).shipx! = 470.0
    parameters(1).shipy! = 0.0
    parameters(1).shipr% = 20
    parameters(1).shipadd! = 5.0
    parameters(1).wave1x! = 0.0
    parameters(1).wave1y! = 0.0
    parameters(1).wave1r% = 25
    parameters(1).wave2x! = 0.0
    parameters(1).wave2y! = 0.0
    parameters(1).wave2r% = 30
    parameters(1).wave3x! = 0.0
    parameters(1).wave3y! = 0.0
    parameters(1).wave3r% = 35
    parameters(1).wave4x! = 0.0
    parameters(1).wave4y! = 0.0
    parameters(1).wave4r% = 40
    parameters(1).wave5x! = 0.0
    parameters(1).wave5y! = 0.0
    parameters(1).wave5r% = 45
    parameters(1).beachx! = 0.0
    parameters(1).beachy! = 100.0 + parameters(1).position!
    parameters(1).palm1x! = 380.0
    parameters(1).palm2x! = 60.0
    parameters(1).palm3x! = 540.0
    parameters(1).palmy! = 3 + parameters(1).position!
    parameters(1).speed! = 0.3360026
    parameters(1).speed_default! = 0.8360006

    parameters(2).position! = 240.0 'Scroller 2 parameters
    parameters(2).shipx! = 360.0
    parameters(2).shipy! = 0.0
    parameters(2).shipr% = 45
    parameters(2).shipadd! = 11.0
    parameters(2).wave1x! = 0.0
    parameters(2).wave1y! = 0.0
    parameters(2).wave1r% = 50
    parameters(2).wave2x! = 0.0
    parameters(2).wave2y! = 0.0
    parameters(2).wave2r% = 55
    parameters(2).wave3x! = 0.0
    parameters(2).wave3y! = 0.0
    parameters(2).wave3r% = 60
    parameters(2).wave4x! = 0.0
    parameters(2).wave4y! = 0.0
    parameters(2).wave4r% = 65
    parameters(2).wave5x! = 0.0
    parameters(2).wave5y! = 0.0
    parameters(2).wave5r% = 70
    parameters(2).beachx! = 0.0
    parameters(2).beachy! = 100.0 + parameters(2).position!
    parameters(2).palm1x! = 520.0
    parameters(2).palm2x! = 195.0
    parameters(2).palm3x! = 10.0
    parameters(2).palmy! = 6 + parameters(2).position!
    parameters(2).speed! = 0.3360026
    parameters(2).speed_default! = 1.0000010

    parameters(3).position! = 360.0 'Scroller 3 parameters
    parameters(3).shipx! = 410.0
    parameters(3).shipy! = 0.0
    parameters(3).shipr% = 70
    parameters(3).shipadd! = 12.0
    parameters(3).wave1x! = 0.0
    parameters(3).wave1y! = 0.0
    parameters(3).wave1r% = 75
    parameters(3).wave2x! = 0.0
    parameters(3).wave2y! = 0.0
    parameters(3).wave2r% = 80
    parameters(3).wave3x! = 0.0
    parameters(3).wave3y! = 0.0
    parameters(3).wave3r% = 85
    parameters(3).wave4x! = 0.0
    parameters(3).wave4y! = 0.0
    parameters(3).wave4r% = 90
    parameters(3).wave5x! = 0.0
    parameters(3).wave5y! = 0.0
    parameters(3).wave5r% = 95
    parameters(3).beachx! = 0.0
    parameters(3).beachy! = 100.0 + parameters(3).position!
    parameters(3).palm1x! = 500.0
    parameters(3).palm2x! = 198.0
    parameters(3).palm3x! = 302.0
    parameters(3).palmy! = 11 + parameters(3).position!
    parameters(3).speed! = 0.3360026
    parameters(3).speed_default! = 1.1100010

    'Waves data
    RESTORE wave0: FOR index! = 0 TO 127: READ value!: value! = value! + 0.0000002: scroller0_wavedata!(index!) = value!: NEXT
    RESTORE wave1: FOR index! = 0 TO 127: READ value!: value! = value! + 0.0000002: scroller1_wavedata!(index!) = value!: NEXT
    RESTORE wave2: FOR index! = 0 TO 127: READ value!: value! = value! + 0.0000002: scroller2_wavedata!(index!) = value!: NEXT
    RESTORE wave3: FOR index! = 0 TO 127: READ value!: value! = value! + 0.0000002: scroller3_wavedata!(index!) = value!: NEXT

    wave0: DATA 2,3,3,4,5,6,6,6,7,7,7,8,8,8,8,8,8,8,8,8,8,7,7,7,6,6,6,5,6,7,7,8,8,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,8,8,7,7,6,5,4,4,4,5,6,6,6,7,7,7,8,8,8,8,8,8,8,8,8,8,7,7,7,6,6,6,5,4,3,2,1,2,3,3,4,5,6,6,6,7,7,7,8,8,8,8,8,8,8,8,8,8,7,7,7,6,6,6,5,4,3,3,1
    wave1: DATA 4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4
    wave2: DATA 8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,9,9,9,9,8,8,8,7,7,7,6,5,5,4,3,3,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8
    wave3: DATA 3,4,4,5,5,6,6,7,8,8,8,9,9,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,10,10,10,10,9,9,8,8,7,7,5,5,3,1,0,1,2,3,4,4,5,5,6,6,7,8,8,8,9,9,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,10,10,10,10,9,9,8,8,7,7,5,5,3,1,0,1,2
END SUB

SUB free_software_surfaces
    SHARED software_surface() AS software_surface_data 'FREE
    SHARED hardware_surface() AS hardware_surface_data 'WRITE copy of surfaces
    STATIC scroller%

    FOR scroller% = 0 TO 3 'Copy all software_surface() arrays to videohardware handles
        hardware_surface(scroller%).background& = _COPYIMAGE(software_surface(scroller%).background&, 33)
        hardware_surface(scroller%).ship& = _COPYIMAGE(software_surface(scroller%).ship&, 33)
        hardware_surface(scroller%).wave1& = _COPYIMAGE(software_surface(scroller%).wave1&, 33)
        hardware_surface(scroller%).wave2& = _COPYIMAGE(software_surface(scroller%).wave2&, 33)
        hardware_surface(scroller%).wave3& = _COPYIMAGE(software_surface(scroller%).wave3&, 33)
        hardware_surface(scroller%).wave4& = _COPYIMAGE(software_surface(scroller%).wave4&, 33)
        hardware_surface(scroller%).wave5& = _COPYIMAGE(software_surface(scroller%).wave5&, 33)
        hardware_surface(scroller%).beach& = _COPYIMAGE(software_surface(scroller%).beach&, 33)
        hardware_surface(scroller%).palm1& = _COPYIMAGE(software_surface(scroller%).palm1&, 33)
        hardware_surface(scroller%).palm2& = _COPYIMAGE(software_surface(scroller%).palm2&, 33)
        hardware_surface(scroller%).palm3& = _COPYIMAGE(software_surface(scroller%).palm3&, 33)
    NEXT

    FOR scroller% = 0 TO 3 'Free software surfaces
        _FREEIMAGE software_surface(scroller%).background&
        _FREEIMAGE software_surface(scroller%).ship&
        _FREEIMAGE software_surface(scroller%).wave1&
        _FREEIMAGE software_surface(scroller%).wave2&
        _FREEIMAGE software_surface(scroller%).wave3&
        _FREEIMAGE software_surface(scroller%).wave4&
        _FREEIMAGE software_surface(scroller%).wave5&
        _FREEIMAGE software_surface(scroller%).beach&
        _FREEIMAGE software_surface(scroller%).palm1&
        _FREEIMAGE software_surface(scroller%).palm2&
        _FREEIMAGE software_surface(scroller%).palm3&
    NEXT
END SUB

SUB free_hardware_surfaces
    SHARED hardware_surface() AS hardware_surface_data 'FREE
    STATIC scroller%
    FOR scroller% = 0 TO 3
        _FREEIMAGE hardware_surface(scroller%).background&
        _FREEIMAGE hardware_surface(scroller%).ship&
        _FREEIMAGE hardware_surface(scroller%).wave1&
        _FREEIMAGE hardware_surface(scroller%).wave2&
        _FREEIMAGE hardware_surface(scroller%).wave3&
        _FREEIMAGE hardware_surface(scroller%).wave4&
        _FREEIMAGE hardware_surface(scroller%).wave5&
        _FREEIMAGE hardware_surface(scroller%).beach&
        _FREEIMAGE hardware_surface(scroller%).palm1&
        _FREEIMAGE hardware_surface(scroller%).palm2&
        _FREEIMAGE hardware_surface(scroller%).palm3&
    NEXT
END SUB

Print this item

  Name of variables: an issue
Posted by: TempodiBasic - 08-30-2022, 06:12 AM - Forum: Repo Discussion - Replies (12)

Hi friends
about naming variable I find a little issue

the duplicating a name has a different behaviour of Parser depending from the way you do this.
Please select, copy, paste the code below into IDE

Code: (Select All)
Type XXX
    a As Integer
    b As Long
    S As String * 1
End Type

Dim Shared Xpos As XXX

Dim Xpos&

Dim Xpos as long

As you can see, you can declare an UDT and with the same name a variable with suffix (or without suffix for single type data), in the while if you try to do the same thing using the explicit type definition with AS DATATYPE you get a name alreadu used error.

In QBasic the suffix is a part of the name of the variable so Xpos$, Xpos% and Xpos# are 3 different variables, moreover an array and a variable can have the same name.
At a first glance I can suppose that a different way to manage variables with suffix and variable without it is the radix of this issue.

What is the official position about name variables following Qbasic track?

Print this item

  Sendkey Keyboard
Posted by: euklides - 08-30-2022, 05:59 AM - Forum: Help Me! - Replies (2)

Hello

Is there a way in QB64 to simulate the sendkey function (send characters to the keyboard)  ???

This sendkey$ command exists for instance in Visual Basic Excel/Word...

Print this item

  Large numbers
Posted by: james2464 - 08-29-2022, 08:28 PM - Forum: Help Me! - Replies (9)

I'm working on a (purely academic) math exercise that involves a 12 digit integer...I was planning to use 'long' integers but that seems to be limited to smaller numbers.

I assumed long integers could handle such a number, but that apparently isn't the case.   Is scientific notation the only format for integers at these values?

Print this item

  5 Letter Hangman
Posted by: SierraKen - 08-29-2022, 06:17 AM - Forum: Programs - Replies (15)

After playing the 4 Letter Hangman for awhile, I figured out that it was getting pretty easy. So tonight I decided to make a 5 letter version. I found a list online of 5 letter words, like I did with the 4 letter one at one time. Then I made an app that automatically makes the DATA statements for the list. This one chooses from 711 5-letter words. I also added some sky color. Everything else is the same, just one more letter than the other one. Also, as I did with the 4 letter one, I added the LCASE$ command so you don't have to worry about upper or lower case letters, it converts it all to lower case. 


[Image: 5-Letter-Hangman-by-Sierra-Ken.jpg]



Code: (Select All)
'5 Letter Hangman by SierraKen - August 28, 2022.
'The game chooses between 711 5-letter words.

_Title "5 Letter Hangman by Sierraken"
start:
Cls
Screen _NewImage(800, 600, 32)

For y = 0 To 400
    c = c + .5
    Line (0, y)-(800, y), _RGB32(0, 0, c)
Next y
c = 0
Line (0, 400)-(800, 400), _RGB32(255, 255, 255)
Line (600, 400)-(600, 100), _RGB32(255, 255, 255)
Line (600, 100)-(400, 100), _RGB32(255, 255, 255)
Line (400, 100)-(400, 180), _RGB32(255, 255, 255)

For lines = 303 To 503 Step 50
    Line (lines, 500)-(lines + 10, 500), _RGB32(255, 255, 255)
Next lines
Randomize Timer
word = Int(Rnd * 711) + 1
For w = 1 To word - 1
    Read w$
Next w
Read word$
letter1$ = Mid$(word$, 1, 1)
letter2$ = Mid$(word$, 2, 1)
letter3$ = Mid$(word$, 3, 1)
letter4$ = Mid$(word$, 4, 1)
letter5$ = Mid$(word$, 5, 1)

letter = 0: oldletter = 0: one = 0: two = 0: three = 0: four = 0: five = 0
mistake = 0
go:
Do
    _Limit 20
    a$ = InKey$
    If a$ <> "" Then GoTo continue:
Loop

continue:
a$ = LCase$(a$)
If a$ = Chr$(27) Then End
oldletter = letter
If a$ = letter1$ Then
    _PrintString (305, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    one = one + 1
    If one = 1 Then letter = letter + 1
    If letter = 5 Then GoTo won:
End If
If a$ = letter2$ Then
    _PrintString (355, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    two = two + 1
    If two = 1 Then letter = letter + 1
    If letter = 5 Then GoTo won:
End If
If a$ = letter3$ Then
    _PrintString (405, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    three = three + 1
    If three = 1 Then letter = letter + 1
    If letter = 5 Then GoTo won:
End If
If a$ = letter4$ Then
    _PrintString (455, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    four = four + 1
    If four = 1 Then letter = letter + 1
    If letter = 5 Then GoTo won:
End If
If a$ = letter5$ Then
    _PrintString (505, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    five = five + 1
    If five = 1 Then letter = letter + 1
    If letter = 5 Then GoTo won:
End If


If oldletter <> letter Then GoTo go:

mistake = mistake + 1

'Head
If mistake = 1 Then
    Circle (400, 200), 20, _RGB32(255, 255, 255)
    _PrintString (50, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Body
If mistake = 2 Then
    Line (400, 220)-(400, 300), _RGB32(255, 255, 255)
    _PrintString (75, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Left Arm
If mistake = 3 Then
    Line (400, 240)-(375, 220), _RGB32(255, 255, 255)
    _PrintString (100, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Right Arm
If mistake = 4 Then
    Line (400, 240)-(425, 220), _RGB32(255, 255, 255)
    _PrintString (125, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Left Leg
If mistake = 5 Then
    Line (400, 300)-(370, 330), _RGB32(255, 255, 255)
    _PrintString (150, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Right Leg
If mistake = 6 Then
    Line (400, 300)-(430, 330), _RGB32(255, 255, 255)
    _PrintString (50, 475), a$
    Sound 200, .5
    Sound 600, .5
End If

'Eyes
If mistake = 7 Then
    Circle (390, 190), 3, _RGB32(255, 255, 255)
    Circle (410, 190), 3, _RGB32(255, 255, 255)
    _PrintString (75, 475), a$
    Sound 200, .5
    Sound 600, .5
End If

'Nose
If mistake = 8 Then
    Circle (400, 200), 3, _RGB32(255, 255, 255)
    _PrintString (100, 475), a$
    Sound 200, .5
    Sound 600, .5
End If

'Mouth
If mistake = 9 Then
    Circle (400, 212), 8, _RGB32(255, 255, 255), , , .5
    _PrintString (125, 475), a$
    For snd = 700 To 100 Step -50
        Sound snd, .5
    Next snd
    _PrintString (305, 480), letter1$
    _PrintString (355, 480), letter2$
    _PrintString (405, 480), letter3$
    _PrintString (455, 480), letter4$
    _PrintString (505, 480), letter5$
    _PrintString (305, 415), "You Lose!"
    Locate 29, 38: Input "Again (Y/N)"; ag$
    If Mid$(ag$, 1, 1) = "y" Or Mid$(ag$, 1, 1) = "Y" Then
        Restore
        GoTo start:
    End If
    End
End If
GoTo go:

won:
_PrintString (305, 415), "You Win!"
Locate 29, 38: Input "Again (Y/N)"; ag$
If Mid$(ag$, 1, 1) = "y" Or Mid$(ag$, 1, 1) = "Y" Then
    Restore
    GoTo start:
End If
End

Data abuse,adult,agent,anger,apple,award,basis,beach,birth,block,blood
Data blood,board,brain,bread,break,brown,buyer,cause,chain,chair,chest
Data chest,chief,child,china,claim,class,clock,coach,coast,court,cover
Data cover,cream,crime,cross,crowd,crown,cycle,dance,death,depth,doubt
Data doubt,draft,drama,dream,dress,drink,drive,earth,enemy,entry,error
Data error,event,faith,fault,field,fight,final,floor,focus,force,frame
Data frame,frank,front,fruit,glass,grant,grass,green,group,guide,heart
Data heart,henry,horse,hotel,house,image,index,input,issue,japan,jones
Data jones,judge,knife,laura,layer,level,lewis,light,limit,lunch,major
Data major,march,match,metal,model,money,month,motor,mouth,music,night
Data night,noise,north,novel,nurse,offer,order,other,owner,panel,paper
Data paper,party,peace,peter,phase,phone,piece,pilot,pitch,place,plane
Data plane,plant,plate,point,pound,power,press,price,pride,prize,proof
Data proof,queen,radio,range,ratio,reply,right,river,round,route,rugby
Data rugby,scale,scene,scope,score,sense,shape,share,sheep,sheet,shift
Data shift,shirt,shock,sight,simon,skill,sleep,smile,smith,smoke,sound
Data sound,south,space,speed,spite,sport,squad,staff,stage,start,state
Data state,steam,steel,stock,stone,store,study,stuff,style,sugar,table
Data table,taste,terry,theme,thing,title,total,touch,tower,track,trade
Data trade,train,trend,trial,trust,truth,uncle,union,unity,value,video
Data video,visit,voice,waste,watch,water,while,white,whole,woman,world
Data world,youth,there,where,which,whose,whoso,yours,yours,admit
Data admit,adopt,agree,allow,alter,apply,argue,arise,avoid,begin,blame
Data blame,break,bring,build,burst,carry,catch,cause,check,claim,clean
Data clean,clear,climb,close,count,cover,cross,dance,doubt,drink,drive
Data drive,enjoy,enter,exist,fight,focus,force,guess,imply,issue,judge
Data judge,laugh,learn,leave,limit,marry,match,occur,offer,order
Data order,phone,place,point,press,prove,raise,reach,refer,relax,serve
Data serve,shall,share,shift,shoot,sleep,solve,sound,speak,spend,split
Data split,stand,start,state,stick,study,teach,thank,think,throw,touch
Data touch,train,treat,trust,visit,voice,waste,watch,worry,would,write
Data write,above,acute,alive,alone,angry,aware,awful,basic,black,blind
Data blind,brave,brief,broad,brown,cheap,chief,civil,clean,clear,close
Data close,crazy,daily,dirty,early,empty,equal,exact,extra,faint,false
Data false,fifth,final,first,fresh,front,funny,giant,grand,great,green
Data green,gross,happy,harsh,heavy,human,ideal,inner,joint,large,legal
Data legal,level,light,local,loose,lucky,magic,major,minor,moral,naked
Data naked,nasty,naval,other,outer,plain,prime,prior,proud,quick,quiet
Data quiet,rapid,ready,right,roman,rough,round,royal,rural,sharp,sheer
Data sheer,short,silly,sixth,small,smart,solid,sorry,spare,steep,still
Data still,super,sweet,thick,third,tight,total,tough,upper,upset,urban
Data urban,usual,vague,valid,vital,white,whole,wrong,young,afore,after
Data after,bothe,other,since,slash,until,where,while,aback,abaft,aboon
Data aboon,about,above,accel,adown,afoot,afore,afoul,after,again,agape
Data agape,agogo,agone,ahead,ahull,alife,alike,aline,aloft,alone,along
Data along,aloof,aloud,amiss,amply,amuck,apace,apart,aptly,arear,aside
Data aside,askew,awful,badly,bally,below,canny,cheap,clean,clear,coyly
Data coyly,daily,dimly,dirty,ditto,drily,dryly,dully,early,extra,false
Data false,fatly,feyly,first,fitly,forte,forth,fresh,fully,funny,gaily
Data gaily,gayly,godly,great,haply,heavy,hence,hotly,icily,infra
Data infra,jildi,jolly,laxly,lento,light,lowly,madly,maybe,never
Data never,newly,nobly,oddly,often,other,ought,party,piano,plain,plonk
Data plonk,plumb,prior,queer,quick,quite,ramen,rapid,redly,right,rough
Data rough,round,sadly,secus,selly,sharp,sheer,shily,short,shyly,silly
Data silly,since,sleek,slyly,small,sound,spang,stark,still
Data still,stone,stour,super,tally,tanto,there,thick,tight,today,tomoz
Data tomoz,truly,twice,under,utter,verry,wanly,wetly,where,wrong,wryly
Data wryly,abaft,aboon,about,above,adown,afore,after,along,aloof,among
Data among,below,circa,cross,furth,minus,neath,round,since,spite,under
Data under,until,aargh,adieu,adios,alack,aloha,avast,bakaw,basta,begad
Data begad,bless,blige,brava,bravo,bring,chook,damme,ditto,frick,fudge
Data fudge,golly,gratz,hallo,hasta,havoc,hello,howay,howdy,hullo
Data hullo,huzza,kapow,loose,marry,mercy,night,plonk,psych
Data psych,quite,salve,skoal,sniff,sooey,there,thiam,thwap,tough,twirp
Data twirp,viola,vivat,wacko,wahey,whist,wilma,wirra,woops,wowie,yecch
Data yecch,yeeha,yeesh,yowch,zowie

Print this item

  The QB64 full screen editor
Posted by: eoredson - 08-29-2022, 05:08 AM - Forum: Utilities - Replies (6)

This attachment is the full screen editor for QB64:

Is a small editor in basic.

Some places from QB45 were edited for:

  Dir$ - _fileexists
  Redim preserve.

Adds _controlchr

Erik.



Attached Files
.bas   SCRNEDIT.BAS (Size: 55.13 KB / Downloads: 92)
Print this item

  4 Letter Hangman
Posted by: SierraKen - 08-28-2022, 11:02 PM - Forum: Programs - Replies (5)

Today I decided to make this version of Hangman that chooses between 500 4-letter words. It's very basic, not like Johnno's version a couple years ago. It has no extra files. 
It can be a bit addicting. Smile Tell me what you think. It took me around 2 1/2 hours to make it, not including the word list I've had on DATA statements for awhile. Feel free to use any of this in your own code as always. After 9 mistakes in any order on the letters you lose. Also, there are no upper-case letters so only use lower case, in fact it will only make those as mistakes. There is no start page, it jumps right into game-play, but there are no time limits.  

[Image: 4-Letter-Hangman-by-Sierra-Ken.jpg]

famous poems about sibling love



Code: (Select All)
'4 Letter Hangman by SierraKen - August 28, 2022.
'The game chooses between 500 4-letter words.
'Lower case letters only.

_Title "4 Letter Hangman by Sierraken - lower case letters"
start:
Cls
Screen _NewImage(800, 600, 32)
Line (0, 400)-(800, 400), _RGB32(255, 255, 255)
Line (600, 400)-(600, 100), _RGB32(255, 255, 255)
Line (600, 100)-(400, 100), _RGB32(255, 255, 255)
Line (400, 100)-(400, 180), _RGB32(255, 255, 255)

For lines = 303 To 453 Step 50
    Line (lines, 500)-(lines + 10, 500), _RGB32(255, 255, 255)
Next lines
Randomize Timer
word = Int(Rnd * 500) + 1
For w = 1 To word - 1
    Read w$
Next w
Read word$
letter1$ = Mid$(word$, 1, 1)
letter2$ = Mid$(word$, 2, 1)
letter3$ = Mid$(word$, 3, 1)
letter4$ = Mid$(word$, 4, 1)

letter = 0: oldletter = 0: one = 0: two = 0: three = 0: four = 0
mistake = 0
go:
Do
_Limit 20
    a$ = InKey$
    If a$ <> "" Then GoTo continue:
Loop
continue:
If a$ = Chr$(27) Then End  
oldletter = letter
If a$ = letter1$ Then
    _PrintString (305, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    one = one + 1
    If one = 1 Then letter = letter + 1
    If letter = 4 Then GoTo won:
End If
If a$ = letter2$ Then
    _PrintString (355, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    two = two + 1
    If two = 1 Then letter = letter + 1
    If letter = 4 Then GoTo won:
End If
If a$ = letter3$ Then
    _PrintString (405, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    three = three + 1
    If three = 1 Then letter = letter + 1
    If letter = 4 Then GoTo won:
End If
If a$ = letter4$ Then
    _PrintString (455, 480), a$
    For snd = 200 To 700 Step 100
        Sound snd, .5
    Next snd
    four = four + 1
    If four = 1 Then letter = letter + 1
    If letter = 4 Then GoTo won:
End If

If oldletter <> letter Then GoTo go:

mistake = mistake + 1

'Head
If mistake = 1 Then
    Circle (400, 200), 20, _RGB32(255, 255, 255)
    _PrintString (50, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Body
If mistake = 2 Then
    Line (400, 220)-(400, 300), _RGB32(255, 255, 255)
    _PrintString (75, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Left Arm
If mistake = 3 Then
    Line (400, 240)-(375, 220), _RGB32(255, 255, 255)
    _PrintString (100, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Right Arm
If mistake = 4 Then
    Line (400, 240)-(425, 220), _RGB32(255, 255, 255)
    _PrintString (125, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Left Leg
If mistake = 5 Then
    Line (400, 300)-(370, 330), _RGB32(255, 255, 255)
    _PrintString (150, 450), a$
    Sound 200, .5
    Sound 600, .5
End If

'Right Leg
If mistake = 6 Then
    Line (400, 300)-(430, 330), _RGB32(255, 255, 255)
    _PrintString (50, 475), a$
    Sound 200, .5
    Sound 600, .5
End If

'Eyes
If mistake = 7 Then
    Circle (390, 190), 3, _RGB32(255, 255, 255)
    Circle (410, 190), 3, _RGB32(255, 255, 255)
    _PrintString (75, 475), a$
    Sound 200, .5
    Sound 600, .5
End If

'Nose
If mistake = 8 Then
    Circle (400, 200), 3, _RGB32(255, 255, 255)
    _PrintString (100, 475), a$
    Sound 200, .5
    Sound 600, .5
End If

'Mouth
If mistake = 9 Then
    Circle (400, 212), 8, _RGB32(255, 255, 255), , , .5
    _PrintString (125, 475), a$
    For snd = 700 To 100 Step -50
        Sound snd, .5
    Next snd
    _PrintString (305, 480), letter1$
    _PrintString (355, 480), letter2$
    _PrintString (405, 480), letter3$
    _PrintString (455, 480), letter4$
    _PrintString (305, 415), "You Lose!"
    Locate 29, 38: Input "Again (Y/N)"; ag$
    If Mid$(ag$, 1, 1) = "y" Or Mid$(ag$, 1, 1) = "Y" Then
        Restore
        GoTo start:
    End If
    End
End If
GoTo go:

won:
_PrintString (305, 415), "You Win!"
Locate 29, 38: Input "Again (Y/N)"; ag$
If Mid$(ag$, 1, 1) = "y" Or Mid$(ag$, 1, 1) = "Y" Then
    Restore
    GoTo start:
End If
End

Data able,acid,aged,also,area,army,away,baby,back,ball
Data band,bank,base,bath,bear,beat,been,beer,bell,belt
Data best,bill,bird,blow,blue,boat,body,bomb,bond,bone
Data book,boom,born,boss,both,bowl,bulk,burn,bush,busy
Data call,calm,came,camp,card,care,case,cash,cast,cell
Data chat,chip,city,club,coal,coat,code,cold,come,cook
Data cool,cope,copy,CORE,cost,crew,crop,dark,data,date
Data dawn,days,dead,deal,dean,dear,debt,deep,deny,desk
Data dial,dick,diet,disc,disk,does,done,door,dose,down
Data draw,drew,drop,drug,dual,duke,dust,duty,each,earn
Data ease,east,easy,edge,else,even,ever,evil,exit,face
Data fact,fail,fair,fall,farm,fast,fate,fear,feed,feel
Data feet,fell,felt,file,fill,film,find,fine,fire,firm
Data fish,five,flat,flow,food,foot,ford,form,fort,four
Data free,from,fuel,full,fund,gain,game,gate,gave,gear
Data gene,gift,girl,give,glad,goal,goes,gold,Golf,gone
Data good,gray,grew,grey,grow,gulf,hair,half,hall,hand
Data hang,hard,harm,hate,have,head,hear,heat,held,hell
Data help,here,hero,high,hill,hire,hold,hole,holy,home
Data hope,host,hour,huge,hung,hunt,hurt,idea,inch,into
Data iron,item,jack,jane,jean,john,join,jump,jury,just
Data keen,keep,kent,kept,kick,kill,kind,king,knee,knew
Data know,lack,lady,laid,lake,land,lane,last,late,lead
Data left,less,life,lift,like,line,link,list,live,load
Data loan,lock,logo,long,look,lord,lose,loss,lost,love
Data luck,made,mail,main,make,male,many,Mark,mass,matt
Data meal,mean,meat,meet,menu,mere,mike,mile,milk,mill
Data mind,mine,miss,mode,mood,moon,more,most,move,much
Data must,name,navy,near,neck,need,news,next,nice,nick
Data nine,none,nose,note,okay,once,only,onto,open,oral
Data over,pace,pack,page,paid,pain,pair,palm,park,part
Data pass,past,path,peak,pick,pink,pipe,plan,play,plot
Data plug,plus,poll,pool,poor,port,post,pull,pure,push
Data race,rail,rain,rank,rare,rate,read,real,rear,rely
Data rent,rest,rice,rich,ride,ring,rise,risk,road,rock
Data role,roll,roof,room,root,rose,rule,rush,ruth,safe
Data said,sake,sale,salt,same,sand,save,seat,seed,seek
Data seem,seen,self,sell,send,sent,sept,ship,shop,shot
Data show,shut,sick,side,sign,site,size,skin,slip,slow
Data snow,soft,soil,sold,sole,some,song,soon,sort,soul
Data spot,star,stay,step,stop,such,suit,sure,take,tale
Data talk,tall,tank,tape,task,team,tech,tell,tend,term
Data test,text,than,that,them,then,they,thin,this,thus
Data till,time,tiny,told,toll,tone,tony,took,tool,tour
Data town,tree,trip,true,tune,turn,twin,type,unit,upon
Data used,user,vary,vast,very,vice,view,vote,wage,wait
Data wake,walk,wall,want,ward,warm,wash,wave,ways,weak
Data wear,week,well,went,were,west,what,when,whom,wide
Data wife,wild,will,wind,wine,wing,wire,wise,wish,with
Data wood,word,wore,work,yard,yeah,year,your,zero,zone

Print this item

  Ellipse trace
Posted by: james2464 - 08-28-2022, 08:01 PM - Forum: Programs - Replies (2)

Hey all,

Excuse my messy code.   I've been playing around with this some more...I wanted to simulate using a string and two pins to draw an ellipse on paper.   I also wanted to rotate around in increments based on angle, which was tricky for me.   Got it working though, and then added more stuff after that.    Cheers.

Code: (Select All)
'ellipse trace
'james2464


Dim scx, scy As Integer

scx = 800
scy = 600

Screen _NewImage(scx, scy, 32)

Randomize Timer

Const PI = 3.141592654#

Dim c0(100) As Long

Dim x
Dim xx, yy

xx = scx / 2
yy = scy / 2


c0(0) = _RGB(0, 0, 0)
c0(1) = _RGB(25, 25, 25)
c0(2) = _RGB(255, 0, 0)
c0(3) = _RGB(0, 200, 100)
c0(4) = _RGB(0, 200, 150)
c0(5) = _RGB(0, 0, 255)
c0(6) = _RGB(255, 0, 0)
c0(7) = _RGB(255, 0, 255)
c0(8) = _RGB(125, 0, 255)
c0(9) = _RGB(0, 125, 255)
c0(10) = _RGB(255, 0, 125)




Cls

Locate 10, 10
Input "Ellipse Width (40-280) ? ", A
Locate 12, 10
Input "Ellipse Height (40-280) ?", B


Cls


If A > 280 Then A = 280
If A < 40 Then A = 40

If B > 280 Then B = 280
If B < 40 Then B = 40


If A >= B Then
    C = Sqr(A ^ 2 - B ^ 2)
    C1 = xx - C / 2
    C2 = xx + C / 2
    C3 = yy
    C4 = yy
Else
    C = Sqr(B ^ 2 - A ^ 2)
    C1 = xx
    C2 = xx
    C3 = yy - C / 2
    C4 = yy + C / 2
End If



'===== display axis lines
Line (0, yy)-(scx, yy), c0(1)
Line (xx, 0)-(xx, scy), c0(1)




'===== parameters
dv = .02 '              time delay value
d90 = 15 '              divisions per 90 degrees
pt = 2 '                point size aka circle size
cc1 = 1 '              line colour
cc2 = 4 '              line colour
di = 90 / d90
tg = 2




'======== main loop
Do
    'control panel
    Line (3, 8)-(115, 50), c0(3), BF
    Line (4, 10)-(114, 49), c0(0), BF

    Line (3, 51)-(115, 150), c0(3), BF
    Line (4, 52)-(114, 149), c0(0), BF

    Line (3, 151)-(115, 215), c0(3), BF
    Line (4, 152)-(114, 214), c0(0), BF

    Line (3, 151)-(115, 230), c0(3), BF
    Line (4, 152)-(114, 229), c0(0), BF

    Line (3, 231)-(115, 260), c0(3), BF
    Line (4, 232)-(114, 258), c0(0), BF


    Color c0(4)
    Locate 2, 3
    Print "Height:"; B
    Locate 3, 3
    Print "Width: "; A
    Locate 5, 3
    Color c0(9)
    Print "CONTROLS"
    Locate 6, 3
    Print "Height +: w"
    Locate 7, 3
    Print "Height -: s"
    Locate 8, 3
    Print "Width +:  d"
    Locate 9, 3
    Print "Width -:  a"
    Locate 11, 3
    Print "Tracing:  t"
    Locate 12, 3
    Print "Erase:    e"


    Locate 13, 3
    Print "Speed +:  k"
    Locate 14, 3
    Print "Speed -:  j"

    sp$ = "Speed: .###"
    Color c0(4)
    Locate 16, 3
    Print Using sp$; dv








    flag = di
    xold = 0
    yold = B
    j = 0
    lpexit = 0
    Do
        j = j + .01
        y = B - j
        x = Sqr((1 - y ^ 2 / B ^ 2) * A ^ 2)
        a42 = 0 - (Atn(x / y) * -57.2957795131)
        PSet (xx + x, yy - y), c0(2)
        If y > 0 Then
            If a42 >= flag Then
                If tg > 0 Then
                    Line (C1, C3)-(xx + xold, yy - yold), c0(cc1)
                    Line (C2, C4)-(xx + xold, yy - yold), c0(cc1)
                End If
                If tg = 2 Then
                    Line (C1, C3)-(xx + x, yy - y), c0(cc2)
                    Line (C2, C4)-(xx + x, yy - y), c0(cc2)
                End If
                Circle (xx + x, yy - y), pt, c0(2)
                _Delay dv
                flag = flag + di
                xold = x
                yold = y
            End If
        Else
            lpexit = 1
        End If
    Loop Until lpexit = 1

    If tg > 0 Then
        Line (C1, C3)-(xx + xold, yy - yold), c0(cc1)
        Line (C2, C4)-(xx + xold, yy - yold), c0(cc1)
    End If
    If tg = 2 Then
        Line (C1, C3)-(xx + A, yy - 0), c0(cc2)
        Line (C2, C4)-(xx + A, yy - 0), c0(cc2)
    End If
    Circle (xx + A, yy - 0), pt, c0(2)
    _Delay dv




    lpexit = 0
    flag = di
    xold = A
    yold = 0
    j = B
    Do
        j = j - .01
        If j > 0 Then
            y = B - j
            x = Sqr((1 - y ^ 2 / B ^ 2) * A ^ 2)
            a42 = 90 - (Atn(x / y) * 57.2957795131)
            PSet (xx + x, yy + y), c0(2)
            If a42 > flag Then
                If tg > 0 Then
                    Line (C1, C3)-(xx + xold, yy + yold), c0(cc1)
                    Line (C2, C4)-(xx + xold, yy + yold), c0(cc1)
                End If
                If tg = 2 Then
                    Line (C1, C3)-(xx + x, yy + y), c0(cc2)
                    Line (C2, C4)-(xx + x, yy + y), c0(cc2)
                End If
                Circle (xx + x, yy + y), pt, c0(2)
                _Delay dv
                flag = flag + di
                xold = x
                yold = y
            End If
        Else
            lpexit = 1
        End If
    Loop Until lpexit = 1


    If tg > 0 Then
        Line (C1, C3)-(xx + xold, yy + yold), c0(cc1)
        Line (C2, C4)-(xx + xold, yy + yold), c0(cc1)
    End If
    If tg = 2 Then
        Line (C1, C3)-(xx + 0, yy + B), c0(cc2)
        Line (C2, C4)-(xx + 0, yy + B), c0(cc2)
    End If
    Circle (xx + 0, yy + B), pt, c0(2)
    _Delay dv




    lpexit = 0
    flag = di
    j = 0
    xold = 0
    yold = B
    Do
        j = j + .01
        y = B - j

        x = Sqr((1 - y ^ 2 / B ^ 2) * A ^ 2)
        a42 = 0 - (Atn(x / y) * -57.2957795131)
        PSet (xx - x, yy + y), c0(2)
        If y > 0 Then
            If a42 >= flag Then
                If tg > 0 Then
                    Line (C1, C3)-(xx - xold, yy + yold), c0(cc1)
                    Line (C2, C4)-(xx - xold, yy + yold), c0(cc1)
                End If
                If tg = 2 Then
                    Line (C1, C3)-(xx - x, yy + y), c0(cc2)
                    Line (C2, C4)-(xx - x, yy + y), c0(cc2)
                End If
                Circle (xx - x, yy + y), pt, c0(2)
                _Delay dv
                flag = flag + di
                xold = x
                yold = y
            End If
        Else
            lpexit = 1
        End If
    Loop Until lpexit = 1




    If tg > 0 Then
        Line (C1, C3)-(xx - xold, yy + yold), c0(cc1)
        Line (C2, C4)-(xx - xold, yy + yold), c0(cc1)
    End If
    If tg = 2 Then
        Line (C1, C3)-(xx - A, yy + 0), c0(cc2)
        Line (C2, C4)-(xx - A, yy + 0), c0(cc2)
    End If
    Circle (xx - A, yy + 0), pt, c0(2)
    _Delay dv



    lpexit = 0
    flag = di
    j = B
    xold = A
    yold = 0
    Do
        j = j - .01
        If j > 0 Then
            y = B - j
            x = Sqr((1 - y ^ 2 / B ^ 2) * A ^ 2)
            a42 = 90 - (Atn(x / y) * 57.2957795131)
            PSet (xx - x, yy - y), c0(2)
            If a42 >= flag Then
                If tg > 0 Then
                    Line (C1, C3)-(xx - xold, yy - yold), c0(cc1)
                    Line (C2, C4)-(xx - xold, yy - yold), c0(cc1)
                End If
                If tg = 2 Then
                    Line (C1, C3)-(xx - x, yy - y), c0(cc2)
                    Line (C2, C4)-(xx - x, yy - y), c0(cc2)
                End If
                Circle (xx - x, yy - y), pt, c0(2)
                _Delay dv
                flag = flag + di
                xold = x
                yold = y
            End If
        Else
            lpexit = 1
        End If
    Loop Until lpexit = 1

    If tg > 0 Then
        Line (C1, C3)-(xx - xold, yy - yold), c0(cc1)
        Line (C2, C4)-(xx - xold, yy - yold), c0(cc1)
    End If
    If tg = 2 Then
        Line (C1, C3)-(xx - 0, yy - B), c0(cc2)
        Line (C1, C4)-(xx - 0, yy - B), c0(cc2)
    End If
    Circle (xx - 0, yy - B), pt, c0(2)
    _Delay dv


    '======================================================

    'adjust height using "w" and "s"
    'adjust width using "a" and "d"
    keypress$ = InKey$


    If keypress$ = Chr$(100) Then A = A + 5
    If keypress$ = Chr$(97) Then A = A - 5

    If keypress$ = Chr$(119) Then B = B + 5
    If keypress$ = Chr$(115) Then B = B - 5

    If keypress$ = Chr$(116) Then tg = tg + 1

    If tg > 2 Then tg = 0

    If keypress$ = Chr$(106) Then dv = dv * 2
    If keypress$ = Chr$(107) Then dv = dv / 2

    If dv > .16 Then dv = .16
    If dv < .002 Then dv = .002

    If keypress$ = Chr$(101) Then
        Line (xx - 290, yy - 290)-(xx + 290, yy + 290), c0(0), BF
        Line (0, yy)-(scx, yy), c0(1)
        Line (xx, 0)-(xx, scy), c0(1)
    End If

    If A > 280 Then A = 280
    If A < 40 Then A = 40

    If B > 280 Then B = 280
    If B < 40 Then B = 40

    If A >= B Then
        C = Sqr(A ^ 2 - B ^ 2)
        C1 = xx - C / 2
        C2 = xx + C / 2
        C3 = yy
        C4 = yy
    Else
        C = Sqr(B ^ 2 - A ^ 2)
        C1 = xx
        C2 = xx
        C3 = yy - C / 2
        C4 = yy + C / 2
    End If



Loop


End




[Image: ellipsetrace.png]

Print this item

  Can't set font size in Linux
Posted by: Circlotron - 08-28-2022, 03:24 AM - Forum: General Discussion - Replies (3)

I posted the following on Facebook because I forgot about this forum... Dodgy 
----
Under Options-Display there is a setting for font size. It defaults to 21 pixels. If I make the number larger it doesn't increase the font size, and if I go back to the setting window it has reverted to 21. How to fix this? 21 pixels was okay for 640x480 screens but it's a bit small for today's screens, IMO.
----
Maybe something about the path to the font file? Would it accept a Linux style path?

I did get a reply from Marcos Guillen saying there were some things in QB64 that didn't yet work in the Linux version. Maybe this is one?

Print this item

  if exist... ?
Posted by: PhilOfPerth - 08-28-2022, 01:25 AM - Forum: Help Me! - Replies (4)

I remember from way back when, there was something like If Exist(filename) to load a file if it existed, so you could provide an option if it didn't, but I can't find it or remember its syntax. Any clues?

Print this item