Author Topic: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!  (Read 6080 times)

0 Members and 1 Guest are viewing this topic.

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Hey everyone, it's been a while. Anyways, I've been working on a building/economic game sort of similar to minecraft, but I really want to implement scrolling. I don't want it to scroll a pixel at a time, I want it to be a tile. I would also have the player *not* stay in the middle when scrolling, because I already have a perfect movement and collision engine. Thanks for all your help!
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
well, the only difference from scrolling a pixel at a time to a tile at a time is instead of:
Code: [Select]
:X++
do this:
Code: [Select]
:X+[width of tile]->X
:P

I seem to be having a little trouble understanding the question.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Wow I just posted something about me having the same problem!!!
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
I'm almost done with the scrolling level editor engine for metal slug. I'll post some code in a second. :)

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Ok thanks :)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Okay, and I just mean scrolling in General, I don't really know how to scroll a tilemap at all, but for the purpose of my game I want it to be a tile at a time
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
WOAH SAME HERE!!! wow nice to know someone else shares my problems
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
lol yeah. I know a lot about regular tilemaps, even getting and setting individual tiles. I just don't know anything about scrolling ones :D

EDIT: lol. im embarrassed. I said "even getting and setting individual tilemaps" I meant tiles.
« Last Edit: January 20, 2012, 05:23:41 pm by thydowulays »
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Well, here's the source of the scrolling a tile at a time, but note: Y doesn't scroll, only X does.
(this is the full source)



:.MSEDIT
:.metal slug level editor
:DiagnosticOff
:.store some crap into the tilemap
:For(A,0,711
:rand^2+0->{L1+A}
:End
:.curser
:[3C3CFFFFFFFF3C3C]->Pic1
:.the tile (only 1 currently)
:[FFFFFFFFFFFFFFFF]->Pic2
:.X position of tilemap
:0->X
:.X position of curser
:48->J
:.Y position of curser
:32->K
:Repeat getKey(15)
:.get the tilemap's position
:X/8->E
:X^8->F
:For(A,0,12
:A*8-F->C
:For(B,0,8
:Pt-On(C,B*8,{B*89+A+E+L1}*8+Pic2
:End
:End
:Pt-Change(J,K,Pic1
:DispGraphClrDraw
:If getKey(1) and (K<55)
:K+8->K
:End
:.see if at left side of tilemap
:If X=0
:If getKey(2) and (J>0)
:J-8->J
:End
:If getKey(3) and (J=48)
:8->X
:End
:If getKey(3) and (J<48)
:J+8->J
:End
:End
:.see if at right side of tilemap
:If X=704
:If getKey(3) and (J<87)
:J+8->J
:End
:If getKey(2) and (J=48)
:696->X
:End
:If getKey(2) and (J>48)
:J-8->J
:End
:End
:If getKey(2) and (X>0) and (X<704)
:X-8->X
:End
:If getKey(3) and (X<704) and (X>0)
:X+8->X
:End
:If getKey(4) and (K>0)
:K-8->K
:End
:End


screenie:


and that's it. ask with any questions :D

EDIT: included source/executable :)

EDIT 2: screenie! :D
« Last Edit: January 20, 2012, 06:50:33 pm by parser padwan »

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Whoa thanks bro, thats a lot of code..... Why are the numbers so big? Like how For(A,0,711 thanks :)
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
well, the numbers are so big because the tilemap is 89 tiles across... O.O

but this can easily be adapted to smaller tilemaps too. ;D

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
:O wow.
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
^^^ included source and executable in post above :D
(and screenie)
« Last Edit: January 20, 2012, 07:10:36 pm by parser padwan »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
ok so parser, how would I change the tile map to say a floor ?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline turiqwalrus

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 840
  • Rating: +51/-2
  • Wheeeeeee~!
    • View Profile
:.store some crap into the tilemap
:For(A,0,711
:rand^2+0->{L1+A}
:End
IIRC, replace this part of the code with something like this:
:[0101010101010101010101010101... -> {L1}

Also, this tutorial may help, as it also includes a way to scroll entire tiles is its source