Author Topic: AXE Tilemaping - Please help!  (Read 6276 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
AXE Tilemaping - Please help!
« on: December 18, 2012, 02:34:52 pm »


Well, I have the basics down: here's my code (copied from graph link, so there are still weird chars):

Code: [Select]
.TILEMAP

ExprOn

[020202020202020202020202]üGDB1
[020000000000000000000002]
[020000000000000000000002]
[020000000000000000000002]
[020000000000000000000002]
[020000000000000000000002]
[020000000000000000000002]
[020202020202020202020202]

[7E7E427EFF7E7E42]üPic1
[FFFFFFFFFFFFFFFF]
[55AA55AA55AA55AA]

0ü{L+0}
0ü{L+1}

Repeat (getKey(15))
sub(Á)

If (0)
Lbl Á

If ((getKey(1)) and (pxl-Test(48,40)õ=0))
{L+1}-1ü{L+1}
Pause 250
End

If ((getKey(4)) and (pxl-Test(48,31)õ=0))
{L+1}+1ü{L+1}
Pause 250
End

If ((getKey(2)) and (pxl-Test(47,32)õ=0))
{L+0)+1ü{L+0}
Pause 250
End

If ((getKey(3)) and (pxl-Test(56,32)õ=0))
{L+0}-1ü{L+0}
Pause 250
End

Return
End

ClrDraw
ClrDrawõ
For(X,0,11)
For(Y,0,7)
If {(Y*12)+X+GDB1}
Pt-On((X*8)+({L+0}*8),(Y*8)+({L+1}*8),({(Y*12)+X+GDB1}*8)+Pic1)
Pt-On((X*8)+({L+0}*8),(Y*8)+({L+1}*8),8+Pic1)õ
End
End
End
Pt-On(48,32,Pic1)
DispGraphClrDraw
End

My problem (the tutorials aren't really helping):

How do I do this type of tilemap WITHOUT rendering the ENTIRE map every step taken?

Example (hypothetical): I have a 96x144 tilemap and want to only render the 8x12 in the tilemap that should be visible.
I am Bach.

Offline stevon8ter

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 663
  • Rating: +10/-0
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #1 on: December 18, 2012, 02:40:21 pm »
I think it's ok as it is now

The

Code: [Select]
For(X,0,11)
For(Y,0,7)
If {(Y*12)+X+GDB1}
Pt-On((X*8)+({L+0}*8),(Y*8)+({L+1}*8),({(Y*12)+X+GDB1}*8)+Pic1)
Pt-On((X*8)+({L+0}*8),(Y*8)+({L+1}*8),8+Pic1)õ
End
End
End

makes it so that it starts at X and Y, and then maps 8 tiles down and 12tiles right...
So it's always 8*12

Tho the IF statement isn't nescecarry... if you change your pt-on statement a bit, you've got it without the extra (memmory taking...) if-statement

EDIT: also, if you'dd drew the sprite 1 time... then storepic L3
and then every loop, before the map routine, do recalpic L3 ... then you don't need the ClrDraw and you don't have to loop through the draw command anymore... which will save a little speed (only a tiny bit)
« Last Edit: December 18, 2012, 02:42:33 pm by stevon8ter »
None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #2 on: December 18, 2012, 02:47:38 pm »
but when I add a 13th column and change the (Y*12)s to (Y*13)s and nothing else, It only renders the initial screen, and not the 13th column when I move.
« Last Edit: December 18, 2012, 02:48:51 pm by pimathbrainiac »
I am Bach.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: AXE Tilemaping - Please help!
« Reply #3 on: December 18, 2012, 02:49:17 pm »
That's because in the For loop you'll have to change the X range from 1 to 12.
In-progress: Graviter (...)

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #4 on: December 18, 2012, 02:52:10 pm »
but when I change it to For(X,{L+0},{L+0}+11) It get weird when I move
« Last Edit: December 18, 2012, 02:57:07 pm by pimathbrainiac »
I am Bach.

Offline stevon8ter

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 663
  • Rating: +10/-0
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #5 on: December 18, 2012, 04:33:12 pm »
Use something like:

Code: [Select]
for(X,0,11)
For(Y,0,7)
pt-on(X*8,Y*8,{<number of rows> * C + D + GDB0}*8+Pic0)
End
End

GDB0 = mapdata
Pic1= all the tiles...
C = 'X'-var (if moved right, raise one, if moved left, lower 1, initialise with 0 (or whatever row you wanna start on))
D = 'Y'-var

Set up pic0 like this
[0000000000000000]->pic0
[FFFFFFFFFFFFFFFF]

That means, if the map says 00 , it will pic the 0*8 +pic0 tile, which is the empty one
And if map says 01 , it will take the 1*8+pic0 tile, which is the full black one

Do you get it?
Any questions? (If there's a misstake, it's from the head + on ipod)
None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #6 on: December 18, 2012, 05:44:52 pm »
Well, using your solution, and by surrounding my map with null bytes, IT WORKED!!! :w00t:
I am Bach.

Offline stevon8ter

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 663
  • Rating: +10/-0
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #7 on: December 18, 2012, 06:30:37 pm »
You're welcome , first time i was able to help someone here on omnimaga :D
None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: AXE Tilemaping - Please help!
« Reply #8 on: December 18, 2012, 08:41:49 pm »
If your using greyscale you have to do +16 instead of +8.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #9 on: December 18, 2012, 09:21:13 pm »
Not greyscale (yet)
I am Bach.

Offline GinDiamond

  • LV3 Member (Next: 100)
  • ***
  • Posts: 71
  • Rating: +2/-2
  • I dont always fail at life, but when I do, I dont
    • View Profile
Re: AXE Tilemaping - Please help!
« Reply #10 on: March 04, 2014, 05:43:20 pm »
*bump*

Is it okay if I use this awesome code for a roguelike Im making? I was looking for a tutorial JUST LIKE THIS and I found it here!

Thanks!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: AXE Tilemaping - Please help!
« Reply #11 on: March 05, 2014, 03:34:14 am »
Hi,

I think it should be fine as long as you give the author credits.