Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:28 27 Mar 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : frames

Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2375
Posted: 06:50pm 10 Mar 2025
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 9800
Posted: 07:16pm 10 Mar 2025
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2375
Posted: 08:55pm 10 Mar 2025
Copy link to clipboard 
Print this post

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: Netherlands
Posts: 4721
Posted: 12:30pm 11 Mar 2025
Copy link to clipboard 
Print this post

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
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2025