-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from deanblackborough/EnemyBaseObject
Base class for patrolling enemies
- Loading branch information
Showing
19 changed files
with
317 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Binary file added
BIN
+761 Bytes
...s/041e5a64-66cb-4b95-9741-ba6693cc22f4/82b415de-6014-4d11-a391-ecf515c7abc9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+767 Bytes
...s/218a96c9-7dd2-45ba-8bb6-8a4f1c5b33cf/82b415de-6014-4d11-a391-ecf515c7abc9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+824 Bytes
...s/490280fc-0c07-4468-a180-4bfb1bfbc30a/82b415de-6014-4d11-a391-ecf515c7abc9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+775 Bytes
...s/d7b10f29-acd4-441b-8a3e-37a189eb63d4/82b415de-6014-4d11-a391-ecf515c7abc9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+777 Bytes
...s/db2c9a1a-c28c-4434-9eff-d226021eb1b7/82b415de-6014-4d11-a391-ecf515c7abc9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.