Learning Spectrum Next basic part 4 - Tile map scrolling

time2 yr agoview3 views

#spectrumnext #nexbasic #zxspectrum

How I worked out the tile map scrolling on the Next

I am replacing greater than and less than with { } because YT does not allow

10 RUN AT 0:layer 2,1:cls:LAYER DIM 16,0,239,191 20 load "1-40.spr" bank 14: tile bank 14 30 LOAD "40tiles.map" BANK 15 40 TILE DIM 15,0,40,16: rem setup the tile map area stored in bank 15 starting at 0 with 40 tiles wide 45 let m=0: let m1=0:rem m = tile taken from the complete map and m1 = tile for the screen 50 for x=0 to 15:tile 1,12 at x,0 to x,0: pause 1:next x : rem this should be tile but I used this fpr the demo 60 rem PAUSE 1 65 let ll=0 : rem loop of 0 } 16 for scroll before drawing new tile 70 FOR l=0 TO 384 :rem loop of length to scroll in pixels 40 x 16 80 IF l } 255 THEN l2=l-256: rem if you scroll past 255 subtract 255 81 if l{256 then l2=l: rem if not use this 82 m= INT (l/16): rem divide the x scroll pixel by 16 83 m1= int(l2/16) : rem device the screen scroll by 16 85 rem PRINT AT 1,1;" l ";l;" ";m;" ";" m1 ";m1;" l2 ";l2 86 ll=ll+1: rem inc the loop for 16 87 IF ll=15 THEN TILE 1,12 AT m+16,0 TO m1,0:ll=0: rem draw new tiles every 16 pixels 88 layer at l2,0: rem scroll the screen 90 rem PAUSE 1 100 NEXT l 190 rem Pause 1 200 FOR l=384 TO 0 STEP -1:rem scroll backwads 205 if l } 255 THEN l2=l-256 210 if l{256 then l2=l 215 m1= int(l2/16) 220 m=int(l/16) 230 rem PRINT AT 1,1;" l ";l;" ";m;" " 240 ll=ll+1 250 IF ll=15 THEN TILE 1,12 AT m,0 TO m1,0:ll=0 260 LAYER AT l2,0 270 rem PAUSE 1 280 NEXT l 290 pause 1 300 goto 70

Loading comments...