Author Topic: Tilemap Collisions  (Read 5789 times)

0 Members and 1 Guest are viewing this topic.

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Tilemap Collisions
« on: November 02, 2011, 07:26:01 pm »
How do you create exact tilemap collisions in Axe?  My routine to access the value of a tile divides x and y by 4, which is the size of each tile, but means that there is only a collision if it overlaps on the right or is exactly aligned.  It does not register collisions on the left.  How can I register a collision on any overlap?

Offline C0deH4cker

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 258
  • Rating: +11/-1
    • View Profile
    • iNinjas Forum/Repo
Re: Tilemap Collisions
« Reply #1 on: November 02, 2011, 10:29:53 pm »
Dont test for pixels. If youre moving to the right, check if there's a solid tile that is one tile to the right. if not, then keep moving.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Tilemap Collisions
« Reply #2 on: November 04, 2011, 04:03:33 am »
This:
but collision s the most complicated!, Damn!
Tile based works perfectly. I use this:
Code: [Select]
:If getKey(2) and (X≠0)
:sub(CC,X,Y,X,Y+7
:!If R
:X-1→X
:End
:End
Just to check for a tile on the left. Now you figure out how to check for tiles in the other 3 directions :)
Code: [Select]
:Lbl CC
:{r2/8*12+(r1/8)+GDB1}→r5
:{r4/8*12+(r3/8)+GDB1}→r6
:r5+r6→R
:Return
If you like my work: why not give me an internet?








Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Tilemap Collisions
« Reply #3 on: November 04, 2011, 10:22:19 am »
Changed for prettification and I think also speed gain:

Code: [Select]
:If getKey(2)
:If X
:!If CC(X,Y,X,Y+7)
:X--
:End
:End
:End
:
:
:Lbl CC
:{r2/8*12+(r1/8)+GDB1}→r5
:{r4/8*12+(r3/8)+GDB1}→r6
:r5+r6→R
:Return

I just love function based programming so much :)
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 Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Tilemap Collisions
« Reply #4 on: November 04, 2011, 12:32:08 pm »
Changed for prettification and I think also speed gain:

Code: [Select]
:If getKey(2)
:If X
:!If CC(X,Y,X,Y+7)
:X--
:End
:End
:End
:
:
:Lbl CC
:{r2/8*12+(r1/8)+GDB1}→r5
:{r4/8*12+(r3/8)+GDB1}→r6
:r5+r6→R
:Return

I just love function based programming so much :)
And so do I :D
If you like my work: why not give me an internet?








Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Tilemap Collisions
« Reply #5 on: November 04, 2011, 12:42:01 pm »
uhh, a full commitment what I'm thinking of ?
lol.
I'm not a nerd but I pretend:

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: Tilemap Collisions
« Reply #6 on: November 04, 2011, 12:43:32 pm »
could someone please show me how to do this in lua?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Tilemap Collisions
« Reply #7 on: November 04, 2011, 10:13:47 pm »
Flyingfisch, I would ask that question in a new thread in a different forum.
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 Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Tilemap Collisions
« Reply #8 on: November 05, 2011, 03:17:13 pm »
could someone please show me how to do this in lua?
Same principle, but a different syntax :)
If you like my work: why not give me an internet?








Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Re: Tilemap Collisions
« Reply #9 on: November 06, 2011, 05:42:17 pm »
If I have 4x4 tiles, I should change the /8 to /4 right?  What does the x12 do?

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Tilemap Collisions
« Reply #10 on: November 06, 2011, 05:50:37 pm »
I'm guessing the *12 was because in an 8*8-tile map, it's 12 tiles wide.  For a 4*4-tile map it's 24 tiles wide.
Vy'o'us pleorsdti thl'e gjaemue