OK, so I got this code I made by myself. This is very weird to be honest. I only had to really use tile_layer_find, which was very, very useful. You don't need any objects for the wall, just a tileset and all solid tiles at the same depth. You needn't use GMS:2 for basic tile collision. Spoiler:
I coded this at another computer.
Code:
//Vertical or ground collision if !tile_layer_find(layer,x,y+16) vspeed += 0.5 else { vspeed = 0 if keyboard_check_pressed(vk_space) vspeed = -12 }
//Collision from above if tile_layer_find(layer,x,y-16) { y+=1 vspeed = 0 }
//Leftward collision if tile_layer_find(layer,x-16,y) { hspeed = 0 if keyboard_check(vk_right) && !keyboard_check(vk_left) x+=1 else x = xprevious } else { if keyboard_check(vk_left) hspeed -= 0.5 }
//Rightward collision if tile_layer_find(layer,x+16,y) { hspeed = 0 if keyboard_check(vk_left) && !keyboard_check(vk_right) x-=1 else x = xprevious } else { if keyboard_check(vk_right) hspeed += 0.5 }
//Friction if !keyboard_check(vk_left) && !keyboard_check(vk_right) { if hspeed > 0 hspeed -= 0.5 if hspeed < 0 hspeed += 0.5 }
//Maxspeed if hspeed > 4 hspeed = 4 if hspeed < -4 hspeed = -4
There are a few quirks with this code, but maybe it could do the job.
Feel free to criticize.
OK, so I got this code I made by myself. This is very weird to be honest. I only had to really use tile_layer_find, which was very, very useful. You don't need any objects for the wall, just a tileset and all solid tiles at the same depth. You needn't use GMS:2 for basic tile collision.
[spoiler]I coded this at another computer.[/spoiler]
[code]
//Vertical or ground collision
if !tile_layer_find(layer,x,y+16)
vspeed += 0.5
else
{
vspeed = 0
if keyboard_check_pressed(vk_space) vspeed = -12
}
//Collision from above
if tile_layer_find(layer,x,y-16)
{
y+=1
vspeed = 0
}
//Leftward collision
if tile_layer_find(layer,x-16,y)
{
hspeed = 0
if keyboard_check(vk_right) && !keyboard_check(vk_left)
x+=1
else x = xprevious
}
else
{
if keyboard_check(vk_left)
hspeed -= 0.5
}
//Rightward collision
if tile_layer_find(layer,x+16,y)
{
hspeed = 0
if keyboard_check(vk_left) && !keyboard_check(vk_right)
x-=1
else x = xprevious
}
else
{
if keyboard_check(vk_right)
hspeed += 0.5
}
//Friction
if !keyboard_check(vk_left) && !keyboard_check(vk_right)
{
if hspeed > 0
hspeed -= 0.5
if hspeed < 0
hspeed += 0.5
}
//Maxspeed
if hspeed > 4
hspeed = 4
if hspeed < -4
hspeed = -4
[/code]
There are a few quirks with this code, but maybe it could do the job.
Feel free to criticize.
Last edited by SMBXfan on Tue May 30, 2017 3:10 pm, edited 1 time in total. _________________
Trolling, how not to behave!
Quote:
Quote:
If I were to give you a rating, it would be -1 out of 10. Don't forget!
mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!
I guess this works, but there's no reason to use tile collision in Game Maker. All it does is give you potentially less control over the environment building and make moving solid elements way more complex to program (as well as slopes).
I guess this works, but there's no reason to use tile collision in Game Maker. All it does is give you potentially less control over the environment building and make moving solid elements way more complex to program (as well as slopes).
I would rather use objects to generate tiles than use tiles as solids. Since Studio allows one to visually stretch objects in the level editor, one can design objects that create tiles across the area they cover, saving the work of tiling.
I would rather use objects to generate tiles than use tiles as solids. Since Studio allows one to visually stretch objects in the level editor, one can design objects that create tiles across the area they cover, saving the work of tiling.
Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?
Let's say that you are developing for something like a game console or there are a lot of objects in the room. The script works because of the fact that you don't have to use more objects within the room, and you could use it.
Sure, as Magnemania said, it wouldn't work with slopes, but it only works for basic stuff. If you are doing a game that is like SMB1, without slopes and all, you would save having to place solids on every solid tile, and all the game would have to do is check for a tile instead of a solid.
Hey, even I said my code was weird.
UPDATE: This is becoming the post for all my scripts, so I will organize all my scripts into one place.
[quote="DJ Coco"]Why though[/quote]
Let's say that you are developing for something like a game console or there are a lot of objects in the room. The script works because of the fact that you don't have to use more objects within the room, and you could use it.
Sure, as Magnemania said, it wouldn't work with slopes, but it only works for basic stuff. If you are doing a game that is like SMB1, without slopes and all, you would save having to place solids on every solid tile, and all the game would have to do is check for a tile instead of a solid.
Hey, even I said my code was weird. :biggrin:
UPDATE: This is becoming the post for all my scripts, so I will organize all my scripts into one place.
_________________
Trolling, how not to behave!
Quote:
Quote:
If I were to give you a rating, it would be -1 out of 10. Don't forget!
mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!
"Why" is the worst question to ask when somebody writes more efficient code than you.
Aw, crap!
This looks like a "sick burn" but I was actually just in a hurry to write it so it comes off as rude lol.
More elaborately: this code is appears (to my non-GM-developer eyes) as more efficient, and while it might not be extremely useful for making GM lag less (I can't say either way), treating tiles as non-objects is good practice if you ask me.
[quote="SMBXfan"][quote="HylianDev"]"Why" is the worst question to ask when somebody writes more efficient code than you.[/quote]
Aw, crap![/quote]
This looks like a "sick burn" but I was actually just in a hurry to write it so it comes off as rude lol.
More elaborately: this code is appears (to my non-GM-developer eyes) as more efficient, and while it might not be extremely useful for making GM lag less (I can't say either way), treating tiles as non-objects is good practice if you ask me.
But it must be probably hard to make it work on moving tiles or slopes.
Yeah. I agree with that.
But wait, could we use another layer for the slopes? Then again, that would be counter-intuitive.
[quote="SuperArthurBros"]I could actually use that.
But it must be probably hard to make it work on moving tiles or slopes.[/quote]
Yeah. I agree with that.
But wait, could we use another layer for the slopes? Then again, that would be counter-intuitive.
_________________
Trolling, how not to behave!
Quote:
Quote:
If I were to give you a rating, it would be -1 out of 10. Don't forget!
mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!
"Why" is the worst question to ask when somebody writes more efficient code than you.
If you're that concerned about the efficiency of your game because of GM's bloated objects you might as well make your own data structure. Repeatedly checking the tile layer is not only sacrificing so much functionality, but it's so insignificantly faster, it really doesn't matter. In fact, while testing the min FPS were actually lower using the tile approach most of the time, with the lowest I got being 60 using tile layers, and 200+ using objects. It only becomes relevant when you use an insane amount of objects, but in that case you should rethink how you use the objects and why you need that many instances to begin with.
[quote="HylianDev"]"Why" is the worst question to ask when somebody writes more efficient code than you.[/quote]If you're that concerned about the efficiency of your game because of GM's bloated objects you might as well make your own data structure. Repeatedly checking the tile layer is not only sacrificing so much functionality, but it's so insignificantly faster, it really doesn't matter. In fact, while testing the min FPS were actually lower using the tile approach most of the time, with the lowest I got being 60 using tile layers, and 200+ using objects. It only becomes relevant when you use an insane amount of objects, but in that case you should rethink how you use the objects and why you need that many instances to begin with.
_________________
Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?
"Why" is the worst question to ask when somebody writes more efficient code than you.
If you're that concerned about the efficiency of your game because of GM's bloated objects you might as well make your own data structure. Repeatedly checking the tile layer is not only sacrificing so much functionality, but it's so insignificantly faster, it really doesn't matter. In fact, while testing the min FPS were actually lower using the tile approach most of the time, with the lowest I got being 60 using tile layers, and 200+ using objects. It only becomes relevant when you use an insane amount of objects, but in that case you should rethink how you use the objects and why you need that many instances to begin with.
This looks like a "sick burn" but I was actually just in a hurry to write it so it comes off as rude lol.
More elaborately: this code is appears (to my non-GM-developer eyes) as more efficient, and while it might not be extremely useful for making GM lag less (I can't say either way), treating tiles as non-objects is good practice if you ask me.
My elaboration is closer to how I feel. I'm not well-versed in Game Maker at all. I just remember that using objects for tiles in Flash, without some kind of clever mapping system, turned your game into a slideshow. This tells me that objects for tiles is inherently kind of an inefficient way of doing it since tiles don't need all of the features objects have. Whenever I program tile systems, I always use a 2D array for tile maps, only draw the relevant ones, etc. It's kinda hard to make your map lag your game when your map is a bunch of integers lol.
[quote="[url=http://phpbb.mfgg.net/viewtopic.php?p=509642#p509642]DJ Coco[/url]"][quote="HylianDev"]"Why" is the worst question to ask when somebody writes more efficient code than you.[/quote]If you're that concerned about the efficiency of your game because of GM's bloated objects you might as well make your own data structure. Repeatedly checking the tile layer is not only sacrificing so much functionality, but it's so insignificantly faster, it really doesn't matter. In fact, while testing the min FPS were actually lower using the tile approach most of the time, with the lowest I got being 60 using tile layers, and 200+ using objects. It only becomes relevant when you use an insane amount of objects, but in that case you should rethink how you use the objects and why you need that many instances to begin with.[/quote]
[quote="[url=http://phpbb.mfgg.net/viewtopic.php?p=509607#p509607]HylianDev[/url]"]This looks like a "sick burn" but I was actually just in a hurry to write it so it comes off as rude lol.
More elaborately: this code is appears (to my non-GM-developer eyes) as more efficient, and while it might not be extremely useful for making GM lag less (I can't say either way), treating tiles as non-objects is good practice if you ask me.[/quote]
My elaboration is closer to how I feel. I'm not well-versed in Game Maker at all. I just remember that using objects for tiles in Flash, without some kind of clever mapping system, turned your game into a slideshow. This tells me that objects for tiles is inherently kind of an inefficient way of doing it since tiles don't need all of the features objects have. Whenever I program tile systems, I always use a 2D array for tile maps, only draw the relevant ones, etc. It's kinda hard to make your map lag your game when your map is a bunch of integers lol.
Game Maker isn't Flash though. If tiles were such an inherently better choice than objects they wouldn't need to exist in the first place.
Game Maker, while certainly not the fastest game engine out there, runs perfectly fine if you don't fill your entire scene mindlessly with thousand of objects without any optimization.
All I'm saying is that tile collsions are kind of redundant and a needlessly circuitious way to set up your scene, and while it can be interesting to see if you can pull it off, it's a weird way to take if optimization is your prime concern.
Game Maker isn't Flash though.
If tiles were such an inherently better choice than objects they wouldn't need to exist in the first place.
Game Maker, while certainly not the fastest game engine out there, runs perfectly fine if you don't fill your entire scene mindlessly with thousand of objects without any optimization.
All I'm saying is that tile collsions are kind of redundant and a needlessly circuitious way to set up your scene, and while it can be interesting to see if you can pull it off, it's a weird way to take if optimization is your prime concern.
_________________
Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum