Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thesolarcode

Pages: [1]
1
QB64 Discussion / Re: Errors in an $include file
« on: May 17, 2021, 02:02:51 pm »
Is there a smart way to conditionally include some file only once?

2
Yes, that is it - the effect looks really great now (even better if you decrease by 1 - then it fades really slowly towards black color).
Today I learned something new (how to use MEMGET/PUT for gfx).
Thanks :)

3
I changed the code a bit - this time I copy an image over and over to achieve the fading effect, but I have the same problem with the faded lines being still visible.
I guess there is no other way in QB64 as to darken/fade each pixel individually, right?

Code: QB64: [Select]
  1.  
  2. dim shared screenx%, screeny%, tx1%, ty1%, tx2%, ty2%, x1%, y1%, x2%, y2%, d%, handle2&
  3. screenx%=800
  4. screeny%=600
  5.        
  6. SCREEN _NEWIMAGE(screenx%,screeny%,32)
  7.  
  8. ' create new black image with alpha channel
  9. handle2& = _NEWIMAGE(screenx%,screeny%,32)
  10. _DEST handle2&
  11. LINE (0, 0)-(screenx%, screeny%), _RGBA(0, 0, 0, 3), BF
  12.  
  13. tx1%=screenx%*rnd
  14. ty1%=screeny%*rnd
  15. tx2%=screenx%*rnd
  16. ty2%=screeny%*rnd
  17. x1%=screenx%*rnd
  18. y1%=screeny%*rnd
  19. x2%=screenx%*rnd
  20. y2%=screeny%*rnd
  21. d%=3
  22.  
  23.         color _RGB(256*rnd, 256*rnd, 256*rnd)
  24.         smearfx
  25.        
  26.         if x1% < tx1% then
  27.                 x1% = x1% + d%
  28.         ELSE
  29.                 x1% = x1% - d%
  30.         end if
  31.         if ABS(x1%-tx1%) < d% then
  32.                 tx1%=screenx%*rnd
  33.         end if
  34.  
  35.         if y1% < ty1% then
  36.                 y1% = y1% + d%
  37.         ELSE
  38.                 y1% = y1% - d%
  39.         end if
  40.         if abs(y1%-ty1%) < d% then
  41.                 ty1%=screeny%*rnd
  42.         end if
  43.        
  44.         if x2% < tx2% then
  45.                 x2% = x2% + d%
  46.         ELSE
  47.                 x2% = x2% - d%
  48.         end if
  49.         if abs(x2%-tx2%) < d% then
  50.                 tx2%=screenx%*rnd
  51.         end if
  52.  
  53.         if y2% < ty2% then
  54.                 y2% = y2% + d%
  55.         ELSE
  56.                 y2% = y2% - d%
  57.         end if
  58.         if abs(y2%-ty2%) < d% then
  59.                 ty2%=screeny%*rnd
  60.         end if
  61.  
  62. sub smearfx()
  63.     _LIMIT 50
  64.     'LINE (0, 0)-(screenx%, screeny%), _RGBA(0, 0, 0, 25), BF
  65.     _PUTIMAGE (0,0), handle2&, 0
  66.     line (x1%, y1%)-(x2%, y2%)
  67.     _DISPLAY
  68.  

4
Thanks,

Not sure how to use CLS without destroying the line effect - I only draw one additional line per screen update, all the other lines are just made darker with one command :)
I'm probably doing the wrong thing - am I effectively just setting transparency to 25% and thus lines are still visible?

5
QB64 Discussion / Help: code not blending to complete black color
« on: May 13, 2021, 03:53:00 pm »
I have this code and thought that with the _RGBA alpha setting (line 67) drawing over the whole screen the image should get darker and darker, but somehow the lines are stuck at some very dark grey color. Any idea how I can fix this?

Code: QB64: [Select]
  1.  
  2. dim shared screenx%, screeny%, tx1%, ty1%, tx2%, ty2%, x1%, y1%, x2%, y2%, d%
  3. screenx%=800
  4. screeny%=600
  5.        
  6. ' open new (full)screen
  7. SCREEN _NEWIMAGE(screenx%,screeny%,32)
  8.  
  9. tx1%=screenx%*rnd
  10. ty1%=screeny%*rnd
  11. tx2%=screenx%*rnd
  12. ty2%=screeny%*rnd
  13. x1%=screenx%*rnd
  14. y1%=screeny%*rnd
  15. x2%=screenx%*rnd
  16. y2%=screeny%*rnd
  17. d%=3
  18.  
  19.         color _RGB(256*rnd, 256*rnd, 256*rnd)
  20.         smearfx
  21.        
  22.         if x1% < tx1% then
  23.                 x1% = x1% + d%
  24.         ELSE
  25.                 x1% = x1% - d%
  26.         end if
  27.         if ABS(x1%-tx1%) < d% then
  28.                 tx1%=screenx%*rnd
  29.         end if
  30.  
  31.         if y1% < ty1% then
  32.                 y1% = y1% + d%
  33.         ELSE
  34.                 y1% = y1% - d%
  35.         end if
  36.         if abs(y1%-ty1%) < d% then
  37.                 ty1%=screeny%*rnd
  38.         end if
  39.        
  40.         if x2% < tx2% then
  41.                 x2% = x2% + d%
  42.         ELSE
  43.                 x2% = x2% - d%
  44.         end if
  45.         if abs(x2%-tx2%) < d% then
  46.                 tx2%=screenx%*rnd
  47.         end if
  48.  
  49.         if y2% < ty2% then
  50.                 y2% = y2% + d%
  51.         ELSE
  52.                 y2% = y2% - d%
  53.         end if
  54.         if abs(y2%-ty2%) < d% then
  55.                 ty2%=screeny%*rnd
  56.         end if
  57.  
  58. sub smearfx()
  59.     _LIMIT 50
  60.     LINE (0, 0)-(screenx%, screeny%), _RGBA(0, 0, 0, 25), BF
  61.         line (x1%, y1%)-(x2%, y2%)
  62.     _DISPLAY
  63.  

6
QB64 Discussion / Re: How to smoothly fadeout desktop?
« on: December 09, 2018, 03:16:41 pm »
Wow, Pete's code works much better, seems like the _FULLSCREEN is the issue.
I can live with the short blink at the start.

Thanks :)

7
QB64 Discussion / Re: How to smoothly fadeout desktop?
« on: December 09, 2018, 01:24:58 pm »
I added the sleep to see where the blinking is happening.
I thought first it blinks due to the program startup, but on my PC there is some ugly blink right after the 3 second sleep (actually it looks like the fade out starts with a black image/screen), and at that time I would guess it is not anymore caused by any startup or setup of the screen.

I tried to move the _limit to after display as you suggested, but don't see any difference.

8
QB64 Discussion / How to smoothly fadeout desktop?
« on: December 09, 2018, 12:22:34 pm »
For a simple game, I'd like to start it with fading out the desktop.
I have some code which nearly does what I want, but it blinks ugly - maybe someone can help me.

Code: QB64: [Select]
  1.  
  2. screenx = _WIDTH(img&)    
  3. screeny = _HEIGHT(img&)
  4. SCREEN _NEWIMAGE(screenx, screeny, 32)
  5. _PUTIMAGE (0, 0)-(screenx-1, screeny-1), img&
  6.  
  7. ' Fade out
  8. FOR i% = 0 TO 255 STEP 5
  9.   _LIMIT 50                          'control fade speed
  10.   _PUTIMAGE (0, 0)-(screenx-1, screeny-1), img&
  11.   LINE (0, 0)-(screenx-1, screeny-1), _RGBA(0, 0, 0, i%), BF 'increase black box transparency
  12.  

Pages: [1]