QB64.org Forum
Active Forums => Programs => Topic started by: bplus on October 09, 2019, 11:25:11 pm
-
_TITLE "Scrolling Plasma Lines Mod 1" 'B+ 2019-10-09 CONST xmax
= 800, ymax
= 600
f = xmax / ymax
ln(i + 1) = ln(i)
LINE (xmax
- i
* f
, 0)-STEP(0, ymax
), ln
(i
+ 1) LINE (i
* f
, 0)-STEP(f
, ymax
), ln
(i
+ 1) LINE (0, ymax
- i
)-STEP(xmax
, 0), ln
(i
+ 1) ln
(0) = _RGB32(127 + 127 * SIN(r
* c
), 127 + 127 * SIN(g
* c
), 127 + 127 * SIN(b
* c
), 40) c = c + 1
-
Half expecting a Scotsman and his bagpipes! Very cool...
-
That's some really CPU intensive work going on inside that inner FOR loop there!
_TITLE "Scrolling Plasma Lines Mod 1" 'B+ 2019-10-09 CONST xmax
= 800, ymax
= 600
f = xmax / ymax
FPS = FPS + 1
ln(i + 1) = ln(i)
LINE (xmax
- i
* f
, 0)-STEP(0, ymax
), ln
(i
+ 1) LINE (i
* f
, 0)-STEP(f
, ymax
), ln
(i
+ 1) LINE (0, ymax
- i
)-STEP(xmax
, 0), ln
(i
+ 1) ln
(0) = _RGB32(127 + 127 * SIN(r
* c
), 127 + 127 * SIN(g
* c
), 127 + 127 * SIN(b
* c
), 40) c = c + 1
As this little program runs for a bit, my CPU fans turn on and imitate an airplane engine, with a single core's usage going up to nearly 100%! Once it hits its stride, my PC produces only about 27 or 28 FPS with this little demo, rendering that _LIMIT 60 completely moot. It can't slow down my PC to make it run at 60 FPS, since it won't even run at 30 FPS to begin with!
-
Just having fun with this a bit, here's a mod which implements a step variable for the routine, which changes the patterns slightly. When the stepper gets to 7, the screen ends up amazing stable and unchanging after a second or so for me, which I found rather oddish.
_TITLE "Scrolling Plasma Lines Mod 1s (S for STEVE)" 'B+ 2019-10-09 CONST xmax
= 800, ymax
= 600
f = xmax / ymax
stepper = 1
FPS = FPS + 1
ln(i + stepper) = ln(i)
LINE (0, i
)-STEP(xmax
, 0), ln
(i
+ stepper
) LINE (xmax
- i
* f
, 0)-STEP(0, ymax
), ln
(i
+ stepper
) LINE (i
* f
, 0)-STEP(f
, ymax
), ln
(i
+ stepper
) LINE (0, ymax
- i
)-STEP(xmax
, 0), ln
(i
+ stepper
) ln
(0) = _RGB32(127 + 127 * SIN(r
* c
), 127 + 127 * SIN(g
* c
), 127 + 127 * SIN(b
* c
), 40) c = c + stepper
IF TIMER > T#
+ 1 THEN FPSDisplay
= FPS: FPS
= 0: T#
= TIMER: SecondsRun
= SecondsRun
+ 1 IF SecondsRun
MOD 10 = 0 THEN CLS: SecondsRun
= 1: stepper
= stepper
+ 1
-
Well we can speed it up like this but Full Screen sucks!!!
_TITLE "Scrolling Plasma Lines Mod 1" 'B+ 2019-10-09 CONST xmax
= 400, ymax
= 300
f = xmax / ymax
FPS = FPS + 1
ln(i + 1) = ln(i)
LINE (xmax
- i
* f
, 0)-STEP(0, ymax
), ln
(i
+ 1) LINE (i
* f
, 0)-STEP(f
, ymax
), ln
(i
+ 1) LINE (0, ymax
- i
)-STEP(xmax
, 0), ln
(i
+ 1) ln
(0) = _RGB32(127 + 127 * SIN(r
* c
), 127 + 127 * SIN(g
* c
), 127 + 127 * SIN(b
* c
), 40) c = c + 1
'_LIMIT 60