add code to: (1) draw platform (shell.sml), (2) fix wall collision detection regression and platform collision detection bug (I was meant to pass one y parameter and one x parameter to the QuadTree for querying, but accidentally sent the y coordinate twice), (3) perform necessary state transitions that allow to drop from platform when pressing down on a platform, and (4) make sure player does not stick to platform if they jump to platform from below
This commit is contained in:
@@ -71,10 +71,18 @@ struct
|
|||||||
platID :: tl =>
|
platID :: tl =>
|
||||||
(case yAxis of
|
(case yAxis of
|
||||||
DROP_BELOW_PLATFORM =>
|
DROP_BELOW_PLATFORM =>
|
||||||
|
(* pass through, allowing player to drop below the platform *)
|
||||||
|
helpCheckPlatforms
|
||||||
|
(yAxis, xAxis, x, y, health, jumpPressed, tl, wallList, game)
|
||||||
|
| JUMPING _ =>
|
||||||
|
(* pass through, allowing player to jump above the platform *)
|
||||||
helpCheckPlatforms
|
helpCheckPlatforms
|
||||||
(yAxis, xAxis, x, y, health, jumpPressed, tl, wallList, game)
|
(yAxis, xAxis, x, y, health, jumpPressed, tl, wallList, game)
|
||||||
| _ =>
|
| _ =>
|
||||||
let
|
let
|
||||||
|
(* default case:
|
||||||
|
* player will land on platform and stay on the ground there. *)
|
||||||
|
|
||||||
(***
|
(***
|
||||||
*** cause of compiler error is here
|
*** cause of compiler error is here
|
||||||
*** The specific error is an error with optimising record representations.
|
*** The specific error is an error with optimising record representations.
|
||||||
@@ -102,10 +110,10 @@ struct
|
|||||||
let
|
let
|
||||||
val {wallTree, platformTree, ...} = game
|
val {wallTree, platformTree, ...} = game
|
||||||
val platCollisions = QuadTree.getCollisionsBelow
|
val platCollisions = QuadTree.getCollisionsBelow
|
||||||
(y, y, size, size, 0, 0, 1920, 1080, 0, platformTree)
|
(x, y, size, size, 0, 0, 1920, 1080, 0, platformTree)
|
||||||
|
|
||||||
val wallCollisions = QuadTree.getCollisionSides
|
val wallCollisions = QuadTree.getCollisionSides
|
||||||
(y, y, size, size, 0, 0, 1920, 1080, 0, wallTree)
|
(x, y, size, size, 0, 0, 1920, 1080, 0, wallTree)
|
||||||
in
|
in
|
||||||
helpCheckPlatforms
|
helpCheckPlatforms
|
||||||
( yAxis, xAxis, x, y, health, jumpPressed
|
( yAxis, xAxis, x, y, health, jumpPressed
|
||||||
@@ -234,8 +242,11 @@ struct
|
|||||||
end
|
end
|
||||||
| (false, true) =>
|
| (false, true) =>
|
||||||
(* todo: should move down if on platform *)
|
(* todo: should move down if on platform *)
|
||||||
let val jumpPressed = false
|
let
|
||||||
in helpMove (x, y, xAxis, yAxis, health, jumpPressed, game)
|
val jumpPressed = false
|
||||||
|
val yAxis = DROP_BELOW_PLATFORM
|
||||||
|
in
|
||||||
|
helpMove (x, y, xAxis, yAxis, health, jumpPressed, game)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -159,8 +159,10 @@ struct
|
|||||||
|
|
||||||
val game = GameUpdate.update (game, input)
|
val game = GameUpdate.update (game, input)
|
||||||
|
|
||||||
val wallVec = Wall.getDrawVec (#walls game, width, height)
|
|
||||||
val playerVec = Player.getDrawVec (#player game, width, height)
|
val playerVec = Player.getDrawVec (#player game, width, height)
|
||||||
|
val wallVec = Wall.getDrawVec (#walls game, width, height)
|
||||||
|
val platVec = Platform.getDrawVec (#platforms game, width, height)
|
||||||
|
val wallVec = Vector.concat [wallVec, platVec]
|
||||||
|
|
||||||
val shellState = uploadWall (shellState, wallVec)
|
val shellState = uploadWall (shellState, wallVec)
|
||||||
val shellState = uploadPlayer (shellState, playerVec)
|
val shellState = uploadPlayer (shellState, playerVec)
|
||||||
|
|||||||
Reference in New Issue
Block a user