[ 14 posts ]  Reply to topicPost new topic 
SMBXFan's Code, NO GMS:2 REQUIRED.
Author Message
 [gb]
 Post subject: SMBXFan's Code
PostPosted: Mon May 29, 2017 6:28 pm 
User avatar
Just cooking food for my Yoshi.
Member
[*]
[*]
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:

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.


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!
scaled image

mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!


My Gaming forum, called "The Gamer's Castle"!
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Tile Collision
PostPosted: Tue May 30, 2017 3:46 am 
User avatar
Kootie Patootie
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
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).

_________________
Image
My mains
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Tile Collision
PostPosted: Tue May 30, 2017 9:30 am 
User avatar
Lawful Evil
Member
[*]
[*]
[*]
[*]
[*]

[*]
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.

_________________
Image
Magikoopa Security Force, the Mario Action-Strategy game!
  It's time to fight for Bowser!
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: Tile Collision
PostPosted: Tue May 30, 2017 10:14 am 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Why though

_________________
Image

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?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Tile Collision
PostPosted: Tue May 30, 2017 3:07 pm 
User avatar
Just cooking food for my Yoshi.
Member
[*]
[*]
DJ Coco wrote:
Why though


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!
scaled image

mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!


My Gaming forum, called "The Gamer's Castle"!
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: SMBXFan's Code
PostPosted: Tue May 30, 2017 3:40 pm 
Always have Jason Voorhees in your sig
Member
[*]
[*]
[*]
[*]
[*]

"Why" is the worst question to ask when somebody writes more efficient code than you.

_________________
Image

Image Image
Bibby Team | MFGG3 Github
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: SMBXFan's Code
PostPosted: Tue May 30, 2017 4:04 pm 
User avatar
Just cooking food for my Yoshi.
Member
[*]
[*]
HylianDev wrote:
"Why" is the worst question to ask when somebody writes more efficient code than you.


Aw, crap!

_________________
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!
scaled image

mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!


My Gaming forum, called "The Gamer's Castle"!
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: SMBXFan's Code
PostPosted: Tue May 30, 2017 5:28 pm 
Always have Jason Voorhees in your sig
Member
[*]
[*]
[*]
[*]
[*]

SMBXfan wrote:
HylianDev wrote:
"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.

_________________
Image

Image Image
Bibby Team | MFGG3 Github
 
Top
Offline 
 User page at mfgg.net
 
 [br]
 Post subject: Re: SMBXFan's Code
PostPosted: Tue May 30, 2017 7:47 pm 
User avatar
Not a bird
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
I could actually use that.

But it must be probably hard to make it work on moving tiles or slopes.

_________________
Please contact me for any broken links below.
Spoiler:

Spoiler:
 
Top
Offline 
 
 
 [gb]
 Post subject: Re: SMBXFan's Code
PostPosted: Tue May 30, 2017 8:27 pm 
User avatar
Just cooking food for my Yoshi.
Member
[*]
[*]
SuperArthurBros wrote:
I could actually use that.

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.

_________________
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!
scaled image

mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!


My Gaming forum, called "The Gamer's Castle"!
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: SMBXFan's Code
PostPosted: Wed May 31, 2017 5:49 am 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
HylianDev wrote:
"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.

_________________
Image

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?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: SMBXFan's Code
PostPosted: Wed May 31, 2017 12:17 pm 
Always have Jason Voorhees in your sig
Member
[*]
[*]
[*]
[*]
[*]

DJ Coco wrote:
HylianDev wrote:
"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.

HylianDev wrote:
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.

_________________
Image

Image Image
Bibby Team | MFGG3 Github
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: SMBXFan's Code
PostPosted: Wed May 31, 2017 12:34 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
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.

_________________
Image

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?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: SMBXFan's Code
PostPosted: Wed May 31, 2017 8:06 pm 
User avatar
Just cooking food for my Yoshi.
Member
[*]
[*]
Well, that's why even I said my code is weird.

_________________
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!
scaled image

mfgg is bad i hate it cuz meiro is totes terre sonac IS betar!!


My Gaming forum, called "The Gamer's Castle"!
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 14 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 1 guest


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
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group