Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1404595 Posts in 68399 Topics- by 62051 Members - Latest Member: paypaladin

January 29, 2023, 11:26:24 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsGrandma: GM Platformer Engine
Pages: 1 ... 4 5 [6] 7
Print
Author Topic: Grandma: GM Platformer Engine  (Read 102218 times)
lasttea999
Level 2
**


View Profile
« Reply #100 on: April 21, 2012, 12:26:23 PM »

@lasttea999 I'm not 100% but I think the only difference in terms of collision detection is that this engine checks for a collision before movement while GM's inbuilt collision detection checks for a collision after movement. So they are both doing the same amount of checking, it's just at different points in the code.

I don't know about GM, but I think--- based on what little I've learned about other collision-checking systems--- that some other systems do things like

-move every object *once* according to their velocities, look for collisions among objects, and then move each colliding object out of its collisions once,

whereas the Grandma engine

-moves each object floor(abs(velocity)) times, checking each time if that object collides with each other object.

So basically, with Grandma's method, the checks rapidly increase with the number of objects and the speed of each object. It seems that the only big advantages this method has over the other method I mentioned is its simplicity and the amount of control you get over the movement. I rather like this advantage, but I want to know if it's worth the loss in efficiency. And while I probably won't need a more advanced engine, for more advanced physics, the capabilities of Grandma's method seem a bit narrow.

EDIT: Oh, allow me to mention that I like how the positions of objects are always restricted to integers, which I guess is part of the simplicity of the engine.
Logged

PureQuestion
Level 4
****



View Profile
« Reply #101 on: May 03, 2012, 10:46:42 PM »

Is this even still linked anywhere on your site, or is it basically just here?

Fixed the link again! Sorry for always forgetting about it when I change hosts haha. It's at http://mattmakesgames.com/matt/GrandmaEngine.gmk

My question was "does the actual site if you go there via the domain contain any reference to the grandma engine or that link?"
Logged

lasttea999
Level 2
**


View Profile
« Reply #102 on: May 04, 2012, 01:52:37 PM »

My question was "does the actual site if you go there via the domain contain any reference to the grandma engine or that link?"

Ah, right. Sorry for the mistake.

I wonder if Mr. Thorson still uses the methods of this engine?
« Last Edit: May 04, 2012, 02:02:31 PM by lasttea999 » Logged

Matt Thorson
Level 7
**

c'est la vie


View Profile WWW
« Reply #103 on: May 04, 2012, 03:43:39 PM »

Figured I'd chime in since there's a few questions:

1) Does my site link to Grandma at all? Nope, it's just hidden away in that directory. I have a fear that the engine will be outdated at some point by Game Maker development. And I'm not really qualified anymore to provide any sort of Game Maker-related support, since I haven't used or thought about the software in years.

2) On the efficiency issue, and whether I still use the algorithm in my work:

Yes, it's a slow method (relative to other methods). The advantage, as has been said, is in the amount of control you gain. Game Maker normally moves the object, then does a single collision check against every other object. Grandma moves the object pixel-by-pixel, doing checks for each tiny movement. This is obviously much much slower. In deciding whether to use this method in your Game Maker project, consider the amount of objects that will be using it. In my Game Maker platformers, the player character uses this method while other moving objects use the built-in hspeed/vspeed or other simple alternatives. Player control is obviously much more important in these games than, say, how an enemy moves, because it is the player's direct interface with the game. This can be different for different games, so choose accordingly and be aware of the cost of the decision.

Give Up, Robot and Give Up Robot 2 both used this method, adapted for use in FlashPunk (first v0.8 and then v1.0, respectively). This algo also happens to be great for robust moving platform logic (integer positions simplify it a lot).

My new engines all have easy ways to get the top/bottom/left/right bounds of any given game entity, so I can simplify it to a single collision check, allow floating-point positions, and snap to the edges of hitboxes on collision. However, there is a sacrifice that comes along with this optimization: all hitboxes must be solid rectangles. Example: If I'm inside a hollow rectangle and I hit the border, snapping to the "left" of that hollow rectangle will warp me outside of it. So I still have to decide which method to use based on the needs of the game Smiley
Logged

lasttea999
Level 2
**


View Profile
« Reply #104 on: May 04, 2012, 05:35:57 PM »

Figured I'd chime in since there's a few questions:

Thank you very much for your feedback!

I'm having a little difficulty seeing exactly how the the edges of the hitboxes are checked (you're not checking how the various rectangular hitboxes overlap, are you?), how that reduces the collision checks, and what exactly "a single collision check" means (I'm guessing something like "once per frame per player object per floor object"?).

I realize I've already been quite forward in asking for feedback, but if you ever find the opportunity within your busy schedule, perhaps you could write up a short tutorial on some of your newer engines and methods? The Grandma engine doesn't necessarily have to end with your usage of Game Maker, does it? Smiley
Logged

Houndninja
Guest
« Reply #105 on: May 13, 2012, 02:15:00 AM »

Hey man this is a really good engine! I can see alot to be done with this!
Logged
Matt Thorson
Level 7
**

c'est la vie


View Profile WWW
« Reply #106 on: June 01, 2012, 11:35:08 AM »

I just posted some FlashPunk Platformer engine code that resembles Grandma Engine, in case anyone is interested Smiley

Actor: http://pastebin.com/H441PktM
Solid: http://pastebin.com/pfAnw4Qk
Logged

Ant
Guest
« Reply #107 on: June 01, 2012, 12:32:33 PM »

I just posted some FlashPunk Platformer engine code that resembles Grandma Engine, in case anyone is interested Smiley

Actor: http://pastebin.com/H441PktM
Solid: http://pastebin.com/pfAnw4Qk

Am I the only one that finds all code other than GML thoroughly incomprehensible?
Logged
lasttea999
Level 2
**


View Profile
« Reply #108 on: June 01, 2012, 02:23:24 PM »

I just posted some FlashPunk Platformer engine code that resembles Grandma Engine, in case anyone is interested Smiley

Actor: http://pastebin.com/H441PktM
Solid: http://pastebin.com/pfAnw4Qk

Thank you for the code! I'm afraid I don't really know much about FlashPunk, but is the Entity class something included with FlashPunk? And are the collision functions you're using here also included with FlashPunk? I'm wondering how the collision checking works.



Am I the only one that finds all code other than GML thoroughly incomprehensible?

Some of the syntax seems a little mysterious! Have you programmed with anything other than Game Maker?
Logged

JMickle
Level 10
*****



View Profile
« Reply #109 on: June 03, 2012, 12:18:43 PM »

did you seriously write
Code:
if (onCollide != null) ...

comon mannnnn
Logged

Matt Thorson
Level 7
**

c'est la vie


View Profile WWW
« Reply #110 on: June 06, 2012, 12:53:15 PM »

did you seriously write
Code:
if (onCollide != null) ...

comon mannnnn

What's wrong with that? It's correct syntax. If I had typed:

Code:
if (onCollide) ...

That would force the compiler to coerce a Function to a Boolean. Which would be doable, but less clear to the reader imo (because it implies onCollide is a bool, and even throws compiler warning flags I believe).
Logged

JMickle
Level 10
*****



View Profile
« Reply #111 on: June 07, 2012, 01:45:04 AM »

ahhh I was getting it mixed up with collide(), I didn't realise it was a callback function.

whoops  Facepalm
Logged

ChevyRay
Level 2
**



View Profile
« Reply #112 on: June 08, 2012, 12:10:26 PM »

You should still do it with collide() if you want to write clear code. collideWith() on the other hand actually returns a bool.

Anyways, that's kinda veering off-topic, but yeah.
Logged
Zanza
Level 0
**


View Profile
« Reply #113 on: November 26, 2012, 04:02:50 AM »

Hey there, I've started messing with this engine and I like it quite a bit. I've noticed something, though. In the stageGoto script, it uses a execute_string function. This seems to work perfectly for what it's supposed to do. However, I looked it up, and most people advise not using it. Also, Game Maker Studio no longer supports it. Are there any alternatives that can be used in case I need to port it to GMS?

EDIT: I found the answer to this after more google searching. The answer can be found here http://gmc.yoyogames.com/index.php?showtopic=556430
« Last Edit: November 26, 2012, 05:33:40 PM by Zanza » Logged
Trystin
Level 4
****


Nyoom


View Profile WWW
« Reply #114 on: December 21, 2012, 04:23:40 PM »

Simple, but I likes it. Thanks  Grin
Logged

Rat Casket
Level 10
*****


i can do what i want


View Profile WWW
« Reply #115 on: January 11, 2013, 10:48:25 PM »

This is a great engine. I've had a lot of fun tweaking it to meet my needs and I really really appreciate all of the work that went into this.
« Last Edit: January 12, 2013, 10:32:37 PM by Rabbit » Logged

GMMike
TIGBaby
*


View Profile
« Reply #116 on: June 06, 2013, 07:58:11 AM »

Can someone explain this section from obj_moveable's end step?
Code:
h_counter += hspd;
v_counter += vspd;
h = round( h_counter );
v = round( v_counter );
h_counter -= h;
v_counter -= v;

Wouldn't it be more simple just to:
Code:
h = round(hspd)
v = round(vspd)

or am I missing something?
Logged
ink.inc
Guest
« Reply #117 on: June 06, 2013, 08:03:53 AM »

it allows for subpixel movement

iirc h_counter builds up until it's greater than/equal to 1, then adds it on to the x coordinate
Logged
lasttea999
Level 2
**


View Profile
« Reply #118 on: June 06, 2013, 02:59:53 PM »

Can someone explain this section from obj_moveable's end step?

I'd like to elaborate on what John Sandoval said: basically, the feature GMMike brought up lets objects move at speeds that aren't whole numbers.

Imagine what would happen if we used h = round(hspd), and hsp was 0.3:

First, round(hsp) would evaluate to 0 (it would round down from 0.3 to 0).
Then, h would be set to 0.
Thus, the object doesn't move at all in the horizontal direction.

This happens every frame; every frame, h is set to 0. So even though the object would have a non-zero speed of 0.3, it wouldn't move horizontally.
Logged

moody
TIGBaby
*


View Profile
« Reply #119 on: June 29, 2013, 08:29:29 PM »

Anyone managed to add moving platforms to this engine yet? There was an attached example but the link is dead now.  Sad
Logged
Pages: 1 ... 4 5 [6] 7
Print
Jump to:  

Theme orange-lt created by panic