Skip to content

Commit

Permalink
Merge pull request #7 from deanblackborough/EnemyBaseObject
Browse files Browse the repository at this point in the history
Base class for patrolling enemies
  • Loading branch information
deanblackborough authored Dec 21, 2024
2 parents 3bc5bde + a67750d commit 69aab6e
Show file tree
Hide file tree
Showing 19 changed files with 317 additions and 17 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

A basic platformer starter project for Game Maker. I'm creating this as a starting point for myself and my kids, I'll get all the basics working for them and then we can all create our own games.

I'm adding many more comments that I would normally, these are to explain what each section of code does so my kids can easily see which parts of the code they may need to modify.
I'm adding many more comments than I would normally, these are to explain what each section of code does so my kids can easily see which parts of the code they may need to modify.

I'm only building the basics of each feature, if you decide to use this starter project you are probably going to need to tweak things here and there.

Check out a game my Son is building using this starter kit [here](https://github.com/jackblackborough/platformer-starter) - it gives you and idea on how to use the Project - you should but your stuff in MyGame and extend the base objects and inherit the create step to make changes.

I've working on `showDebug` options. The intention is if you set it to true in the create event for an object useful values and
information will display to help explain what is happening - this is very much to do/work in progress.

Expand All @@ -30,7 +32,7 @@ Check the `player/scripts/playerInput` script file, the controls should be what
- Gravity setting and terminal velocity setting
- Max jumps setting
- Jump through platforms
- Moving jump through platforms, move in x and/or y
- Moving jump through platforms, move in x and/or y, set speed a target
- Player collision with ground
- Player collision with jump through platforms
- Player collision with moving jump through platforms
Expand All @@ -40,32 +42,26 @@ Check the `player/scripts/playerInput` script file, the controls should be what
- Player single ground slide
- Ground slide and ground dash have a cooldown
- Player sprites for idle, running, jumping (up and down), dashing & slide
- Patrolling enemy base class - similar to moving platforms, set speed and target

## In progress

- Need to show debug values/ranges for moving platforms
- You can slide and then end up in a ground object

## To Do

- Debug option to show colliders on objects, players
- Solid platforms - for puzzles
- Air Dash
- Rolling
- Wall climb & Wall hang
- Breakable walls/platforms
- Ladders
- HUD

## How to run

- Download Game Maker
- Download the Project
- Open the Project in Game Maker and press play

## Bugs & issues

There are three know bugs currently - these will be fixed at some point

- If a moving jump through platform is moving in x and y there is a little player wobble when the platform moves in positive x and y
- You can get stuck if you are right at the edge of a moving platform and connect with a ground object
- You can dash and slide at the same time if you are quick

## Credits

Expand Down
6 changes: 5 additions & 1 deletion gm-platformer.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions objects/oEnemyPatrol/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
enemyMovementSpeed = 1;
enemyMovementDirection = 1;

enemySpeedY = 0;

deltaX = 0;
targetX = xstart + moveInXAmount;
incrementX = true;

enemySprite = sEnemyIdle;
enemySpriteIdle = sEnemyIdle;
enemySpriteRun = sEnemyIdle;
enemySpriteFacing = 1;

gravitySpeed = 0.3;
gravityTerminalSpeed = 6;

// Quality options
snapToColliders = true;

// Debugging
showDebug = false;
11 changes: 11 additions & 0 deletions objects/oEnemyPatrol/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
draw_sprite_ext(
sprite_index,
image_index,
x,
y,
image_xscale * enemySpriteFacing,
image_yscale,
image_angle,
image_blend,
image_alpha
);
105 changes: 105 additions & 0 deletions objects/oEnemyPatrol/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Variables for object

// enemySpeedX = float
// moveInXAmount = float

sprite_index = enemySpriteIdle;
image_speed = 1;


/*****************************************
*
* Ground collision in x
*
*****************************************/

if (place_meeting(x + enemySpeedX, y, oGround))
{

if (snapToColliders)
{
snapToColliderOnX(enemySpeedX, oGround);
}

enemySpeedX = 0;
}



/*****************************************
*
* Assign gravity to the enemy
*
*****************************************/

enemySpeedY += gravitySpeed;

if (enemySpeedY > gravityTerminalSpeed) {
enemySpeedY = gravityTerminalSpeed;
}

/*****************************************
*
* Ground collision in y
*
*****************************************/

if (place_meeting(x, y + enemySpeedY, oGround))
{
enemySpeedY = 0;

setPlayerOnGround(true);
}

var nextFrameX = x;
if (incrementX == true)
{
nextFrameX += enemySpeedX;
deltaX = nextFrameX - xprevious;

if (nextFrameX >= targetX)
{
incrementX = false;
}
} else {
nextFrameX -= enemySpeedX;
deltaX = nextFrameX - xprevious;

if (nextFrameX <= xstart)
{
incrementX = true;
}
}


/*****************************************
*
* Move the player
*
*****************************************/

x = nextFrameX;
y += enemySpeedY;


/*****************************************
*
* Switch the sprite
*
*****************************************/

if (incrementX = false)
{
enemySpriteFacing = -1;
}
else
{
enemySpriteFacing = 1;
}

if (enemySpeedX == 0)
{
sprite_index = enemySpriteRun;
mask_index = enemySpriteRun;
image_speed = 1;
}
43 changes: 43 additions & 0 deletions objects/oEnemyPatrol/oEnemyPatrol.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions options/main/options_main.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion rooms/room01/room01.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 69aab6e

Please sign in to comment.