Since it came up in another thread, here's an example of what REDRAW does for speed in PBCC's graphic windows.
Without REDRAW, this speed wouldn't be possible, especially since this is done one pixel at a time. This isn't even optimized by any means, or written in any elegant form, just thrown together to show what's possible with graphics in PBCC. It could be done MUCH better and leaner.
BTW, I meant for this to be much shorter, but I just kept adding options, and I guess I got carried away in all the fun.
Still, its just a simple copy and paste to see it.
Press SPACE to toggle bounce mode, and Esc to quit.
Without REDRAW, this speed wouldn't be possible, especially since this is done one pixel at a time. This isn't even optimized by any means, or written in any elegant form, just thrown together to show what's possible with graphics in PBCC. It could be done MUCH better and leaner.
BTW, I meant for this to be much shorter, but I just kept adding options, and I guess I got carried away in all the fun.

Still, its just a simple copy and paste to see it.
Code:
#COMPILE EXE TYPE DotType x AS SINGLE y AS SINGLE angle AS SINGLE xadd AS SINGLE yadd AS SINGLE spd AS SINGLE clr AS LONG END TYPE FUNCTION PBMAIN () AS LONG radian# = .017453293 background& = RGB(0, 0, 0) foreground& = RGB(255, 255, 255) DESKTOP GET SIZE TO w&, h& minspeed! = .4 [email protected]@ = 1 dotcount& = 500 [email protected]@ = 5 bounce& = 0 DIM dot(dotcount&) AS DotType RANDOMIZE(TIMER) angle! = INT(360 * RND) FOR count& = 1 TO dotcount& dot(count&).x = w& * RND dot(count&).y = h& * RND dot(count&).angle = angle! dot(count&).spd = ([email protected]@ - minspeed!) * RND + minspeed! dot(count&).xadd = SIN(angle! * radian#) * dot(count&).spd dot(count&).yadd = -COS(angle! * radian#) * dot(count&).spd dot(count&).clr = RGB (RND(0, 255), RND(0, 255), RND(0, 255)) NEXT GRAPHIC WINDOW "", 0, 0, w&, h& TO MyWindow??? GRAPHIC ATTACH MyWindow???, 0, REDRAW GRAPHIC COLOR foreground&, background& DO GRAPHIC CLEAR background& FOR count& = 1 TO dotcount& newx! = dot(count&).x + dot(count&).xadd newy! = dot(count&).y + dot(count&).yadd IF newx! < 0 OR newx! => w& THEN IF bounce& = 0 THEN newx! = (w& - 1) * -SGN(SGN(newx!) - 1) newy! = h& * RND dot(count&).spd = ([email protected]@ - minspeed!) * RND + minspeed! dot(count&).angle = angle! dot(count&).xadd = SIN(angle! * radian#) * dot(count&).spd dot(count&).yadd = -COS(angle! * radian#) * dot(count&).spd dot(count&).clr = RGB (RND(0, 255), RND(0, 255), RND(0, 255)) ELSE dot(count&).angle = dot(count&).angle + 180 - (2 * (dot(count&).angle - 90)) IF dot(count&).angle < 0 THEN dot(count&).angle = dot(count&).angle + 360 ELSEIF dot(count&).angle > 360 THEN dot(count&).angle = dot(count&).angle - 360 END IF dot(count&).xadd = SIN(dot(count&).angle * radian#) * dot(count&).spd newx! = dot(count&).x + dot(count&).xadd END IF ELSEIF newy! < 0 OR newy! => h& THEN IF bounce& = 0 THEN newx! = w& * RND newy! = (h& - 1) * -SGN(SGN(newy!) - 1) dot(count&).spd = ([email protected]@ - minspeed!) * RND + minspeed! dot(count&).angle = angle! dot(count&).xadd = SIN(angle! * radian#) * dot(count&).spd dot(count&).yadd = -COS(angle! * radian#) * dot(count&).spd dot(count&).clr = RGB (RND(0, 255), RND(0, 255), RND(0, 255)) ELSE dot(count&).angle = dot(count&).angle + 180 - (2 * dot(count&).angle) IF dot(count&).angle < 0 THEN dot(count&).angle = dot(count&).angle + 360 ELSEIF dot(count&).angle > 360 THEN dot(count&).angle = dot(count&).angle - 360 END IF dot(count&).yadd = -COS(dot(count&).angle * radian#) * dot(count&).spd newy! = dot(count&).y + dot(count&).yadd END IF END IF dot(count&).x = newx! dot(count&).y = newy! GRAPHIC SET PIXEL (INT(dot(count&).x), INT(dot(count&).y)), dot(count&).clr NEXT GRAPHIC SET POS (50, 50) GRAPHIC PRINT "Stars:"; GRAPHIC SET POS (120, 50) GRAPHIC PRINT "+ -"; GRAPHIC SET POS (150, 50) GRAPHIC PRINT dotcount&; GRAPHIC SET POS (50, 75) GRAPHIC PRINT "Speed:"; GRAPHIC SET POS (115, 75) GRAPHIC PRINT "\/ /\"; GRAPHIC SET POS (150, 75) GRAPHIC PRINT [email protected]@; GRAPHIC SET POS (50, 100) GRAPHIC PRINT "Angle:"; GRAPHIC SET POS (115, 100) GRAPHIC PRINT "<- ->"; GRAPHIC SET POS (150, 100) GRAPHIC PRINT angle!; GRAPHIC SET POS (50, 125) GRAPHIC PRINT "Turn Rate:"; GRAPHIC SET POS (120, 125) GRAPHIC PRINT "< >"; GRAPHIC SET POS (150, 125) GRAPHIC PRINT [email protected]@; GRAPHIC REDRAW GRAPHIC INKEY$ TO x$ SELECT CASE x$ CASE CHR$(27) 'Esc END CASE CHR$(0) + CHR$(75) 'Left arrow angle! = angle! - [email protected]@ IF angle! < 0 THEN angle! = angle! + 360 FOR count& = 1 TO dotcount& dot(count&).angle = dot(count&).angle - [email protected]@ IF dot(count&).angle < 0 THEN dot(count&).angle = dot(count&).angle + 360 END IF dot(count&).xadd = SIN(dot(count&).angle * radian#) * dot(count&).spd dot(count&).yadd = -COS(dot(count&).angle * radian#) * dot(count&).spd NEXT CASE CHR$(0) + CHR$(77) 'Right arrow angle! = angle! + [email protected]@ IF angle! => 360 THEN angle! = angle! - 360 FOR count& = 1 TO dotcount& dot(count&).angle = dot(count&).angle + [email protected]@ IF dot(count&).angle => 360 THEN dot(count&).angle = dot(count&).angle - 360 END IF dot(count&).xadd = SIN(dot(count&).angle * radian#) * dot(count&).spd dot(count&).yadd = -COS(dot(count&).angle * radian#) * dot(count&).spd NEXT CASE CHR$(0) + CHR$(72) 'up arrow IF [email protected]@ < 30 THEN [email protected]@ = [email protected]@ + .2 IF minspeed! < [email protected]@ THEN minspeed! = minspeed! + .02 FOR count& = 1 TO dotcount& IF dot(count&).spd < [email protected]@ THEN dot(count&).spd = dot(count&).spd + .2 dot(count&).xadd = SIN(dot(count&).angle * radian#) * dot(count&).spd dot(count&).yadd = -COS(dot(count&).angle * radian#) * dot(count&).spd END IF NEXT CASE CHR$(0) + CHR$(80) 'down arrow IF minspeed! > .4 THEN minspeed! = minspeed! - .02 IF [email protected]@ > 1 THEN [email protected]@ = [email protected]@ - .2 FOR count& = 1 TO dotcount& IF dot(count&).spd > [email protected]@ THEN dot(count&).spd = dot(count&).spd - .2 dot(count&).xadd = SIN(dot(count&).angle * radian#) * dot(count&).spd dot(count&).yadd = -COS(dot(count&).angle * radian#) * dot(count&).spd END IF NEXT CASE "=", "+" IF dotcount& + 25 =< 50000 THEN dotcount& = dotcount& + 25 REDIM PRESERVE dot(dotcount&) AS DotType FOR addcount& = dotcount& - 24 TO dotcount& dot(addcount&).x = w& * RND dot(addcount&).y = h& * RND dot(addcount&).angle = angle! dot(addcount&).spd = ([email protected]@ - minspeed!) * RND + minspeed! dot(addcount&).xadd = SIN(angle! * radian#) * dot(count&).spd dot(addcount&).yadd = -COS(angle! * radian#) * dot(count&).spd dot(addcount&).clr = RGB (RND(0, 255), RND(0, 255), RND(0, 255)) NEXT END IF CASE "-", "_" IF dotcount& - 25 => 25 THEN dotcount& = dotcount& - 25 REDIM PRESERVE dot(dotcount&) AS DotType END IF CASE ",", "<" IF [email protected]@ > .5 THEN [email protected]@ = [email protected]@ - .5 END IF CASE ".", ">" IF [email protected]@ < 50 THEN [email protected]@ = [email protected]@ + .5 END IF CASE " " bounce& = ABS(bounce& - 1) END SELECT LOOP END FUNCTION
Comment