10-10-2024, 10:31 PM
I was just messing around with a particle fountain. Sometimes the program runs smoothly, but if I change the _limit a little it can become hurky-jerky. Like the below seems to do great at 60 or 80 FPS, though runs less smoothly at 50 or 70. Is it my laptop? Is smoothness in graphics always a dance between run-speed and the number of pixels that items move per cycle? I'm curious how this could be made to run smoothly at various _limits. Any thoughts or insights appreciated!
Code: (Select All)
OPTION _EXPLICIT
SCREEN _NEWIMAGE(1280, 720, 32)
RANDOMIZE TIMER: _MOUSEHIDE
_DELAY .25: _SCREENMOVE _MIDDLE
TYPE particle
x AS SINGLE
y AS SINGLE
Vx AS SINGLE
Vy AS SINGLE
END TYPE
DIM AS INTEGER c
DIM AS particle p(200)
start:
c = -1
DO '
c = c + 1 ' init particles
p(c).x = _WIDTH / 2
p(c).y = c * -5 - 140
p(c).Vx = 0
p(c).Vy = 3 + (RND - RND) / 4
LOOP UNTIL c = UBOUND(p)
DO
c = -1
CLS
_LIMIT 60
DO ' move em
c = c + 1
p(c).x = p(c).x + p(c).Vx
p(c).y = p(c).y + p(c).Vy
IF p(c).y > 20 AND p(c).y < 26 THEN p(c).Vx = (RND - RND) / 1.75 ' only change em once
IF p(c).y > 14 THEN p(c).Vy = p(c).Vy + .06 ' a little gravity
LOOP UNTIL c = UBOUND(p)
c = -1
DO ' draw em
c = c + 1
PSET (p(c).x, p(c).y), _RGB32(255)
LOOP UNTIL c = UBOUND(p)
_DISPLAY
IF p(200).y > _HEIGHT + 140 THEN GOTO start
LOOP UNTIL _KEYDOWN(27)
SYSTEM