diff --git a/fcore/chain-edge.sml b/fcore/chain-edge.sml new file mode 100644 index 0000000..0720788 --- /dev/null +++ b/fcore/chain-edge.sml @@ -0,0 +1,49 @@ +structure ChainEdgeRight = +struct + fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector = + let + val endY = windowHeight - startY + val startY = windowHeight - (startY + drawHeight) + val endX = startX + drawWidth + val windowHeight = windowHeight / 2.0 + val windowWidth = windowWidth / 2.0 + in + #[ (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, + (((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, + r, g, b, + + (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, + (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0, + r, g, b, + + (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, + (((startY * (1.0 - 0.485714316368)) + (endY * 0.485714316368)) / windowHeight) - 1.0, + r, g, b + ] + end +end + +structure ChainEdgeLeft = +struct + fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector = + let + val endY = windowHeight - startY + val startY = windowHeight - (startY + drawHeight) + val endX = startX + drawWidth + val windowHeight = windowHeight / 2.0 + val windowWidth = windowWidth / 2.0 + in + #[ (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, + (((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, + r, g, b, + + (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, + (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0, + r, g, b, + + (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, + (((startY * (1.0 - 0.485714316368)) + (endY * 0.485714316368)) / windowHeight) - 1.0, + r, g, b + ] + end +end diff --git a/fcore/player.sml b/fcore/player.sml index b0a65c8..5dc1a37 100644 --- a/fcore/player.sml +++ b/fcore/player.sml @@ -548,7 +548,7 @@ struct case #mainAttack player of MAIN_ATTACKING {length, ...} => let - val {x, y, ...} = player + val {x, y, facing, ...} = player val wratio = width / Constants.worldWidthReal val hratio = height / Constants.worldHeightReal val x = @@ -573,18 +573,13 @@ struct val {charge, ...} = player val alpha = Real32.fromInt charge / 60.0 in - Field.lerp - ( x - , y - , realLength - , realSize - , width - , height - , 0.7 - , 0.7 - , 1.0 - , alpha - ) + case facing of + FACING_RIGHT => + ChainEdgeRight.lerp + (x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) + | FACING_LEFT => + ChainEdgeLeft.lerp + (x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) end else let @@ -603,18 +598,13 @@ struct val {charge, ...} = player val alpha = Real32.fromInt charge / 60.0 in - Field.lerp - ( x - , y - , realLength - , realSize - , width - , height - , 0.7 - , 0.7 - , 1.0 - , alpha - ) + case facing of + FACING_RIGHT => + ChainEdgeRight.lerp + (x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) + | FACING_LEFT => + ChainEdgeLeft.lerp + (x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) end end | _ => Vector.fromList [] diff --git a/oms.mlb b/oms.mlb index 21526f3..cfe8dc2 100644 --- a/oms.mlb +++ b/oms.mlb @@ -15,6 +15,7 @@ ann in fcore/block.sml fcore/field.sml + fcore/chain-edge.sml end fcore/wall.sml diff --git a/shell/gl-draw.sml b/shell/gl-draw.sml index 2f40af8..97e61d7 100644 --- a/shell/gl-draw.sml +++ b/shell/gl-draw.sml @@ -241,15 +241,14 @@ struct val wallVec = Wall.getDrawVec (#walls game, width, height) val platVec = Platform.getDrawVec (#platforms game, width, height) - val wallVec = Vector.concat [wallVec, platVec] - - val fieldVec = Player.getFieldVec (#player game, width, height) + val chainVec = Player.getFieldVec (#player game, width, height) + val wallVec = Vector.concat [wallVec, platVec, chainVec] (* temp *) val pelletVec = Player.getPelletVec (#player game, width, height) val projectileVec = Projectile.getProjectileVec (#player game, width, height) - val fieldVec = Vector.concat [pelletVec, projectileVec, fieldVec] + val fieldVec = Vector.concat [pelletVec, projectileVec] val shellState = uploadWall (shellState, wallVec) val shellState = uploadPlayer (shellState, playerVec)