Last active
August 29, 2015 14:05
-
-
Save joseanpg/d9a5d8e855293c73f09a to your computer and use it in GitHub Desktop.
Experimentando con wescheme.org y codeworld.info (va ganando haskell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = animationOf mover | |
pared = color(solidRectangle (4,2),light yellow) | |
tejado = color(solidPolygon[(-2,1),(0,2),(2,1)],red) | |
puerta = translate(color(solidRectangle(0.6,1),brown),0,-0.5) | |
ventana1 = translate(color(solidRectangle(0.6,0.6),light blue),-1,0) | |
ventana2 = translate(color(solidRectangle(0.6,0.6),light blue),1,0) | |
mover a = rotate (casa,100*a) | |
casa = pictures [ventana1,ventana2,puerta,tejado,pared] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rec x y = solidRectangle(x,y) | |
cir = solidCircle | |
pol = solidPolygon | |
col c d = color(d,c) | |
pos x y d = translate(d,x,y) | |
rot a d = rotate(d,a) | |
sca e d = scale(d,e,e) | |
(>>) a b = b a | |
---------------------------------------------------------- | |
main = animationOf mover | |
---------------------------------------------------------- | |
servicio = rec 4 4 >> col yellow | |
mando = pol [(-2,2),(0,5),(2,2)] >> col blue | |
tobera = pol [(-1,-3.5),(0,-0.5),(1,-3.5)] >> col green | |
apolo = mando & servicio & tobera | |
mover = \y-> let z = y*y*y/20 - 8 | |
in apolo >> sca 0.5 >> pos 0 z >> rot y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define componer-imagenes (lambda (fondo cosas) | |
(foldl | |
(lambda (cosa fondo) | |
(let* ((imagen (vector-ref cosa 0)) | |
(ancho (image-width imagen)) | |
(alto (image-height imagen)) | |
(x (+ (vector-ref cosa 1) (/ ancho 2))) | |
(y (+ (vector-ref cosa 2) (/ alto 2)))) | |
(place-image imagen x y fondo))) | |
fondo cosas))) | |
(define fondo (componer-imagenes | |
(rectangle 600 300 "solid" "sky blue") | |
(list (vector (rectangle 600 150 "solid" "blue") 0 150) | |
(vector (circle 20 "solid" "yellow") 500 50) | |
(vector (ellipse 80 20 "solid" "white") 300 50) | |
(vector (ellipse 100 30 "solid" "white") 320 30) | |
(vector (star 20 "solid" "white") 60 40)))) | |
(define barco1 (image-url "http://icons.iconseeker.com/png/fullsize/jolly-roger-vol-2/ship.png")) | |
(define barco2 (flip-horizontal barco1)) | |
(define-struct mundo (t x1 y1 x2 y2)) | |
(define redibujar (lambda(w) | |
(componer-imagenes fondo | |
(list (vector barco2 (mundo-x2 w) (+ (mundo-y2 w) (* 2 (sin (mundo-t w))))) | |
(vector barco1 (+ (mundo-x1 w) (* 2 (mundo-t w) )) (+ (mundo-y1 w) (* 2 (sin (+ 10 (mundo-t w)))))))))) | |
(define mover (lambda (w) | |
(make-mundo (+ (mundo-t w) 0.1) | |
(mundo-x1 w) | |
(mundo-y1 w) | |
(mundo-x2 w) | |
(mundo-y2 w)))) | |
(define teclear (lambda (w key) | |
(cond [ (key=? "left" key) (make-mundo (mundo-t w) | |
(- (mundo-x1 w) 2) | |
(mundo-y1 w) | |
(mundo-x2 w) | |
(mundo-y2 w))] | |
[ (key=? "right" key) (make-mundo (mundo-t w) | |
(+ (mundo-x1 w) 2) | |
(mundo-y1 w) | |
(mundo-x2 w) | |
(mundo-y2 w))] | |
#| | |
[ (key=? "up" key) (make-mundo (mundo-t w) | |
(mundo-x1 w) | |
(- (mundo-y1 w) 2) | |
(mundo-x2 w) | |
(mundo-y2 w))] | |
[ (key=? "down" key) (make-mundo (mundo-t w) | |
(mundo-x1 w) | |
(+ (mundo-y1 w) 2) | |
(mundo-x2 w) | |
(mundo-y2 w))] | |
|# | |
[ else w ]))) | |
(big-bang (make-mundo 0 100 100 300 90) | |
(on-tick mover) | |
(on-key teclear) | |
(to-draw redibujar)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment