Author Topic: Checking location in Tilemap and changing GDB value.  (Read 10911 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #15 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?

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #16 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.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #17 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?

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #18 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.
« Last Edit: March 09, 2011, 05:57:23 pm by jkag »

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #19 on: March 10, 2011, 05:28:17 pm »
bump

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #20 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?

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #21 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

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #22 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.


« Last Edit: March 10, 2011, 06:00:59 pm by yunhua98 »

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #23 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

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #24 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.  ;)
« Last Edit: March 10, 2011, 06:05:25 pm by yunhua98 »

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #25 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
« Last Edit: March 10, 2011, 06:19:16 pm by jkag »

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #26 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}

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #27 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?

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Checking location in Tilemap and changing GDB value.
« Reply #28 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]

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Checking location in Tilemap and changing GDB value.
« Reply #29 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.