Skip to content

Instantly share code, notes, and snippets.

@Raynos
Last active December 14, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/78aef8a57d216283151c to your computer and use it in GitHub Desktop.
Save Raynos/78aef8a57d216283151c to your computer and use it in GitHub Desktop.
/* rendering */
var main = mapMany([
dimensions, marioState
], function display(dimensions, mario) {
var src = "/imgs/mario/stand/right.gif"
var w = dimensions.w
var h = dimensions.h
var verb = mario.y > 0 ? "jump" :
mario.xVelocity !== 0 ? "walk" : "stand"
var direction = mario.xVelocity < 0 ? "left" : "rigth"
var src = "/imgs/mario/" + verb + "/" + direction + ".gif"
var largeRect = rect(h, { x: w / 2, y: h / 2 })
var smallRect = rect(50, { x: w / 2, y: 25 })
var sky = filled(largeRect, skyblue)
var grass = filled(smallRect, grassgreen)
var marioImage = image(35, 35, src)
var marioForm = toForm(marioImage, {
x: mario.x
, y: (h - 63) - mario.y
})
// collage creates a canvas of size w x h and
// puts the forms in the array in there as shapes
return collage(w, h, [sky, grass, marioForm])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment