From 7446e9e396d778192b3d24e84b39cbc749c16e20 Mon Sep 17 00:00:00 2001 From: Nicolas Glondu Date: Thu, 20 Oct 2011 00:19:34 +0200 Subject: [PATCH] Compilation fixes and Pacman is now a true circle --- src/opacman.opa | 3 +++ src/pacman.opa | 14 +++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/opacman.opa b/src/opacman.opa index 404726b..51ec35a 100644 --- a/src/opacman.opa +++ b/src/opacman.opa @@ -1,3 +1,5 @@ +import stdlib.web.canvas + /* Config */ fps = 60 @@ -125,6 +127,7 @@ body() =
init()}> +
diff --git a/src/pacman.opa b/src/pacman.opa index 4412f16..af48cca 100644 --- a/src/pacman.opa +++ b/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