Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Compilation fixes and Pacman is now a true circle

  • Loading branch information...
commit 7446e9e396d778192b3d24e84b39cbc749c16e20 1 parent a84320b
@HenJi authored
Showing with 6 additions and 11 deletions.
  1. +3 −0  src/opacman.opa
  2. +3 −11 src/pacman.opa
View
3  src/opacman.opa
@@ -1,3 +1,5 @@
+import stdlib.web.canvas
+
/* Config */
fps = 60
@@ -125,6 +127,7 @@ body() =
</canvas>
<div>
<span id="info" onready={_ -> init()}></span>
+ <span id="debug"></span>
</div>
</>
View
14 src/pacman.opa
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.