Page 1 of 1

Animating Bullets

Posted: Thu Aug 11, 2022 7:01 pm
by MrVertigo
When I’m animating a bullet going up the screen, like in Space Invaders, I do something along these lines:

10 Let x=20
20 print at x,16;”*”
30 let x=x+1
40 print at x-1,16;” “
50 GOTO 20

Is there another, better, way to do this in BASIC (not machine code)?

I also know about swapping CLS for line 40, but it seems too much flicker for me. Swapping lines 30 and 40 is simpler code (with the -1 removed) but also seems to flicker more. (Not sure if that’s my imagination.)

Re: Animating Bullets

Posted: Thu Aug 11, 2022 7:37 pm
by XavSnap
This code:
10 LET X=19
20 PRINT AT X,16;" ";TAB 16;"*";TAB 16;" "
30 LET X=X-1
50 GOTO 20

Re: Animating Bullets

Posted: Thu Aug 11, 2022 7:46 pm
by MrVertigo
Thank you!

Re: Animating Bullets

Posted: Thu Aug 11, 2022 7:57 pm
by MrVertigo
Using these methods, is there anyway to control the speed? I sometimes change to x=x+2 to make it go faster, but again, it flickers a lot.

Re: Animating Bullets

Posted: Thu Aug 11, 2022 8:00 pm
by XavSnap
O this code (not a MC code):
Use the DF_CC system variable = "PRINT AT" video memory offset.

10 LET X=20
20 PRINT AT X,16;"*";
25 POKE (PEEK 16399*256+PEEK 16398)+32,0
30 LET X=X-1
50 IF X>=0 THEN GOTO 20
60 RUN

Re: Animating Bullets

Posted: Thu Aug 11, 2022 8:05 pm
by XavSnap
x=x+2
Bottom to the up side X=X-2
Up to the bottom side=X=X+2

Down:
10 LET X=0
20 PRINT AT X,16;"*";
25 POKE (PEEK 16399*256+PEEK 16398)-1,0
30 LET X=X+1
50 IF X<18 THEN GOTO 20
60 RUN



Up:
10 LET X=20
20 PRINT AT X,16;"*";
25 POKE (PEEK 16399*256+PEEK 16398)-1,0
30 LET X=X-1
50 IF X>0 THEN GOTO 20
60 RUN


Just change LET X=X-1 >>> LET X=X-2

Re: Animating Bullets

Posted: Thu Aug 11, 2022 8:14 pm
by XavSnap
Withis this code:
10 LET X=19
20 PRINT AT X,16;" ";TAB 16;"*";TAB 16;" "
30 LET X=X-1
50 GOTO 20


You had to add a space line: (2 space " " due to the bidirectional move, use one eraser space in case of up to down move)
10 LET X=19
20 PRINT AT X,16;" ";TAB 16;TAB 16;"*";TAB 16;TAB 16;" "
30 LET X=X-2
50 GOTO 20

Re: Animating Bullets

Posted: Thu Aug 11, 2022 8:26 pm
by XavSnap
To limit the flicking during the display, erase the dot before print a new one.
Keep the printed dot location in the memory, and retrieve it after the BASIC scan process .
The first erased dot in poked in the ROM (POKE 3,0).
The A variable had to be set...

5 LET A=PI
10 LET X=20
20 POKE A,0
25 PRINT AT X,16;"*";
30 LET A=(PEEK 16399*256+PEEK 16398)-1
40 LET X=X-1
50 IF X>0 THEN GOTO 20
55 POKE A,0
60 RUN

Re: Animating Bullets

Posted: Thu Aug 11, 2022 9:10 pm
by MrVertigo
Brilliant! 🙏