Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: thydowulays on January 20, 2012, 04:55:57 pm

Title: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: thydowulays on January 20, 2012, 04:55:57 pm
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!
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: parserp on January 20, 2012, 04:59:13 pm
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.
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: saintrunner on January 20, 2012, 05:00:58 pm
Wow I just posted something about me having the same problem!!!
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: parserp on January 20, 2012, 05:01:57 pm
I'm almost done with the scrolling level editor engine for metal slug. I'll post some code in a second. :)
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: saintrunner on January 20, 2012, 05:02:52 pm
Ok thanks :)
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: thydowulays on January 20, 2012, 05:04:09 pm
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
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: saintrunner on January 20, 2012, 05:05:33 pm
WOAH SAME HERE!!! wow nice to know someone else shares my problems
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: thydowulays on January 20, 2012, 05:06:25 pm
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.
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: parserp on January 20, 2012, 05:41:09 pm
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:
(http://img.removedfromgame.com/imgs/tilemap.gif)

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

EDIT: included source/executable :)

EDIT 2: screenie! :D
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: thydowulays on January 20, 2012, 05:47:04 pm
Whoa thanks bro, thats a lot of code..... Why are the numbers so big? Like how For(A,0,711 thanks :)
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: parserp on January 20, 2012, 05:48:35 pm
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
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: thydowulays on January 20, 2012, 05:53:24 pm
:O wow.
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: parserp on January 20, 2012, 06:09:13 pm
^^^ included source and executable in post above :D
(and screenie)
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: saintrunner on January 20, 2012, 07:08:07 pm
ok so parser, how would I change the tile map to say a floor ?
Title: Re: Tilemap scrolling for RPG game. One *tile* at a time, not a pixel. Please help!
Post by: turiqwalrus on January 21, 2012, 05:52:20 am
:.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 (http://www.omnimaga.org/index.php?action=articles;sa=view;article=46) tutorial may help, as it also includes a way to scroll entire tiles is its source