From 2433797caff5439e0ac93af33386baba827fd057 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 9 Jan 2025 11:52:39 +0000 Subject: [PATCH] progress drawing projectiles --- fcore/player.sml | 32 ++++++++++++++++++++++++++++++++ shell/gl-draw.sml | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/fcore/player.sml b/fcore/player.sml index 1be3f84..34ec646 100644 --- a/fcore/player.sml +++ b/fcore/player.sml @@ -1007,4 +1007,36 @@ struct (x, y, 0, enemies, width, height, hratio, xOffset, 0.0, []) end end + + fun helpGetProjectileVec (pos, projectiles, width, height, ratio, acc) = + if pos = Vector.length projectiles then + Vector.concat acc + else + let + val {x, y, ...} = Vector.sub (projectiles, pos) + + val x = Real32.fromInt x * ratio + val y = Real32.fromInt y * ratio + + val defeatedSize = defeatedSize * ratio + + val vec = Field.lerp + (x, y, defeatedSize, defeatedSize, width, height, 0.3, 0.9, 0.3, 1.0) + val acc = vec :: acc + in + helpGetProjectileVec (pos + 1, projectiles, width, height, ratio, acc) + end + + fun getProjectileVec (player: player, width, height) = + let + val {x, y, projectiles, ...} = player + + val wratio = width / 1920.0 + val hratio = height / 1080.0 + in + if wratio < hratio then + helpGetProjectileVec (0, projectiles, width, height, wratio, []) + else + helpGetProjectileVec (0, projectiles, width, height, hratio, []) + end end diff --git a/shell/gl-draw.sml b/shell/gl-draw.sml index f75965a..9f2bd42 100644 --- a/shell/gl-draw.sml +++ b/shell/gl-draw.sml @@ -247,7 +247,9 @@ struct (* temp *) val pelletVec = Player.getPelletVec (#player game, width, height) - val fieldVec = Vector.concat [pelletVec, fieldVec] + val projectileVec = + Player.getProjectileVec (#player game, width, height) + val fieldVec = Vector.concat [pelletVec, projectileVec, fieldVec] val shellState = uploadWall (shellState, wallVec) val shellState = uploadPlayer (shellState, playerVec)