Author Topic: Help with tilemap collision?  (Read 8940 times)

0 Members and 1 Guest are viewing this topic.

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Help with tilemap collision?
« Reply #15 on: January 11, 2012, 05:02:11 pm »
haha that's totally fine. Everyone forgets these things, most especially me.
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Re: Help with tilemap collision?
« Reply #16 on: January 11, 2012, 05:46:41 pm »
Wait, I have a question. If I had the routine GT, with {r2/8*12+(r1/8)+GBD1}=r3, and I did this:
If sub(GT,X,Y-8,2)
End
Would that test to see if the tile had a number 02? Like I could do this:
If sub(GT,X,Y-8,2)
Y-8->Y
Pause 500
End
ElseIf sub(GT,X,Y-8,3)
Pause 500
End


Nevermind, I got it. However, does anyone know a routine to say, move a tile up or down, or left or right? Like, edit the little [01000000000000001]->GBD1 sorta thing via a routine in game?
That would make it so I could move through tile 02, but not tile 03. Would that work?
« Last Edit: January 11, 2012, 05:53:07 pm by thydowulays »
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Help with tilemap collision?
« Reply #17 on: January 12, 2012, 05:44:27 pm »
yes, but you'll want to make a copy of your map data and modify that, so you don't screw up your map for permanent.

To acces the Yth element down and the Xth element across, go like this:

{Y*WIDTH_OF_MAP + X + START_OF_MAP_DATA}

So, to move a tile to the left, say:

Code: [Select]
{Y*WIDTH_OF_MAP + X + START_OF_MAP_DATA}->{Y*WIDTH_OF_MAP + X-1 + START_OF_MAP_DATA}

And so on
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline C0deH4cker

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 258
  • Rating: +11/-1
    • View Profile
    • iNinjas Forum/Repo
Re: Help with tilemap collision?
« Reply #18 on: January 12, 2012, 06:13:41 pm »
In my programs where I want to edit my maps, I first copy the maps to L1 or some other free ram area during level loading. I usually have three map functions:

Code: [Select]
DrawMap(mapPtr, tilePics)
GetTile(mapPtr, x, y) .x and y are actual screen coords. Function just divides each by 8 to get the tile that contains the point specified.
SetTile(mapPtr, row, col, value)

Then you can access and modify your map very easily.

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Help with tilemap collision?
« Reply #19 on: January 25, 2012, 06:09:49 pm »
hmmm, I can't think of a good way to erase a tile from the map. Is there a fast way to draw it every frame?
Every way that I've tried it, it is too slow. :-\
« Last Edit: January 25, 2012, 06:09:55 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
Re: Help with tilemap collision?
« Reply #20 on: January 25, 2012, 09:42:04 pm »
Parser, to erase an individual tile from the map, you basically take leafy's routine:
Code: [Select]
Lbl GT
{r2/8*12+(r1/8)+GDB1}
Return
And turn it into this:
Code: [Select]
Lbl ST
{r2/8*12+(r1/8)+GDB1}->r3
Return
Then, you would just have to do ST(X,Y,0 and the tile at position X,Y will be converted into 00.
What do you mean by fast drawing?

EDIT: Leveled up! W00t!
« Last Edit: January 25, 2012, 09:42:35 pm by thydowulays »
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Help with tilemap collision?
« Reply #21 on: January 25, 2012, 10:01:13 pm »
Did you mean:

Code: [Select]
Lbl ST
r3->{r2*12+r1+GDB1}
Return

Also I think he meant actually erasing the tile from the screen. Parser you can do that by drawing a Rect( and a RectI( at the coordinates of the tile.
In-progress: Graviter (...)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Help with tilemap collision?
« Reply #22 on: January 25, 2012, 10:14:01 pm »
Also I think he meant actually erasing the tile from the screen. Parser you can do that by drawing a Rect( and a RectI( at the coordinates of the tile.
...or a single Pt-Off() if the tile is 8x8.  If its smaller than 8x8 you can use Pt-Mask()r to erase and redraw the new tile just like Pt-Off().
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Help with tilemap collision?
« Reply #23 on: January 25, 2012, 10:34:41 pm »
actually yes, I was referring to physically erasing a tile from the buffer. I'll try trying using 'Rect' and 'Pt-Mask'. Thanks guys! :D

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Help with tilemap collision?
« Reply #24 on: February 08, 2012, 05:19:35 am »
Just a little optimisation:

x+1->x

Becomes:

x++

Same with x--
;)

But is faster
Code: [Select]
getKey(4)?Y--
End

than?
Code: [Select]
If getKey(4)
Y-1->Y
End

i think there should be many bytes and cycles won, but not much

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: Help with tilemap collision?
« Reply #25 on: February 08, 2012, 07:03:44 am »
But is faster
Code: [Select]
getKey(4)?Y--
End

than?
Code: [Select]
If getKey(4)
Y-1->Y
End
Nope, that's the same. ;)
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Help with tilemap collision?
« Reply #26 on: February 08, 2012, 03:29:39 pm »
Really? I thought that would be faster, or lighter...

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Help with tilemap collision?
« Reply #27 on: February 08, 2012, 03:30:32 pm »
This has been alot of help! :D

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Help with tilemap collision?
« Reply #28 on: February 08, 2012, 03:31:55 pm »
You'r welcome! ;)