![]() |
Forum Index : Microcontroller and PC projects : frames
Author | Message | ||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2375 |
Hi, why is this simple code not doing what I want ie. move a box over other boxes but not leave a trail. ' mode 2 FRAMEBUFFER CREATE f FRAMEBUFFER WRITE F cls rgb(black) for x=0 to 319 step 16' draw vertical boxes box x,0,8,239,0,,rgb(white) next x do for x2=0 to 319 FRAMEBUFFER COPY F,n' this shold redraw vertical boxes box x2,80,32,8,0,,rgb(yellow)' draw horizontal moving box next x2 loop do:loop end |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 9800 |
You need a layer buffer not a framebuffer and erase the box before the next move MODE 2 FRAMEBUFFER layer CLS RGB(black) For x=0 To 319 Step 16' draw vertical boxes Box x,0,8,239,0,,RGB(white) Next x FRAMEBUFFER write l lastx2=0 Do For x2=0 To 319 Box lastx2,80,32,8,0,,RGB(black)' draw horizontal moving box Box x2,80,32,8,0,,RGB(yellow)' draw horizontal moving box Pause 50 lastx2=x2 Next x2 Loop Do :Loop End |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2375 |
Thank you Peter sir. it's an optical illusion. the two horizontal yellow and blue blocks seem to step, one in front of the other but they move at the same speed. please post in vga demos. MODE 2 FRAMEBUFFER layer CLS RGB(black) For x=0 To 319 Step 16' draw vertical boxes Box x,0,8,239,0,,RGB(white) Next x FRAMEBUFFER write l lastx2=0 Do For x2=0 To 319 Box lastx2,80,32,8,0,,RGB(black)' draw horizontal moving box Box x2,80,32,8,0,,RGB(yellow)' draw horizontal moving box Box lastx2,140,32,8,0,,RGB(black)' draw horizontal moving box Box x2,140,32,8,0,,RGB(blue)' draw horizontal moving box Pause 50 lastx2=x2 Next x2 Loop Do :Loop |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4721 |
Hi Stan, It can be simplified a bit when you use SPRITE SCROLL. This scrolls a whole layer x,y pixels. Sprite scroll wraps around, so you do not have to redraw the boxes ever. It is a funny effect this opical illusion. MODE 2 FRAMEBUFFER layer CLS RGB(black) For x=0 To 319 Step 16' draw vertical boxes Box x,0,8,239,0,,RGB(white) Next x FRAMEBUFFER write l Box x2,80,32,8,0,,RGB(yellow)' draw horizontal box Box x2,140,32,8,0,,RGB(blue) ' draw horizontal box Do sprite scroll 1,0 'moves both boxes (whole layer L) 1 pixel right Pause 50 Loop Volhout P.S. the same SPRITE SCROLL is used in FLAPPY BIRD, where I scroll the pipes to the left, and background slowly right to give a nice effect. . Edited 2025-03-11 22:36 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
![]() |