summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/ricketyspace/ror/five/loco.rkt59
-rw-r--r--net/ricketyspace/ror/five/resources/caroille.pngbin0 -> 886 bytes
-rw-r--r--net/ricketyspace/ror/five/resources/caroille.svg125
3 files changed, 184 insertions, 0 deletions
diff --git a/net/ricketyspace/ror/five/loco.rkt b/net/ricketyspace/ror/five/loco.rkt
new file mode 100644
index 0000000..977c976
--- /dev/null
+++ b/net/ricketyspace/ror/five/loco.rkt
@@ -0,0 +1,59 @@
+#lang racket
+(require 2htdp/universe 2htdp/image)
+
+(define WIDTH 300)
+(define HEIGHT 300)
+(define CAROILLE (bitmap/file "resources/caroille.png"))
+(define CAROILLE-WIDTH (image-width CAROILLE))
+
+;;;
+;;; If the car is placed at X = 1/2 its width, its back will be
+;;; touching the left edge of the World.
+;;;
+;;; If the car is place at X = - 1/2 its width, its front will be touching
+;;; the left edge of the World.
+;;;
+(define CAROILLE-WIDTH-HALF (/ CAROILLE-WIDTH 2.0))
+
+;;; Structure to represent the X position of two cars in animation.
+(struct cars (one two))
+
+(define (caroille-past-right-edge? pos)
+ (> pos (- WIDTH CAROILLE-WIDTH-HALF)))
+
+(define (caroille-fully-past-right-edge? pos)
+ (>= pos (+ WIDTH CAROILLE-WIDTH-HALF)))
+
+(define (caroille-fully-past-left-edge? pos)
+ (>= pos CAROILLE-WIDTH-HALF))
+
+(define (caroille-fully-inside? pos)
+ (and (caroille-fully-past-left-edge? pos)
+ (not (caroille-past-right-edge? pos))))
+
+(define (move caroilles)
+ (let ((caroille-one (cars-one caroilles))
+ (caroille-two (cars-two caroilles)))
+ (cond
+ ;; Case set I - one of the cars is fully inside.
+ ((caroille-fully-inside? caroille-one)
+ (cars (+ 1 caroille-one) caroille-two))
+ ((caroille-fully-inside? caroille-two)
+ (cars caroille-one (+ 1 caroille-two)))
+ ;; Case set II - one of the cars disappeared into the right edge.
+ ((caroille-fully-past-right-edge? caroille-one)
+ (cars (- CAROILLE-WIDTH-HALF) (+ 1 caroille-two)))
+ ((caroille-fully-past-right-edge? caroille-two)
+ (cars (+ 1 caroille-one) (- CAROILLE-WIDTH-HALF)))
+ ;; Case else - Both cars are partially out.
+ (else (cars (+ 1 caroille-one) (+ 1 caroille-two))))))
+
+(define (draw-cars caroilles)
+ (place-image CAROILLE (cars-one caroilles) (/ HEIGHT 2)
+ (place-image CAROILLE (cars-two caroilles) (/ HEIGHT 2)
+ (empty-scene WIDTH HEIGHT))))
+
+(define (start)
+ (big-bang (cars CAROILLE-WIDTH-HALF (- CAROILLE-WIDTH-HALF))
+ (on-tick move)
+ (to-draw draw-cars)))
diff --git a/net/ricketyspace/ror/five/resources/caroille.png b/net/ricketyspace/ror/five/resources/caroille.png
new file mode 100644
index 0000000..052cc58
--- /dev/null
+++ b/net/ricketyspace/ror/five/resources/caroille.png
Binary files differ
diff --git a/net/ricketyspace/ror/five/resources/caroille.svg b/net/ricketyspace/ror/five/resources/caroille.svg
new file mode 100644
index 0000000..eb4db63
--- /dev/null
+++ b/net/ricketyspace/ror/five/resources/caroille.svg
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="80"
+ height="80"
+ viewBox="0 0 21.166666 21.166667"
+ version="1.1"
+ id="svg8"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="caroille.svg">
+ <title
+ id="title3715">caroille</title>
+ <defs
+ id="defs2">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="1.8428503 : 18.575596 : 1"
+ inkscape:vp_y="0 : 999.99999 : 0"
+ inkscape:vp_z="28.301183 : 18.575596 : 1"
+ inkscape:persp3d-origin="15.072016 : 14.165874 : 1"
+ id="perspective3723" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="3.959798"
+ inkscape:cx="72.620745"
+ inkscape:cy="61.452165"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="px"
+ showguides="false"
+ inkscape:window-width="1280"
+ inkscape:window-height="800"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>caroille</dc:title>
+ <cc:license
+ rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
+ <dc:date>2018-04-02</dc:date>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>rsiddharth &lt;s@ricketyspace.net&gt;</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>car</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-275.83332)">
+ <g
+ id="g3759"
+ transform="matrix(1.6602564,0,0,1.6602564,-10.597836,-177.21015)"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
+ <rect
+ ry="0.8018086"
+ style="stroke-width:0.26458332"
+ y="277.95703"
+ x="7.550364"
+ height="3.4745038"
+ width="10.423512"
+ id="rect3717" />
+ <circle
+ style="stroke-width:0.26458332"
+ r="1.1692964"
+ cy="281.3313"
+ cx="9.254199"
+ id="path3719" />
+ <circle
+ id="circle3721"
+ cx="15.969346"
+ cy="281.49835"
+ r="1.1692964"
+ style="stroke-width:0.26458332" />
+ <rect
+ ry="1.1693041"
+ style="stroke-width:0.24171647"
+ y="275.9859"
+ x="9.7219286"
+ height="2.7395124"
+ width="5.9133382"
+ id="rect3753" />
+ </g>
+ </g>
+</svg>