Author Topic: 16x16 tilemap smoothscrolling  (Read 2679 times)

0 Members and 1 Guest are viewing this topic.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
16x16 tilemap smoothscrolling
« on: April 03, 2012, 04:57:43 pm »
I'm trying to make stuff with 16x16 tilemap that smoothscrolls, but I don't know where to start. D:
Any helps?
Sig wipe!

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: 16x16 tilemap smoothscrolling
« Reply #1 on: April 03, 2012, 05:11:39 pm »
You can in general use the same algorithms and ideas from smoothscroll 8x8 tilemapping: just instead of incrementing the draw by 8, increment by 16, etc. Instead of a single pt-on(), you can use 4 pt-on()s or you can try the bitmap command if you want. I haven't tested this code btw, just wrote it on the spot but it should work (I might have reversed the Y buttons by accident..idr)
Code: [Select]
.Super simple unoptimized with a 16x16 map and 16x16 tiles
[MAPDATA]->GDB1
[TILES]->Pic1
Repeat getkey(15)
getKey(3)-getKey(2)+X->X
getKey(1)-getKey(4)+Y->Y
For(A,0,4
For(B,0,6
subroutine(B*16-(X^16),A*16-(Y^16),{Y/16+B*16+A+(X/16)+GDB1}*32+Pic1)
End
End
DispGraphClrDraw
End
Lbl subroutine
Pt-On(r1,r2,r3)
Pt-On(r1+8,r2,r3+8)
Pt-On(r1,r2+8->r2,r3+16)
Pt-On(r1+8,r2,r3+24)
Return
If you would rather use Horizontal and Vertical instead of redrawing every frame, you can still use the same engine as Horizontal/vertical 8x8 just with similar tweaks as the above example. The easiest way you call your 16x16 routine to redraw the whole set of edge tiles, but you can also try to optimize by only drawing the two 8x8 tiles of the 16x16 that would be necessary. I don't have a lot of experience with these types of tilemappers though :P while they can be faster I personally find the redraw-every-frame approach cleaner and more flexible. To each his own.
« Last Edit: April 03, 2012, 07:25:39 pm by squidgetx »

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: 16x16 tilemap smoothscrolling
« Reply #2 on: April 03, 2012, 06:38:05 pm »
I tried the code. :D
But the scrolling seems kinda strange. D:
(pressing Left/Right scrolls the up/down a bit)
Sig wipe!

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: 16x16 tilemap smoothscrolling
« Reply #3 on: April 03, 2012, 07:26:23 pm »
Sorry, code edited ({B+Y*16+A+X..} should've been {Y/16+B*16+A+(X/16)..})