Pages: 1
  Print  
Author Topic: Usage of tile_layer_find, Game Maker vs Enigma/LGM  (Read 1586 times)
Offline (Unknown gender) BTR
Posted on: July 12, 2014, 02:37:15 pm
Member
Joined: Jul 2014
Posts: 3

View Profile
Hello, here's another behaviour I can't quite understand, I'd would be thankful for some guidance.

This is the scenario: There is a tile layer (floor) and a 16x16 pixel block around 120 pixles above it. I want the block to fall down and stop falling as soon as it touches the floor.
This is the code in the step event of the block, the only code that object carries actually.
Code: [Select]
if not (tile_layer_find(10,self.x,self.y)) //10 is the depth of the tiled floor
{
vspeed = 2;
}
else
{
vspeed = 0;
}

When run in Game Maker 6.1, the block falls down and stops after touching the floor.
When using LGM/Enigma, it just hovers. When I change the code by simply remving the "not" part
Code: [Select]
if (tile_layer_find(10,self.x,self.y))
{
vspeed = 2;
}
else
{
vspeed = 0;
}
the block just falls down, through the tiled floor.

I've used the same file for both tests, so I didn't forget to check the tile layer depth.
Testing done in Linux Mint 17 64bit and Windows XP 32bit via Virtualbox. Any ideas what is causing this?
Logged
Offline (Unknown gender) TheExDeus
Reply #1 Posted on: July 12, 2014, 02:42:30 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
It should return -1 when not finding any tiles. So try this:
Code: [Select]
if (tile_layer_find(10,self.x,self.y) != -1)
{
vspeed = 2;
}
else
{
vspeed = 0;
}
But I don't think using tiles for collision is the best thing. You should probably use invisible block objects. Or even real physics engine (Box2D) if you prefer.
Logged
Offline (Male) Josh @ Dreamland
Reply #2 Posted on: July 12, 2014, 04:12:10 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
Yeah, tiles have not been optimized for quick searching, and are unlikely to be.

This makes me wonder how useful it would be if users could create collision meshes in the room editor.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) BTR
Reply #3 Posted on: July 12, 2014, 04:21:59 pm
Member
Joined: Jul 2014
Posts: 3

View Profile
@TheExDeus
Thank you for the suggestion.
For the time being I'll follow your advice with the invisble blocks. I still have some code from the Game Maker 6 days for a basic platformer/physcis engine, Guess I'll try to get this working then. (Prebaked physics aren't really my thing as I'm currently looking into relearning GML and not making an actual game)

@Josh @ Dreamland
Ah, that clarifies it a lot, thanks!
I used to do pretty much everything with objects in Game Maker 4, 5 and 6, and the room editors got really messy and slowed down. Didn't happen after switching to tiles.
But this was like 10 years ago, it shouldn't be a problem now.
Logged
Pages: 1
  Print