Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: XVicarious on March 08, 2011, 11:12:48 pm

Title: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 08, 2011, 11:12:48 pm
This is old, I figured this out.
Spoiler For Spoiler:
So...

I would like to test if my cursor (x,y) is on my sprite, no variables right now and its always at the same position. I would like it to change Pic pointers. From Say Pic0R to Pic0B, but the catch is that it does it to adjacent tiles as well.. I've even kind of lost myself here...

Um... Here.

x = red
y = blue
z = green

XXXXX
XYYYX
XYXYX
XYYYX

now if you 2nd the x in the middle of the Ys, the Ys change to Xs. But I have no clue how to change these in Axe or even check if I clicked in the correct space...
I'll ask about the menu after I get this answered...

Now that I finished that... How would I check what tile I am on and change tiles around it? Okay I have
X = tile 0
Y = tile 1
x = tile 0 with cursor
XXXXX
XYYYX
XYxYX
XYYYX

if I second x, i want to check the values in a square around it, and up them by one. like 00 -> 01 and 01 -> 02 and 02 -> 00. But the thing is, each tile will have a different way they change the surrounding tiles. If I could figure out one, i could figure out the rest. I used Nemo's tilemapping example (http://ourl.ca/7512/130274 (http://ourl.ca/7512/130274)) and made a few changes so that it did a 5x4 grid.
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: Deep Toaster on March 08, 2011, 11:19:07 pm
So...

I would like to test if my cursor (x,y) is on my sprite, no variables right now and its always at the same position. I would like it to change Pic pointers. From Say Pic0R to Pic0B, but the catch is that it does it to adjacent tiles as well.. I've even kind of lost myself here...

You can't really test if you're on a sprite directly (except with a mass of pxl-Test('s), but you can store the X- and Y-positions of the object, then test to see if it's within 8 of the X- and Y-value of the cursor.
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: AngelFish on March 08, 2011, 11:26:53 pm
I'm confused as to how you have red, blue, or green anything on a monochrome screen ???
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: XVicarious on March 08, 2011, 11:32:18 pm
Oh, well I'm remaking a game. It was easier for me to think of it that way lol. Okay, I figured that. I suppose i could figure which one i am on because X will equal 8*column and same with Y... well row. But how about changing the "color" of them, or do I have a mass of different states of them?
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: Deep Toaster on March 08, 2011, 11:35:25 pm
Oh, well I'm remaking a game. It was easier for me to think of it that way lol. Okay, I figured that. I suppose i could figure which one i am on because X will equal 8*column and same with Y... well row. But how about changing the "color" of them, or do I have a mass of different states of them?

If everything's confined to a grid, that's a great idea. Tilemaps make things a lot easier :)
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: XVicarious on March 08, 2011, 11:48:04 pm
No, no tilemap. Just drew all... 20 sprites lol. But reading Cmpwn's tutorial on Tilemapping right now. I only have 3 sprites so...
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: jnesselr on March 09, 2011, 07:32:10 am
It would be easiest to have the tilemap somewhere in ram, and have values that correspond to the sprites (With only 3 sprites, you can fill an entire 12*8 sprite screen in only 24 bytes @ 2 bits per tile), and change them in the stored data, and redraw when needed.
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: XVicarious on March 09, 2011, 03:08:38 pm
Okay... So I followed Cmpwn's tutorial... And got some strange results? Can this maybe because 1) How my sprites are formatted in "Pic0T" or 2) Just the version of Axe parser?

I'm just totally lost lol... My grid is a 5x4 grid, only 20 sprites on the screen at a time (not including the title i did as a sprite, which is 5 sprites).
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: DJ Omnimaga on March 09, 2011, 03:20:53 pm
Isn't SirCmpwn tutorial for Axe 0.07 or something? I am not convinced it is still valid for current versions of Axe anymore.
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: XVicarious on March 09, 2011, 03:22:18 pm
D: Oh no lol. How shall I learn now!? lol.
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: DJ Omnimaga on March 09, 2011, 03:23:21 pm
I don't know. Hopefully someone can help you soon. I think it would be best to rename the topic title to reflect it is now about tilemapping, check older topics about tilemapping and start a new one if you can't find anything, though.
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: XVicarious on March 09, 2011, 03:28:35 pm
I found a simple little thing from nemo on how to do it, gonna try it now. I'm gonna rename the topic anyhow because the title is confusing lol
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: DJ Omnimaga on March 09, 2011, 03:29:28 pm
Ok good to hear. Good luck! :D
Title: Re: Testing Location and a Menu (that also includes the first thing)
Post by: XVicarious on March 09, 2011, 03:36:19 pm
Yep, It works but it will not work on a 5x4 set, and returns crap on the 5th column. It will do a 4x5 though, but that doesn't work for my game :/

edit: Fixed it :D  :D
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 09, 2011, 04:04:18 pm
Updated :D

sorry for double post :O
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: Munchor on March 09, 2011, 05:42:56 pm
From what I got from the rest of the topic, are you using a tilemap?

Then my question is, do you have variables for your current position (as in (X,Y))?

I personally don't like tilemaps so I don't know much about them, but kind of understand how they work and I believe you need variables for your location.

In addition, can you paste the *entire* code?
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 09, 2011, 05:45:59 pm
*Entire* code of what? I do have a location variable. X and Y. I switched the tilemapper to I and J.
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: Munchor on March 09, 2011, 05:52:59 pm
*Entire* code of what? I do have a location variable. X and Y. I switched the tilemapper to I and J.

The entire code of your program, it's easier for me and most of us to help you if we can read it.

If you have your location variables, what exactly do you need help with?
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 09, 2011, 05:55:01 pm
the second part
Quote
like 00 -> 01 and 01 -> 02 and 02 -> 00. But the thing is, each tile will have a different way they change the surrounding tiles.
I have no idea to do this. The last time i ran into this in a project i just dropped it.

I'm SourceCoding the files now.
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 10, 2011, 05:28:17 pm
bump
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: yunhua98 on March 10, 2011, 05:35:08 pm
I've been working on a generic tilemapper with lots of comments, its pretty much done now, and when I upload it, I'm going to write a short tutorial explaining it.  ;)

Stay tuned, i should get it done by tomorrow.  For now, could you explain again what the problem is?
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 10, 2011, 05:37:11 pm
Checking what tile im on, but its really just 8*column and 8*row and interact with that piece. And change it. like if in the tilemap its 00, change to 01. but store it to a temp tilemap so it won't over write the main one in case they want to play that level again
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: yunhua98 on March 10, 2011, 05:58:00 pm
Does your program have scrolling?  If it does, does the character stay put while the screen shifts around it?  or does the screen stay still?  If the character stays put with the screen scrolling, read the spoiler.  ;)

if the screen stays put.  (i.e. theres only one screen)  you can have a Var and add/subtract 1
when you move sideways and add/subtract the width of the entire map when you move up and down.

And for storing a level to a temp tile map, you can just store each level to its own pointer, and have a special pointer, like GDB0 or whatever, and copy the levels to that pointer when you switch levels. 

Ex.
Code: [Select]
://Data for Level1->GDB1
://Level2->GDB2
:...
:when you switch levels:
:Copy(GDB1,GDB0,'size'
and when you display the levels, just always use GDB0

Sorry if this isn't very clear.
Spoiler For Spoiler:
I think I know what your asking, tell me if its not.  ;)

lets say your position is X and Y

if your coordinates are incremented by 8 each time you move, divinde X and Y by 8, otherwise keep it as it is.  ;)

now, let W be how wide your map is, once you spread it all out, not on a calc screen.

I'm assuming you're storing your maps like this, with each byte being a tile.

ex.
Code: [Select]
:[010101010000000001010101->GDB1
:[010101010101010101010101
:[...

then, take your Y coordinate, multiply it by W, add X, and thats the location of the top corner of your screen.


Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 10, 2011, 06:02:34 pm
Good idea thanks... Now about modifying the map? I have an idea for deciding which tiles need modifying, but modifying them itself I have no clue. This is where I got stuck on another project, not related to this one at all :P
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: yunhua98 on March 10, 2011, 06:05:06 pm
when your modifying a specific tile in the program, you can do this:

Code: [Select]
Assuming you've already stored your data,
:'new tile #'->{'byte #'+GDB0}

although you need to use relative pointing if you do it this way.

may I see your code?  you could PM it to me, I need to know how you're storing your data in order to help you correctly.  ;)
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 10, 2011, 06:08:32 pm
Yeah sure. I'm not quite sure if what I have is up to date because I just had a ram reset this morning in Physics :/
I'll edit with the code.

edit: yeah the source I had wasn't up to date :/ I hadn't backed up what I had before the crash, but this is what I am using, a tad modified though to use it as a 5x4 map.

Code: [Select]
For(Y,0,3
   For(X,0,4
      Pt-On(X*8,Y*8,{Y*5+X+GDB0}*8+Pic0T
   End
End
DispGraph
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: yunhua98 on March 10, 2011, 06:21:15 pm
ok, I see...
This will probably be covered on my upcoming tutorial, except this doesn't have scrolling...

What I said above should work.  ;)

but to be more specific, the tile your on is your characters Y coordinate * 5 + your characters X coordinate all divided by 8  ;)

and to store different tiles to the data, just do 'new tile #'->{'position'+GDB1}
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 10, 2011, 06:25:52 pm
Okay thanks! One more question, how would I switch levels? You already explained that I think, but how would I have it choose what one to do? I use the format for my levels GDB00 GDB01 etc... Like how would I increment the level?
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: yunhua98 on March 10, 2011, 06:29:42 pm
If each level's the same size, you could do this.

Let S be the size of your levels (in bytes)
Code: [Select]
:0->L  \\for level number
:[code]
:.Next Level
:Sub(NXT)
:[code]
:Lbl NXT
:L+S->L
:Copy(GDB1+L,GDB0,S)  \\make sure your leves are stored in order if you do it this way!!
:Return
[/code][/code]
Title: Re: Checking location in Tilemap and changing GDB value.
Post by: XVicarious on March 10, 2011, 06:31:10 pm
Okay, not exactly how I store the levels, but it should work and be easy to adapt.