Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I must be missing something obvious with this code
#1
I was adding a screen flipping effect to a program, and don't see why CLS is needed to remove the edge LINE before the last _PUTIMAGE is called.  I'm putimaging the whole screen at the end, shouldn't that remove the LINE?

- Dav

Code: (Select All)
'==============
'FLIPSCREENHZ.BAS
'==============

Screen _NewImage(1000, 700, 32)

'=== draw stuff
For t = 1 To 50
    Line (Rnd * _Width, Rnd * _Height)-Step(15 + (Rnd * 100), 15 + (Rnd * 100)), _RGB(Rnd * 255, Rnd * 255, Rnd * 255), BF
    Circle (Rnd * _Width, Rnd * _Height), 15 + (Rnd * 100), _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next

Locate 12, 12: Print "PRESS ANY KEY TO FILP ME";
'kep pressing any key to flip screen
'ESC exits

Do
    a$ = Input$(1)
    If a$ = Chr$(27) Then End

    FlipScreen

Loop

Sub FlipScreen

    'Flips current screen horizontally

    displayStatus%% = _AutoDisplay 'get current display status

    _Display 'turn off auto screen updates

    scrn& = _CopyImage(_Display)

    x1 = 0: x2 = _Width
    y1 = 0: y2 = _Height

    Do
        'draw screen image
        Cls: _PutImage (x1, y1)-(x2, y2), scrn&

        'draw edge line around it for extra effect
        Line (x1, y1)-(x2, y2), _RGB(128, 128, 128), B

        x1 = x1 + 45: If x1 > _Width Then x1 = _Width
        x2 = x2 - 45: If x2 < 0 Then x2 = 0

        _Display
        _Limit 30
    Loop Until x1 = _Width And x2 = 0

    'Shouldn't _PUTIMAGE below fit the whole screen and remove the edge LINE without needing CLS?
    'CLS

    _PutImage (_Width, 0)-(0, _Height), scrn&
    _Display
    _FreeImage scrn&

    If displayStatus%% = -1 Then _AutoDisplay 'restore previous

End Sub

Find my programs here in Dav's QB64 Corner
Reply
#2
Set a variable W and H and make them = Width - 1 and Height - 1.

Your screen dimensions are 0 to Width - 1, not 0 to Width.  Wink
Reply
#3
(09-15-2024, 01:21 PM)SMcNeill Wrote: Set a variable W and H and make them = Width - 1 and Height - 1.

Your screen dimensions are 0 to Width - 1, not 0 to Width.  Wink

Ahhh,  Thanks, Steve.

Woo hoo!  I won the idiot of the day award before 9:30am.  Big Grin 

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#4
(09-15-2024, 01:31 PM)Dav Wrote:
(09-15-2024, 01:21 PM)SMcNeill Wrote: Set a variable W and H and make them = Width - 1 and Height - 1.

Your screen dimensions are 0 to Width - 1, not 0 to Width.  Wink

Ahhh,  Thanks, Steve.

Woo hoo!  I won the idiot of the day award before 9:30am.  Big Grin 

- Dav

Ok, I'll return my cup; I'll miss it though.  Big Grin
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#5
The off-by-one error is so common that the ISO has considered making it a required standard error.
Reply
#6
(09-16-2024, 09:43 AM)JRace Wrote: The off-by-one error is so common that the ISO has considered making it a required standard error.
If I had a dollar for every time the off by one error has befuddled me I would be funding flights on a SpaceX Dragon.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#7
Steve could likely listen to your car engine and diagnosis an efficiency just by the sound. In fact, I suspect there are a lot of engine whispers on this forum.
Reply
#8
(09-16-2024, 05:31 PM)Dimster Wrote: Steve could likely listen to your car engine and diagnosis an efficiency just by the sound. In fact, I suspect there are a lot of engine whispers on this forum.
My grandpa (a life-long farmer) definitely had this skill. His Chalmers, Masseys, Fords, and Olivers always ran in perfect condition. Hell, the Alliis Chalmers he used as a cultivator and you had to hand crank that puppy. More than once that damn thing kicked back on me and sent me flying.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#9
Wait, I missed out on the Idiot of the Day award? Dammit, now I'll have to figure out when the next competition starts! Big Grin Big Grin Big Grin

Pete
Shoot first and shoot people who ask questions, later.
Reply




Users browsing this thread: 4 Guest(s)