Author Topic: SCREEN the unbreakable power!  (Read 1629 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
SCREEN the unbreakable power!
« on: January 23, 2021, 06:48:33 am »
Hi guys and gals
following this trhead https://www.qb64.org/forum/index.php?topic=3509.15 and specifically this demonstration code taken from the wiki https://www.qb64.org/wiki/index.php/PCOPY example 2 bouncing balls I have been beaten by this line of code
Code: QB64: [Select]
  1. SCREEN 7, 0, 1, 0
... in specific the first 0 in the parameters of SCREEN.
Why? Because I have never reminded that there is a value to put into the second position of SCREEN keyword.
So I go to the wiki page of SCREEN https://www.qb64.org/wiki/index.php/SCREEN
and I can read 
Quote
SCREEN {mode%|imagehandle&} [, , active_page, visual_page]   

The empty comma disables color when any value is used. DO NOT USE! Include the comma ONLY when using page flipping.
If the SCREEN mode supports pages, the active page is the page to be worked on while visual page is the one displayed.
So it seems that my memory was right! Uh, let's see what happens if I put a number in that second position.
....just a moment but 0 is a number! So if I use colors into the above demo code I'll see the difference!
here the colorizing code
Code: QB64: [Select]
  1. SCREEN 7, 0, 1, 0
  2. COLOR  12,3
  3. DIM x(10), y(10), dx(10), dy(10)
  4. FOR a = 1 TO 10
  5.     x(a) = INT(RND * 320) + 1
  6.     y(a) = INT(RND * 200) + 1
  7.     dx(a) = (RND * 2) - 1
  8.     dy(a) = (RND * 2) - 1
  9.     PCOPY 1, 0 'place image on the visible page 0
  10.     CLS
  11.     _LIMIT 100 'regulates speed of balls in QB64
  12.     FOR a = 1 TO 10
  13.         CIRCLE (x(a), y(a)), 5, 14 'all erasing and drawing is done on page 1
  14.         x(a) = x(a) + dx(a)
  15.         y(a) = y(a) + dy(a)
  16.         IF x(a) > 320 THEN dx(a) = -dx(a): x(a) = x(a) - 1
  17.         IF x(a) < 0 THEN dx(a) = -dx(a): x(a) = x(a) + 1
  18.         IF y(a) > 200 THEN dy(a) = -dy(a): y(a) = y(a) - 1
  19.         IF y(a) < 0 THEN dy(a) = -dy(a): y(a) = y(a) + 1
  20.     NEXT
  21. LOOP UNTIL INKEY$ = CHR$(27) ' escape exit
  22.  

but with 0 (a number) as parameter it works the same!
and also if we put another number, also negative number or float/single precision number!
see screenshot
  [ You are not allowed to view this attachment ]  
There is a difference between QB45 and QB64 about SCREEN statement and we can affirm that this inner enpowerment of SCREEN is good but it push back the backwards compatibility of SCREEN keywords from 100% to 80%.

Thanks to read
Welcome your opinions.

PS I think about it that this is a good enpowerement of SCREEN, but wiki lacks of precision.
Programming isn't difficult, only it's  consuming time and coffee

Offline bartok

  • Newbie
  • Posts: 80
    • View Profile
Re: SCREEN the unbreakable power!
« Reply #1 on: January 23, 2021, 09:23:35 am »
I had similar troubles while investigating on PCOPY statement and I come to this QB64 example. What I have undestood is that "page flipping" is related to the use of PCOPY in the code. In my attempts, nothing changed with:
SCREEN 7, , 1, 0
SCREEN 7, 0 , 1, 0
SCREEN 7, any number, 1, 0 

but with
SCREEN 7, 1, 0

we have the screen flickering, and I think it is why the empty commas are required with page flipping.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: SCREEN the unbreakable power!
« Reply #2 on: January 23, 2021, 11:00:26 am »
You need that comma as a place holder for the parameters to be passed to the SCREEN function correctly. One of my favorites in QuickBASIC was the ability to build stuff on a hidden screen, and then call that screen. Since QB was a lot slower than QB64, especially when running interpreted, that ability made it appear everything being drawn, or added, was already present when the page appeared, instead of in the process of displaying. It also eliminated flicker. Fun stuff back then, and still useful to know now, when everything is up to speed.

Code: QB64: [Select]
  1. SCREEN 0, 0, 0, 0
  2. PRINT "What program would Pete like to see Democrats working on?"
  3.  
  4. ans$ = "Hello Hell!"
  5.  
  6. SCREEN , , 1, 0
  7. LOCATE 12, 34
  8. FOR i = 1 TO LEN(ans$)
  9.     _DELAY .2
  10.     PRINT MID$(ans$, i, 1);
  11. SCREEN , , 1, 1 ' Or don't change the screen and just use PCOPY 1, 0
  12.  

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/