Animating Bullets
Animating Bullets
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.)
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
This code:
10 LET X=19
20 PRINT AT X,16;" ";TAB 16;"*";TAB 16;" "
30 LET X=X-1
50 GOTO 20
10 LET X=19
20 PRINT AT X,16;" ";TAB 16;"*";TAB 16;" "
30 LET X=X-1
50 GOTO 20
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Animating Bullets
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
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
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
Last edited by XavSnap on Thu Aug 11, 2022 8:08 pm, edited 1 time in total.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Animating Bullets
Bottom to the up side X=X-2x=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
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Animating Bullets
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
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
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Animating Bullets
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
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
Xavier ...on the Facebook groupe : "Zx81 France"(fr)