Good Idea Games‎ > ‎

Time Throttle: Dev Journal 9

posted Oct 10, 2017, 9:07 PM by Good Idea Games
Inheritance.
This tutorial covers the basics of inheritance in Game Maker.

I've got a problem where the player object gets 'stuck' on obstacles in the game. I *suspect* this is because a collision causes some small amount of overlap, and ends up locking the player object in place.

If I apply move_bounce_solid(true) to the player object, this applies a good bounce effect, but this 'automatic' bounce doesn't reduce speed, so a fast moving player starts to bounce like a pinball. Not the behavior i'm looking for.

So I need to write my own collision handling code. This is a good opportunity to learn about inheritance.

The practical purpose is to put my player collision code in a parent object, so all player objects inherit the same collision properties.

I also augmented the YoYo Games Recommend Controller Implementation to create additional player spawn pads in a vertical row, preventing new players from spawning atop one another.
obj_spawn_pad is a non-solid starting line whose purpose is to posess x,y coordinates where a player should spawn.

if !(instance_exists(player[pad]))         // Check to see if an instance is associated with this pad index
        {
        //Create a new spawn pad, located on top of starting spawn pad
        instance_create(obj_spawn_pad.x, obj_spawn_pad.y, obj_spawn_pad)
        //Identify instance number of new spawn pad
        player_pad_instance = instance_find(obj_spawn_pad, pad)
        //move spawn_pad down, according to player number
        player_pad_instance.y = player_pad_instance.y - 80*pad
        // Create a player object, spawn it on the new spawn pad, and assign it a gamepad number
        player[pad] = instance_create(player_pad_instance.x, player_pad_instance.y, object_player);
        with (player[pad])
            {
            image_index = pad;
            pad_num = pad;
            }
        }
Comments