Skip to content

Instantly share code, notes, and snippets.

@mizchi
Last active August 29, 2015 13:58
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 mizchi/10008832 to your computer and use it in GitHub Desktop.
Save mizchi/10008832 to your computer and use it in GitHub Desktop.
createCube = ([x, y, z], color = obelisk.ColorPattern.GRAY) ->
new obelisk.Cube(
new obelisk.CubeDimension(x, y, z)
new obelisk.CubeColor().getByHorizontalColor(color)
)
createBrick = ([x, y], color = obelisk.ColorPattern.GRAY) ->
new obelisk.Brick(
new obelisk.BrickDimension(x, y)
new obelisk.SideColor().getByInnerColor(color)
true
)
createPyramid = (n, color = obelisk.ColorPattern.GRAY)->
new obelisk.Pyramid(
new obelisk.PyramidDimension(n),
new obelisk.PyramidColor().getByRightColor(color)
)
createSideX = ([x, y]) ->
new obelisk.SideX(
new obelisk.SideXDimension(x, y)
new obelisk.SideColor().getByInnerColor(color)
)
createSideY = ([x, y]) ->
new obelisk.SideY(
new obelisk.SideYDimension(x, y)
new obelisk.SideColor().getByInnerColor(color)
)
class Stage
constructor: (canvas, [x, y]) ->
@view = new obelisk.PixelView canvas, new obelisk.Point(x,y)
addObject: ([x, y, z], entity) =>
@view.renderObject entity, new obelisk.Point3D(x,y,z)
$ =>
canvas = document.querySelector '#obl'
stage = new Stage canvas, [canvas.width/2, canvas.height/2]
stage.addObject [ -200, -200], createBrick([400, 400])
for i in [1..10]
for j in [1..10]
stage.addObject [30*i, 30*j, Math.min(~~(Math.random() * 10), 10 )], createCube([30,30,30])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment