I'm trying to create some simple randomly generated "obstacles" for my game. These obstacles are just singular playfield pixels that I turn on in playfield row 11 so they will scroll down during the next draw. The pixels are being created and turned off correctly, and everything seems to be running at full speed.
The problem is that playfield pixels (seemingly inbetween rows 10 and 11) flash randomly at the bottom of the screen. I've tried putting my pixeldrawing code after drawscreen and the same thing occured.
Below is the extracted code for my background - even with just the background code running, the flickering continues. If I rem out the pfpixel call for my created pixel, the flickering stops!
Please help a newb out! Thanks!
init
COLUPF = 36
COLUBK = 44
scorecolor = 14
rem --- stores rand to add to the playfield uses r
dim pfadd = r
pfadd = 10
rem --- draw the playfield borders
pfvline 0 0 11
pfvline 1 0 11
pfvline 30 0 11
pfvline 31 0 11
pfpixel 2 0 on:pfpixel 29 0 on:pfpixel 2 1 on:pfpixel 3 1 on
pfpixel 28 1 on:pfpixel 29 1 on:pfpixel 2 2 on:pfpixel 28 2 on
pfpixel 29 2 on:pfpixel 29 3 on:pfpixel 2 4 on:pfpixel 2 5 on
pfpixel 3 5 on:pfpixel 2 6 on:pfpixel 29 6 on:pfpixel 28 7 on
pfpixel 29 7 on:pfpixel 2 8 on:pfpixel 29 8 on:pfpixel 2 9 on
pfpixel 3 9 on:pfpixel 2 10 on:pfpixel 3 10 on:pfpixel 29 10 on
rem --- vertical bar on sides
PF0=128
mainloop
rem --- randomize the playfield
rem -- first clear out old pixels
pfhline 4 11 27 off
rem -- then generate new pixel in row 11 between columns 4 and 27 inclusive
pfadd = rand
if pfadd > 72 then goto skip
if pfadd > 48 then pfadd = pfadd - 48
if pfadd > 24 then pfadd = pfadd - 24
pfadd = pfadd + 3
pfpixel pfadd 11 on
skip
pfscroll down
drawscreen
goto mainloop