Skip to content

Commit

Permalink
Compilation fixes and Pacman is now a true circle
Browse files Browse the repository at this point in the history
  • Loading branch information
HenJi committed Oct 19, 2011
1 parent a84320b commit 7446e9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/opacman.opa
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import stdlib.web.canvas

/* Config */

fps = 60
Expand Down Expand Up @@ -125,6 +127,7 @@ body() =
</canvas>
<div>
<span id="info" onready={_ -> init()}></span>
<span id="debug"></span>
</div>
</>

Expand Down
14 changes: 3 additions & 11 deletions src/pacman.opa
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,11 @@
alpha = Base.Dir.facing_angle(p.base.dir)
do Canvas.rotate(ctx, alpha)

angle = Math.PI*Int.to_float((steps-mouth)/(3*steps))
x = Int.of_float(Float.of_int(w)*Math.cos(angle)/2.)-1
y = (w*(steps-mouth))/(4*steps)

angle = Math.PI*Int.to_float(steps-mouth)/Int.to_float(5*steps)

do Canvas.begin_path(ctx)
do Canvas.move_to(ctx, -w/10, 0)
// Could replace all curves but currently not available in OPA :(
// do Canvas.arc(0, 0, w/2, -angle, angle, 1)
do Canvas.line_to(ctx, x, y)
do Canvas.quadratic_curve_to(ctx, w/2, w/2, 0, w/2)
do Canvas.quadratic_curve_to(ctx, -w/2, w/2, -w/2, 0)
do Canvas.quadratic_curve_to(ctx, -w/2, -w/2, 0, -w/2)
do Canvas.quadratic_curve_to(ctx, w/2, -w/2, x, -y)
do Canvas.arc(ctx, 0, 0, w/2, -angle, angle, true)
do Canvas.fill(ctx)
do Canvas.restore(ctx)
void
Expand Down

0 comments on commit 7446e9e

Please sign in to comment.