From f16a7830b1d2e0b27449abcb0307278a77ed0c06 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 22 Jan 2017 15:10:42 -0800 Subject: [PATCH] pong: no need for multi-methods. --- extra/pong/pong.factor | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/extra/pong/pong.factor b/extra/pong/pong.factor index ff50d3b7a2..fcab4b7cca 100644 --- a/extra/pong/pong.factor +++ b/extra/pong/pong.factor @@ -4,8 +4,6 @@ grouping kernel locals math math.intervals math.order math.rectangles math.vectors namespaces opengl opengl.gl opengl.glu processing.shapes sequences sequences.generalizations shuffle threads ui ui.gadgets ui.gestures ui.render ; -FROM: multi-methods => GENERIC: METHOD: ; -FROM: syntax => M: ; IN: pong ! Inspired by this Ruby/Shoes version by why: http://gist.github.com/26431 @@ -14,7 +12,7 @@ IN: pong ! by Bill Mill. : clamp-to-interval ( x interval -- x ) - [ from>> first max ] [ to>> first min ] bi ; + [ from>> first ] [ to>> first ] bi clamp ; TUPLE: play-field < rectangle ; @@ -67,9 +65,9 @@ TUPLE: ball < vel GENERIC: draw ( obj -- ) -METHOD: draw { paddle } [ bottom-left ] [ dim>> ] bi draw-rectangle ; +M: paddle draw [ bottom-left ] [ dim>> ] bi draw-rectangle ; -METHOD: draw { ball } [ pos>> ] [ diameter>> 2 / ] bi draw-circle ; +M: ball draw [ pos>> ] [ diameter>> 2 / ] bi draw-circle ; TUPLE: pong-gadget < gadget paused field ball player computer ; -- 2.34.1