Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing bugs

  • Loading branch information...
commit 9fead8a2bdc5a1d3e1c9810bc801f21a4541ff7b 1 parent 17fb625
Jared Cosulich authored
View
1  build/client/js/views/home.js
@@ -36,6 +36,7 @@
removeElements: this.removeLevelElements,
reset: this.resetLevel,
load: this.loadNewLevel,
+ find: this.$,
getTimeDiff: this.getTimeDiff
};
this.templates = {
View
22 index.html
@@ -5,17 +5,17 @@
<link rel="shortcut icon" href="favicon.png" />
<title>Peanutty</title>
<meta name="description" content="Learn how to program by solving puzzles. For kids, adults, grandparents, cats, dogs, small rodents, etc.">
- <link rel="stylesheet" href="./build/client/css/all.css?1326864860922" type="text/css" />
- <script src="./src/client/js/lib/ender.min.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./src/client/js/lib/ace/ace-noconflict.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./src/client/js/lib/ace/mode-coffee-noconflict.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./src/client/js/lib/coffee-script.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./build/client/js/peanutty.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./build/client/js/views/base.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./build/client/js/views/home.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./build/client/js/views/main.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./build/client/js/init.js?1326864860922" type="text/javascript" charset="utf-8"></script>
- <script src="./build/client/js/util.js?1326864860922" type="text/javascript" charset="utf-8"></script>
+ <link rel="stylesheet" href="./build/client/css/all.css?1326915835655" type="text/css" />
+ <script src="./src/client/js/lib/ender.min.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./src/client/js/lib/ace/ace-noconflict.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./src/client/js/lib/ace/mode-coffee-noconflict.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./src/client/js/lib/coffee-script.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./build/client/js/peanutty.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./build/client/js/views/base.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./build/client/js/views/home.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./build/client/js/views/main.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./build/client/js/init.js?1326915835655" type="text/javascript" charset="utf-8"></script>
+ <script src="./build/client/js/util.js?1326915835655" type="text/javascript" charset="utf-8"></script>
<script type='text/javascript' charset="utf-8">
views = require('views');
View
39 src/client/js/simple_bucket_level.js
@@ -2,7 +2,7 @@
var ball, bucket, bucketBottom, cannon, cannonControl, title;
var _this = this, __hasProp = Object.prototype.hasOwnProperty, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (__hasProp.call(this, i) && this[i] === item) return i; } return -1; };
- view.level = 'simple_bucket';
+ level.name = 'simple_bucket';
Peanutty.createEnvironment();
@@ -118,11 +118,10 @@
peanutty.addContactListener({
listener: function(contact) {
var fixtures, success, _ref;
- if (view.levelElements.success != null) return;
+ if (level.elements.success != null) return;
fixtures = [contact.GetFixtureA(), contact.GetFixtureB()];
if ((_ref = ball.GetFixtureList(), __indexOf.call(fixtures, _ref) >= 0) && __indexOf.call(fixtures, bucketBottom) >= 0) {
- success = view.levelElements.success = $(document.createElement("DIV"));
- success.addClass('level_element');
+ success = level.elements.success = $(document.createElement("DIV"));
success.css({
textAlign: 'center',
position: 'absolute',
@@ -130,12 +129,12 @@
left: "" + (peanutty.canvas.width() * 6 / 11)
});
success.html("<h4>Success! Nice Job!</h4>\n<p>\n Got a creative solution? \n Let me know: \n <a href='http://twitter.com/jaredcosulich' target='_blank'>@jaredcosulich</a>\n</p>\n <p>On to the <a href='#level/a_little_code'>next level ></a>...</p>\n<p>\n ... or <a href='#create'>create your own level!<a> \n</p>");
- return view.$('#canvas_container').append(success);
+ return level.canvasContainer.append(success);
}
}
});
- title = view.levelElements.title = $(document.createElement("DIV"));
+ title = level.elements.title = $(document.createElement("DIV"));
title.css({
width: '500px',
@@ -148,9 +147,9 @@
title.html("Get the Blue Ball in to the Bucket");
- view.$('#canvas_container').append(title);
+ level.canvasContainer.append(title);
- cannonControl = view.levelElements.cannonControl = $(document.createElement("DIV"));
+ cannonControl = level.elements.cannonControl = $(document.createElement("DIV"));
cannonControl.css({
fontSize: '12pt',
@@ -161,26 +160,26 @@
cannonControl.html("<h5>Cannon Controls</h5>\n<p>Angle: <input id='cannon_angle' type='text' style='width: 2em' value=45 />&deg;</p>\n<p>Force: <input id='cannon_force' type='text' style='width: 2em' value=10 /></p>\n<a id='fire_cannon' class=\"btn error\">\n Fire Cannon!\n</a>\n<a id='try_again' class=\"btn primary\" style='display: none;'>\n Try Again\n</a> ");
- view.$('#canvas_container').append(cannonControl);
+ level.canvasContainer.append(cannonControl);
- view.$('#fire_cannon').bind('click', function() {
+ level.find('#fire_cannon').bind('click', function() {
peanutty.addToScript({
- command: "cannonball = peanutty.createBall\n x: 125\n y: 133\n radius: 10\n density: 50\n drawData: {color: new b2d.Common.b2Color(0.1, 0.1, 0.1), alpha: 0.8}\n\nangle = " + (view.$('#cannon_angle').val()) + "\nforce = " + (view.$('#cannon_force').val()) + "\nx = Math.cos(Math.PI/(180 / angle)) * force\ny = -1 * Math.sin(Math.PI/(180 / angle)) * force\ncannonball.SetLinearVelocity(new b2d.Common.Math.b2Vec2(x,y))",
+ command: "cannonball = peanutty.createBall\n x: 125\n y: 133\n radius: 10\n density: 50\n drawData: {color: new b2d.Common.b2Color(0.1, 0.1, 0.1), alpha: 0.8}\n\nangle = " + (level.find('#cannon_angle').val()) + "\nforce = " + (level.find('#cannon_force').val()) + "\nx = Math.cos(Math.PI/(180 / angle)) * force\ny = -1 * Math.sin(Math.PI/(180 / angle)) * force\ncannonball.SetLinearVelocity(new b2d.Common.Math.b2Vec2(x,y))",
time: 0
});
- view.$('#fire_cannon').hide();
- return view.$('#try_again').show();
+ level.find('#fire_cannon').hide();
+ return level.find('#try_again').show();
});
- view.$('#try_again').bind('click', function() {
+ level.find('#try_again').bind('click', function() {
var angleVal, forceVal;
- angleVal = view.$('#cannon_angle').val();
- forceVal = view.$('#cannon_force').val();
+ angleVal = level.find('#cannon_angle').val();
+ forceVal = level.find('#cannon_force').val();
level.reset();
- view.$('#cannon_angle').val(angleVal);
- view.$('#cannon_force').val(forceVal);
- view.$('#try_again').hide();
- return view.$('#fire_cannon').show();
+ level.find('#cannon_angle').val(angleVal);
+ level.find('#cannon_force').val(forceVal);
+ level.find('#try_again').hide();
+ return level.find('#fire_cannon').show();
});
peanutty.sign('@jaredcosulich', 'jaredcosulich');
View
1  src/client/js/views/home.coffee
@@ -12,6 +12,7 @@
removeElements: @removeLevelElements
reset: @resetLevel
load: @loadNewLevel
+ find: @$
getTimeDiff: @getTimeDiff
@templates = {
View
195 src/client/templates/a_little_code_level.coffee
@@ -1,195 +0,0 @@
-view.level = 'a_little_code'
-Peanutty.createEnvironment()
-
-# Zoom out
-peanutty.setScale(25 * (peanutty.canvas.width() / 835))
-
-# Create the first ground
-peanutty.createGround
- x: 150
- y: 30
- width: 400
- height: 10
- friction: 0
-
-# Create the second ground
-peanutty.createGround
- x: 850
- y: 30
- width: 300
- height: 10
-
-
-# Create the ball
-ball = peanutty.createBall
- x: 240
- y: 50
- radius: 20
- drawData:
- color: new b2d.Common.b2Color(0, 0, 0.8)
- alpha: 0.8
-
-# Create the pinball
-pinball = peanutty.createBall
- x: 120
- y: 50
- radius: 20
- density: 20
- drawData:
- color: new b2d.Common.b2Color(0, 0, 0)
- alpha: 0.8
-
-# Create the goal
-goal = peanutty.createBox
- x: 980
- y: 85
- height: 50
- width: 10
- static: true
- drawData:
- color: new b2d.Common.b2Color(0, 0, 0.8)
- alpha: 0.8
-
-# Create the striker
-view.striker = peanutty.createBox
- x: 10
- y: 50
- width: 80
- height: 20
- density: 30
- friction: 0
- drawData:
- color: new b2d.Common.b2Color(0, 0, 0)
- alpha: 0.8
-
-# Create the launch button
-launchButtonBackground = view.levelElements.launchButton = $(document.createElement("DIV"))
-launchButtonBackground.css(
- backgroundColor: '#666'
- position: 'absolute'
- top: '398px'
- left: '68px'
- width: '44px'
- height: '44px'
- borderRadius: '22px'
-)
-view.$('#canvas_container').append(launchButtonBackground)
-launchButton = view.levelElements.launchButton = $(document.createElement("A"))
-launchButton.css(
- backgroundColor: '#57A957'
- backgroundImage: '-webkit-radial-gradient(circle, #CAE6CA, #62C462)'
- position: 'absolute'
- top: '400px'
- left: '70px'
- width: '40px'
- height: '40px'
- borderRadius: '20px'
-)
-
-launchButton.bind 'mousedown', () =>
- launchButton.css(backgroundImage: '-webkit-radial-gradient(circle, #158515, #62C462)')
- peanutty.addToScript
- command:
- """
- clearInterval(view.strikerInterval)
- view.strikerInterval = setInterval((
- () =>
- clearInterval(view.strikerInterval) if view.striker.GetPosition().x < -2.5
- changeVec = new b2d.Common.Math.b2Vec2((view.striker.GetPosition().x + 2.5) / 50, 0)
- view.striker.GetPosition().Subtract(changeVec)
- ),
- 10
- )
- """
- time: view.getTimeDiff()
-
-launchButton.bind 'mouseup', () =>
- launchButton.css(backgroundImage: '-webkit-radial-gradient(circle, #CAE6CA, #62C462)')
- peanutty.addToScript
- command:
- """
- clearInterval(view.strikerInterval)
- view.striker.SetAwake(true)
- view.striker.SetLinearVelocity(new b2d.Common.Math.b2Vec2(view.striker.GetPosition().x * -10,0))
- view.strikerInterval = setInterval((
- () =>
- clearInterval(view.strikerInterval) if view.striker.GetPosition().x < 0 && !view.striker.IsAwake()
- if view.striker.GetPosition().x > 1 || !view.striker.IsAwake()
- view.striker.SetAwake(false)
- changeVec = new b2d.Common.Math.b2Vec2(0.01, 0)
- view.striker.GetPosition().Subtract(changeVec)
- ),
- 10
- )
- """
- time: view.getTimeDiff()
-
-view.$('#canvas_container').append(launchButton)
-
-launchInstructions = view.levelElements.launchInstructions = $(document.createElement("DIV"))
-launchInstructions.html("<p>Press and hold the button to<br/>pull back the pinball striker.</p>")
-launchInstructions.css
- position: 'absolute'
- top: '360px'
- left: "10px"
-view.$('#canvas_container').append(launchInstructions)
-
-
-# pinball.SetLinearVelocity(new b2d.Common.Math.b2Vec2(40,1))
-
-# Listen for the ball hitting the goal
-peanutty.addContactListener
- listener: (contact) =>
- return if view.levelElements.success?
- fixtures = [contact.GetFixtureA(), contact.GetFixtureB()]
- if ball.GetFixtureList() in fixtures and goal.GetFixtureList() in fixtures
- success = view.levelElements.success = $(document.createElement("DIV"))
- success.html(
- """
- <h4>Nicely done.</h4>
- <p>
- Got a creative solution?
- Let me know:
- <a href='http://twitter.com/jaredcosulich' target='_blank'>@jaredcosulich</a>
- </p>
- <p>How about a <a href='#level/stack_em'>slightly harder level ></a></p>
- <p>
- ... or <a href='#create'>create your own level!<a>
- </p>
- """
- )
- success.css
- width: '400px'
- textAlign: 'center'
- position: 'absolute'
- top: '200px'
- left: "#{(peanutty.canvas.width() / 2) - 200}px"
- view.$('#canvas_container').append(success)
-
-# instructions
-instructions = view.levelElements.instructions = $(document.createElement("DIV"))
-instructions.html(
- """
- <h1>Get the blue ball to hit the blue wall.</h1>
- <div>
- The toolbar is gone, so it's going to take a little coding to do it.
- </div>
- <div>(hint: look at previous levels to get some ideas)</div>
- """
-)
-instructions.css
- width: '600px'
- textAlign: 'center'
- position: 'absolute'
- top: '20px'
- left: "#{(peanutty.canvas.width() / 2) - 300}px"
-view.$('#canvas_container').append(instructions)
-
-# remove the toolbar
-$('#tools').css(visibility: 'hidden')
-peanutty.canvas.unbind 'click'
-peanutty.canvas.css(cursor: 'default')
-
-# Signed
-peanutty.sign('@jaredcosulich', 'jaredcosulich')
-
View
71 src/client/templates/ball_jump_level.coffee
@@ -1,71 +0,0 @@
-view.level = 'ball_jump'
-Peanutty.createEnvironment()
-
-view.level = 'stack_em'
-Peanutty.createEnvironment()
-
-scale = 30 * (peanutty.canvas.width() / 835)
-peanutty.setScale(scale)
-
-peanutty.createGround
- x: peanutty.world.dimensions.width / 2
- y: 50
- width: 600
- height: 10
-
-peanutty.createBall
- x: peanutty.world.dimensions.width / 2
- y: 75
- radius: 20
-
-peanutty.createBox
- x: peanutty.world.dimensions.width / 2
- y: 100
- width: 150
- height: 5
-
-peanutty.createBox
- x: peanutty.world.dimensions.width / 2
- y: 140
- width: 20
- height: 20
-
-peanutty.createBox
- x: peanutty.world.dimensions.width / 2
- y: 200
- width: 20
- height: 20
-
-setInterval(
- (() =>
- body = peanutty.world.GetBodyList()
- while body?
- body.GetPosition().Subtract(new b2d.Common.Math.b2Vec2(0.01, 0)) if !body.IsAwake()
- body = body.GetNext()
- ), 10
-)
-
-instructions = $(document.createElement("DIV"))
-instructions.css
- width: "#{peanutty.canvas.width()}px"
- textAlign: 'center'
- position: 'absolute'
- top: '20px'
- left: 0
-
-header = view.levelElements.header = $(document.createElement("DIV"))
-header.css
- height: '30px'
- fontSize: '20pt'
-header.html("Build a stable tower that reaches the star.")
-instructions.append(header)
-
-note = view.levelElements.note = $(document.createElement("DIV"))
-note.html("The tower will turn gray when it is stable (not about to fall over).<br/>Hint: this is a lot easier if you write some code.")
-
-instructions.append(note)
-view.$('#canvas_container').append(instructions)
-
-view.$('#tools #box').click()
-
-peanutty.sign('@jaredcosulich', 'jaredcosulich')
View
549 src/client/templates/hello_world_level.coffee
@@ -1,549 +0,0 @@
-view.level = 'hello_world'
-Peanutty.createEnvironment()
-
-peanutty.setScale(30 * (peanutty.canvas.width() / 835))
-
-# Create the ground
-peanutty.createGround
- x: peanutty.world.dimensions.width / 2
- y: 50
- width: 600
- height: 10
-
-# Set up the user inputs
-
-instructions = view.levelElements.instructions = $(document.createElement("DIV"))
-instructions.css
- height: '30px'
- width: '360px'
- textAlign: 'center'
- fontSize: '20pt'
- position: 'absolute'
- top: '20px'
- left: "#{(peanutty.canvas.width() / 2) - 180}px"
-instructions.html("Type your name:")
-view.$('#canvas_container').append(instructions)
-
-nameInput = view.levelElements.nameInput = $(document.createElement('INPUT'))
-nameInput.css
- width: '360px'
- height: '30px'
- fontSize: '20pt'
- position: 'absolute'
- top: '50px'
- left: "#{(peanutty.canvas.width() / 2) - 180}px"
-
-view.alreadyCollided = []
-view.levelLetters = '';
-nameInput.bind 'keyup', (e) ->
- letters = $(e.currentTarget).val().replace(/[^A-Za-z\s]/ig, '')
- return if letters == view.levelLetters
- view.levelLetters = letters
- view.loadScript()
-
- for name in ['destroyInstructions', 'successInstructions']
- element = view.levelElements[name]
- continue unless element?
- element.remove()
- view.levelElements[name] = null
-
- view.alreadyCollided = []
- peanutty.destroyDynamicObjects()
- peanutty.addToScript
- command:
- """
- peanutty.destroyDynamicObjects()
- view.levelElements.nameInput.val("#{letters}") if view.levelElements.nameInput.val() != "#{letters}"
- peanutty.createLetters
- x: peanutty.world.dimensions.width / 2
- y: 55
- letters: "#{letters}"
- """
- time: 0
- view.lastNameInputKey = new Date()
- $.timeout 1500, () =>
- return if new Date() - view.lastNameInputKey < 1500
- return if view.levelElements.destroyInstructions?
- destroyInstructions = view.levelElements.destroyInstructions = $(document.createElement("DIV"))
- destroyInstructions.css
- height: '30px'
- width: '400px'
- textAlign: 'center'
- fontSize: '11pt'
- position: 'absolute'
- top: '100px'
- left: "#{(peanutty.canvas.width() / 2) - 200}px"
- destroyInstructions.html("Now destroy your name!<br/>(click a few times below this but above your name)")
- view.$('#canvas_container').append(destroyInstructions)
-
-view.$('#canvas_container').append(nameInput)
-nameInput[0].focus()
-
-peanutty.addContactListener
- listener: (contact) =>
- contactedBodies = [contact.GetFixtureA().GetBody(), contact.GetFixtureB().GetBody()]
- for body, index in contactedBodies
- continue if body.m_I == 0
- continue if (body.GetUserData()? && body.GetUserData().letter) or body in view.alreadyCollided
- view.alreadyCollided.push(body) unless (body.GetUserData()? && body.GetUserData().letter)
- if !(successInstructions = view.levelElements.successInstructions)?
- successInstructions = view.levelElements.successInstructions = $(document.createElement("DIV"))
- successInstructions.addClass('level_element')
- successInstructions.css
- height: '30px'
- width: '400px'
- textAlign: 'center'
- fontSize: '11pt'
- position: 'absolute'
- top: '150px'
- left: "#{(peanutty.canvas.width() / 2) - 200}px"
- $('#canvas_container').append(successInstructions)
- successInstructions.html(successInstructions.html() + "Bamm! ") unless view.alreadyCollided.length > 2
-
- if view.alreadyCollided.length == 2
- successInstructions.html(
- successInstructions.html() +
- "<br/>Nice job :) When you're ready, head to the <a id='next_level'>next level ></a>"
- )
- $.timeout 10, () => view.$('#next_level').bind 'click', () => view.loadNewLevel('simple_bucket')
-
-# Add an explanation of how to run the code if you change it.
-view.codeChangeMessageShown or= false
-view.$('#codes .code').bind 'keypress', () =>
- return if view.codeChangeMessageShown
- view.codeChangeMessageShown = true
- peanutty.sendCodeMessage
- message:
- """
- You've changed the code.
- To see your changes you'll need to rerun your script by clicking "Run Script" above.
- """
-
-
-# Letter definitions added to Peanutty
-Peanutty::createLetters = ({x, y, letters}) ->
- width = @getLettersWidth letters: letters
- start = x - (width / 2) - (4 * ((letters.length - 1) / 2))
- for letter in letters
- letterWidth = @getLettersWidth(letters: letter)
- @createLetter(x: start, y: y, letter: letter)
- start += letterWidth + 4
-
-Peanutty::getLettersWidth = ({letters}) ->
- totalWidth = 0
- for letter in letters
- if letter == ' '
- totalWidth += 25
- else
- baseWidth = if letter.toLowerCase() == letter then 50 else 60
- totalWidth += switch letter
- when 'a' then 70
- when 'A' then 78
- when 'd', 'h', 'l', 'o', 'r' then 40
- when 'W' then 80
- else baseWidth
-
- return totalWidth
-
-Peanutty::createLetter = ({x, y, letter}) ->
- switch letter
- when "a"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x+28, y: y+70},{x: x+40, y: y+70},{x: x+13, y: y}]),
- @polyFixtureDef(path: [{x: x+26, y: y+32},{x: x+21, y: y+20},{x: x+34, y: y+20},{x: x+34, y: y+32}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+40, y: y+70},{x: x+34, y: y+54},{x: x+56, y: y},{x: x+70, y: y}]),
- @polyFixtureDef(path: [{x: x+34, y: y+32},{x: x+34, y: y+20},{x: x+47, y: y+20},{x: x+43, y: y+32}])
- ]
- userData: {letter: true}
- when "A"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x+33, y: y+90},{x: x+48, y: y+90},{x: x+13, y: y}]),
- @polyFixtureDef(path: [{x: x+26, y: y+32},{x: x+22, y: y+20},{x: x+42, y: y+20},{x: x+42, y: y+32}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+48, y: y+90},{x: x+42, y: y+73},{x: x+64, y: y},{x: x+78, y: y}]),
- @polyFixtureDef(path: [{x: x+42, y: y+32},{x: x+42, y: y+20},{x: x+57, y: y+20},{x: x+54, y: y+32}])
- ]
- userData: {letter: true}
- when "b"
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+45, y: y+20, width: 5, height: 10, userData: {letter: true}
- @createBox x: x+35, y: y+35, width: 10, height: 5, userData: {letter: true}
- @createBox x: x+45, y: y+50, width: 5, height: 10, userData: {letter: true}
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- when "B"
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+45, width: 10, height: 35, userData: {letter: true}
- @createBox x: x+55, y: y+25, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+40, y: y+45, width: 15, height: 5, userData: {letter: true}
- @createBox x: x+55, y: y+65, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- when "c"
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+35, width: 10, height: 25, userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+74, width: 6, height: 2, userData: {letter: true}, density: 10
- when "C"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+45, width: 10, height: 35, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+6, y: y+92, width: 8, height: 2, userData: {letter: true}, density: 10
- when "d"
- @createBox x: x+20, y: y+5, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+35, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+20, y: y+65, width: 20, height: 5, userData: {letter: true}
- when "D"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+45, width: 5, height: 35, userData: {letter: true}
- @createBox x: x+55, y: y+45, width: 5, height: 35, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- when "e"
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+20, width: 10, height: 10, userData: {letter: true}
- @createBox x: x+20, y: y+35, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+50, width: 10, height: 10, userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+74, width: 6, height: 2, userData: {letter: true}, density: 10
- when "E"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+25, width: 10, height: 15, userData: {letter: true}
- @createBox x: x+20, y: y+45, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+65, width: 10, height: 15, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+91, width: 6, height: 2, userData: {letter: true}, density: 10
- when "f"
- @createBox x: x+10, y: y+15, width: 10, height: 15, userData: {letter: true}, density: 10
- @createBox x: x+20, y: y+35, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+50, width: 10, height: 10, userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+74, width: 6, height: 2, userData: {letter: true}, density: 10
- when "F"
- @createBox x: x+10, y: y+20, width: 10, height: 20, userData: {letter: true}, density: 10
- @createBox x: x+20, y: y+45, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+65, width: 10, height: 15, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+91, width: 6, height: 2, userData: {letter: true}, density: 10
- when "g"
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+7, y: y+35, width: 7, height: 25, userData: {letter: true}
- @createBox x: x+45, y: y+20, width: 5, height: 10, userData: {letter: true}
- @createBox x: x+35, y: y+35, width: 15, height: 5, userData: {letter: true}
- @createBox x: x+45, y: y+40, width: 6, height: 2, userData: {letter: true}, density: 10
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+74, width: 8, height: 2, userData: {letter: true}, density: 10
- when "G"
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+45, width: 10, height: 35, userData: {letter: true}
- @createBox x: x+55, y: y+25, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+45, y: y+45, width: 15, height: 5, userData: {letter: true}
- @createBox x: x+55, y: y+52, width: 6, height: 2, userData: {letter: true}, density: 10
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+92, width: 8, height: 2, userData: {letter: true}, density: 10
- when "h"
- @createBox x: x+5, y: y+15, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+35, y: y+15, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+20, y: y+35, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+55, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+35, y: y+55, width: 5, height: 15, userData: {letter: true}
- when "H"
- @createBox x: x+10, y: y+20, width: 10, height: 20, userData: {letter: true}
- @createBox x: x+50, y: y+20, width: 10, height: 20, userData: {letter: true}
- @createBox x: x+30, y: y+45, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+70, width: 10, height: 20, userData: {letter: true}
- @createBox x: x+50, y: y+70, width: 10, height: 20, userData: {letter: true}
- when "i"
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+25, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- when "I"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+30, y: y+45, width: 5, height: 35, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- when "j"
- @createBox x: x+15, y: y+5, width: 15, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+18, width: 5, height: 8, userData: {letter: true}
- @createBox x: x+25, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- when "J"
- @createBox x: x+17, y: y+5, width: 18, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+18, width: 5, height: 8, userData: {letter: true}
- @createBox x: x+30, y: y+40, width: 5, height: 35, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- when "k"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x, y: y+70},{x: x+10, y: y+70},{x: x+10, y: y}]),
- @polyFixtureDef(path: [{x: x+10, y: y+30},{x: x+10, y: y+40},{x: x+40, y: y+70},{x: x+50, y: y+70}])
- ]
- userData: {letter: true}
- @createPoly
- path: [{x: x+10, y: y+30},{x: x+15, y: y+35},{x: x+50, y: y},{x: x+40, y: y}]
- userData: {letter: true}
- when "K"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x, y: y+90},{x: x+10, y: y+90},{x: x+10, y: y}]),
- @polyFixtureDef(path: [{x: x+10, y: y+40},{x: x+10, y: y+50},{x: x+50, y: y+90},{x: x+60, y: y+90}])
- ]
- userData: {letter: true}
- @createPoly
- path: [{x: x+10, y: y+40},{x: x+15, y: y+45},{x: x+60, y: y},{x: x+50, y: y}]
- userData: {letter: true}
- when "l"
- @createBox x: x+20, y: y+5, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+40, width: 5, height: 30, userData: {letter: true}
- when "L"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+50, width: 5, height: 40, userData: {letter: true}
- when "m"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x, y: y+70},{x: x+10, y: y+70},{x: x+10, y: y}]),
- @polyFixtureDef(path: [{x: x+10, y: y+55},{x: x+10, y: y+70},{x: x+25, y: y+40},{x: x+25, y: y+25}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+40, y: y},{x: x+40, y: y+70},{x: x+50, y: y+70},{x: x+50, y: y}]),
- @polyFixtureDef(path: [{x: x+25, y: y+25},{x: x+25, y: y+40},{x: x+40, y: y+70},{x: x+40, y: y+55}])
- ]
- userData: {letter: true}
- when "M"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x, y: y+90},{x: x+10, y: y+90},{x: x+10, y: y}]),
- @polyFixtureDef(path: [{x: x+10, y: y+75},{x: x+10, y: y+90},{x: x+30, y: y+60},{x: x+30, y: y+45}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+50, y: y},{x: x+50, y: y+90},{x: x+60, y: y+90},{x: x+60, y: y}]),
- @polyFixtureDef(path: [{x: x+30, y: y+45},{x: x+30, y: y+60},{x: x+50, y: y+90},{x: x+50, y: y+75}])
- ]
- userData: {letter: true}
- when "n"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x, y: y+70},{x: x+10, y: y+70},{x: x+10, y: y}]),
- @polyFixtureDef(path: [{x: x+10, y: y+70},{x: x+10, y: y+55},{x: x+40, y: y},{x: x+40, y: y+15}])
- ]
- userData: {letter: true}
- @createPoly
- path: [{x: x+40, y: y},{x: x+40, y: y+70},{x: x+50, y: y+70},{x: x+50, y: y}]
- userData: {letter: true}
- when "N"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y},{x: x, y: y+90},{x: x+10, y: y+90},{x: x+10, y: y}]),
- @polyFixtureDef(path: [{x: x+10, y: y+90},{x: x+10, y: y+75},{x: x+50, y: y},{x: x+50, y: y+15}])
- ]
- userData: {letter: true}
- @createPoly
- path: [{x: x+50, y: y},{x: x+50, y: y+90},{x: x+60, y: y+90},{x: x+60, y: y}]
- userData: {letter: true}
- when "o"
- @createBox x: x+20, y: y+5, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+35, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createBox x: x+20, y: y+65, width: 20, height: 5, userData: {letter: true}
- when "O"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+45, width: 5, height: 35, userData: {letter: true}
- @createBox x: x+55, y: y+45, width: 5, height: 35, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- when "p"
- @createBox x: x+17, y: y+30, width: 5, height: 30, userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+60},{x: x, y: y+70},{x: x+50, y: y+70},{x: x+50, y: y+60}]),
- @polyFixtureDef(path: [{x: x+50, y: y+60},{x: x+50, y: y+40},{x: x+40, y: y+40},{x: x+40, y: y+60}]),
- @polyFixtureDef(path: [{x: x+50, y: y+40},{x: x+50, y: y+30},{x: x+22, y: y+30},{x: x+22, y: y+40}])
- ]
- userData: {letter: true}
- @createBox x: x+4, y: y+72, width: 6, height: 2, userData: {letter: true}, density: 10
- when "P"
- @createBox x: x+17, y: y+40, width: 5, height: 40, userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+80},{x: x, y: y+90},{x: x+60, y: y+90},{x: x+60, y: y+80}]),
- @polyFixtureDef(path: [{x: x+60, y: y+80},{x: x+60, y: y+50},{x: x+50, y: y+50},{x: x+50, y: y+80}]),
- @polyFixtureDef(path: [{x: x+60, y: y+50},{x: x+60, y: y+40},{x: x+22, y: y+40},{x: x+22, y: y+50}])
- ]
- userData: {letter: true}
- @createBox x: x+4, y: y+92, width: 6, height: 2, userData: {letter: true}, density: 30
- when "q"
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+35, width: 5, height: 25, userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+40, y: y+10},{x: x+40, y: y+60},{x: x+50, y: y+60},{x: x+50, y: y+10}]),
- @polyFixtureDef(path: [{x: x+20, y: y+40},{x: x+30, y: y+40},{x: x+40, y: y+20},{x: x+40, y: y+10},{x: x+35, y: y+10}])
- ]
- userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- when "Q"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+40, width: 5, height: 30, userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+50, y: y+10},{x: x+50, y: y+70},{x: x+60, y: y+70},{x: x+60, y: y+10}]),
- @polyFixtureDef(path: [{x: x+30, y: y+40},{x: x+40, y: y+40},{x: x+50, y: y+20},{x: x+50, y: y+10},{x: x+45, y: y+10}])
- ]
- userData: {letter: true}
- @createBox x: x+30, y: y+75, width: 30, height: 5, userData: {letter: true}
- when "r"
- @createBox x: x+5, y: y+20, width: 5, height: 30, userData: {letter: true}
- @createBox x: x+28, y: y+5, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+25, y: y+25, width: 15, height: 5, userData: {letter: true}
- @createBox x: x+35, y: y+40, width: 5, height: 10, userData: {letter: true}
- @createBox x: x+20, y: y+55, width: 20, height: 5, userData: {letter: true}
- when "R"
- @createBox x: x+5, y: y+40, width: 5, height: 40, userData: {letter: true}
- @createBox x: x+35, y: y+20, width: 5, height: 20, userData: {letter: true}
- @createBox x: x+35, y: y+45, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+55, y: y+65, width: 5, height: 15, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- when "s"
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+40, y: y+20, width: 10, height: 10, userData: {letter: true}
- @createBox x: x+25, y: y+35, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+47, y: y+42, width: 6, height: 2, userData: {letter: true}, density: 50
- @createBox x: x+10, y: y+50, width: 10, height: 10, userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+72, width: 6, height: 2, userData: {letter: true}, density: 10
- when "S"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+50, y: y+25, width: 10, height: 15, userData: {letter: true}
- @createBox x: x+30, y: y+45, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+57, y: y+52, width: 6, height: 2, userData: {letter: true}, density: 80
- @createBox x: x+10, y: y+65, width: 10, height: 15, userData: {letter: true}
- @createBox x: x+30, y: y+85, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+4, y: y+92, width: 6, height: 2, userData: {letter: true}, density: 10
- when "t"
- @createBox x: x+25, y: y+30, width: 5, height: 30, userData: {letter: true}
- @createBox x: x+25, y: y+60, width: 25, height: 5, userData: {letter: true}
- when "T"
- @createBox x: x+30, y: y+40, width: 5, height: 40, userData: {letter: true}
- @createBox x: x+30, y: y+80, width: 30, height: 5, userData: {letter: true}
- when "u"
- @createBox x: x+20, y: y+5, width: 20, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+40, width: 5, height: 30, userData: {letter: true}
- @createBox x: x+35, y: y+40, width: 5, height: 30, userData: {letter: true}
- when "U"
- @createBox x: x+30, y: y+5, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+50, width: 5, height: 40, userData: {letter: true}
- @createBox x: x+55, y: y+50, width: 5, height: 40, userData: {letter: true}
- when "v"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+70}, {x: x+10, y: y+70}, {x: x+25, y: y+20}, {x: x+25, y: y}]),
- @polyFixtureDef(path: [{x: x+25, y: y}, {x: x+25, y: y+20}, {x: x+40, y: y+70}, {x: x+50, y: y+70}])
- ]
- userData: {letter: true}
- when "V"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+90}, {x: x+10, y: y+90}, {x: x+30, y: y+20}, {x: x+30, y: y}]),
- @polyFixtureDef(path: [{x: x+30, y: y}, {x: x+30, y: y+20}, {x: x+50, y: y+90}, {x: x+60, y: y+90}])
- ]
- userData: {letter: true}
- when "w"
- @createBox x: x+25, y: y+5, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+5, y: y+40, width: 5, height: 30, userData: {letter: true}
- @createBox x: x+45, y: y+40, width: 5, height: 30, userData: {letter: true}
- @createBox x: x+25, y: y+25, width: 5, height: 15, userData: {letter: true}
- when "W"
- @createBox x: x+40, y: y+5, width: 40, height: 5, userData: {letter: true}
- @createBox x: x+10, y: y+45, width: 10, height: 40, userData: {letter: true}
- @createBox x: x+70, y: y+45, width: 10, height: 40, userData: {letter: true}
- @createBox x: x+40, y: y+20, width: 5, height: 15, userData: {letter: true}
- when "x"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y}, {x: x+20, y: y+35}, {x: x+30, y: y+35}, {x: x+10, y: y}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+30, y: y+35}, {x: x+50, y: y}, {x: x+40, y: y}, {x: x+25, y: y+25}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+70}, {x: x+10, y: y+70}, {x: x+30, y: y+35}, {x: x+20, y: y+35}]),
- @polyFixtureDef(path: [{x: x+25, y: y+45}, {x: x+40, y: y+70}, {x: x+50, y: y+70}, {x: x+30, y: y+35}])
- ]
- userData: {letter: true}
- when "X"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y}, {x: x+25, y: y+45}, {x: x+35, y: y+45}, {x: x+10, y: y}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x+35, y: y+45}, {x: x+60, y: y}, {x: x+50, y: y}, {x: x+30, y: y+35}])
- ]
- userData: {letter: true}
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+90}, {x: x+10, y: y+90}, {x: x+35, y: y+45}, {x: x+25, y: y+45}]),
- @polyFixtureDef(path: [{x: x+30, y: y+55}, {x: x+50, y: y+90}, {x: x+60, y: y+90}, {x: x+35, y: y+45}])
- ]
- userData: {letter: true}
- when "y"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+70}, {x: x+10, y: y+70}, {x: x+30, y: y+35}, {x: x+20, y: y+35}]),
- @polyFixtureDef(path: [{x: x+25, y: y+45}, {x: x+40, y: y+70}, {x: x+50, y: y+70}, {x: x+30, y: y+35}])
- ]
- userData: {letter: true}
- @createBox x: x+25, y: y+17, width: 5, height: 17, userData: {letter: true}
- when "Y"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y+90}, {x: x+10, y: y+90}, {x: x+35, y: y+45}, {x: x+25, y: y+45}]),
- @polyFixtureDef(path: [{x: x+30, y: y+55}, {x: x+50, y: y+90}, {x: x+60, y: y+90}, {x: x+35, y: y+45}])
- ]
- userData: {letter: true}
- @createBox x: x+30, y: y+22, width: 5, height: 22, userData: {letter: true}
- when "z"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y}, {x: x, y: y+10}, {x: x+50, y: y+10}, {x: x+50, y: y}]),
- @polyFixtureDef(path: [{x: x, y: y+10}, {x: x+40, y: y+60}, {x: x+50, y: y+60}, {x: x+10, y: y+10}])
- ]
- userData: {letter: true}
- @createBox x: x+25, y: y+65, width: 25, height: 5, userData: {letter: true}
- @createBox x: x+47, y: y+72, width: 6, height: 2, userData: {letter: true}, density: 50
- when "Z"
- @createPoly
- fixtureDefs: [
- @polyFixtureDef(path: [{x: x, y: y}, {x: x, y: y+10}, {x: x+60, y: y+10}, {x: x+60, y: y}]),
- @polyFixtureDef(path: [{x: x, y: y+10}, {x: x+50, y: y+90}, {x: x+60, y: y+90}, {x: x+10, y: y+10}])
- ]
- userData: {letter: true}
- @createBox x: x+30, y: y+95, width: 30, height: 5, userData: {letter: true}
- @createBox x: x+57, y: y+102, width: 6, height: 2, userData: {letter: true}, density: 50
- else
- return
-
-
-# Display Hello World
-
-peanutty.createLetters
- x: peanutty.world.dimensions.width / 2
- y: 55
- letters: 'Hello World'
-
-peanutty.sign('@jaredcosulich', 'jaredcosulich')
View
49 src/client/templates/levels/simple_bucket_level.coffee
@@ -124,39 +124,36 @@ cannonControl.html(
)
level.canvasContainer.append(cannonControl)
-level.fireCannon = ({angle, force}) =>
- cannonball = peanutty.createBall
- x: 125
- y: 133
- radius: 10
- density: 50
- drawData: {color: new b2d.Common.b2Color(0.1, 0.1, 0.1), alpha: 0.8}
-
- x = Math.cos(Math.PI/(180 / angle)) * force
- y = -1 * Math.sin(Math.PI/(180 / angle)) * force
- cannonball.SetLinearVelocity(new b2d.Common.Math.b2Vec2(x,y))
# Cannon Firing
-level.elements.cannonControl.find('#fire_cannon').bind 'click', () =>
+level.find('#fire_cannon').bind 'click', () =>
peanutty.addToScript
command:
"""
- level.fireCannon
- angle: #{level.elements.cannonControl.find('#cannon_angle').val()}
- force: #{level.elements.cannonControl.find('#cannon_force').val()}
+ cannonball = peanutty.createBall
+ x: 125
+ y: 133
+ radius: 10
+ density: 50
+ drawData: {color: new b2d.Common.b2Color(0.1, 0.1, 0.1), alpha: 0.8}
+
+ angle = #{level.find('#cannon_angle').val()}
+ force = #{level.find('#cannon_force').val()}
+ x = Math.cos(Math.PI/(180 / angle)) * force
+ y = -1 * Math.sin(Math.PI/(180 / angle)) * force
+ cannonball.SetLinearVelocity(new b2d.Common.Math.b2Vec2(x,y))
"""
time: 0
- level.elements.cannonControl.find('#fire_cannon').hide()
- level.elements.cannonControl.find('#try_again').show()
+ level.find('#fire_cannon').hide()
+ level.find('#try_again').show()
-level.elements.cannonControl.find('#try_again').bind 'click', () =>
- angleVal = level.elements.cannonControl.find('#cannon_angle').val()
- forceVal = level.elements.cannonControl.find('#cannon_force').val()
- level.resetLevel()
- level.elements.cannonControl.find('#cannon_angle').val(angleVal)
- level.elements.cannonControl.find('#cannon_force').val(forceVal)
- level.elements.cannonControl.find('#try_again').hide()
- level.elements.cannonControl.find('#fire_cannon').show()
+level.find('#try_again').bind 'click', () =>
+ angleVal = level.find('#cannon_angle').val()
+ forceVal = level.find('#cannon_force').val()
+ level.reset()
+ level.find('#cannon_angle').val(angleVal)
+ level.find('#cannon_force').val(forceVal)
+ level.find('#try_again').hide()
+ level.find('#fire_cannon').show()
peanutty.sign('@jaredcosulich', 'jaredcosulich')
-
View
161 src/client/templates/simple_bucket_level.coffee
@@ -1,161 +0,0 @@
-view.level = 'simple_bucket'
-Peanutty.createEnvironment()
-
-# Zoom out
-peanutty.setScale(25 * (peanutty.canvas.width() / 835))
-
-# Create the cannon area
-peanutty.createGround
- x: 60
- y: 20
- width: 100
- height: 10
-
-peanutty.createBall
- x: 80
- y: 40
- radius: 15
- static: true
-
-cannon = peanutty.createBox
- x: 70
- y: 80
- width: 60
- height: 20
- static: true
-cannon.SetPositionAndAngle(cannon.GetPosition(), (Math.PI * 3/4))
-
-
-# Create the ball area
-peanutty.createGround
- x: 400
- y: 400
- width: 100
- height: 10
-
-ball = peanutty.createBall
- x: 400
- y: 440
- radius: 20
- drawData:
- color: new b2d.Common.b2Color(0, 0, 0.8)
- alpha: 0.8
-
-
-# Create the bucket
-bucket = peanutty.createPoly
- fixtureDefs: [
- peanutty.polyFixtureDef
- path: [{x: 600, y: 280},{x: 610, y: 280},{x: 610, y: 180},{x: 600, y: 180}]
- peanutty.polyFixtureDef
- path: [{x: 610, y: 190},{x: 700, y: 190},{x: 700, y: 180},{x: 610, y: 180}]
- userData: {bottom: true}
- peanutty.polyFixtureDef
- path: [{x: 700, y: 280},{x: 710, y: 280},{x: 710, y: 180},{x: 700, y: 180}]
- ]
- static: true
-bucketBottom = peanutty.searchObjectList(
- object: bucket.GetFixtureList()
- searchFunction: (fixture) -> fixture.GetUserData()? && fixture.GetUserData().bottom
- limit: 1
-)[0]
-
-# Listen for the ball in the bucket
-peanutty.addContactListener
- listener: (contact) =>
- return if view.levelElements.success?
- fixtures = [contact.GetFixtureA(), contact.GetFixtureB()]
- if ball.GetFixtureList() in fixtures and bucketBottom in fixtures
- success = view.levelElements.success = $(document.createElement("DIV"))
- success.addClass('level_element')
- success.css
- textAlign: 'center'
- position: 'absolute'
- top: '180px'
- left: "#{peanutty.canvas.width() * 6/11}"
- success.html(
- """
- <h4>Success! Nice Job!</h4>
- <p>
- Got a creative solution?
- Let me know:
- <a href='http://twitter.com/jaredcosulich' target='_blank'>@jaredcosulich</a>
- </p>
- <p>On to the <a href='#level/a_little_code'>next level ></a>...</p>
- <p>
- ... or <a href='#create'>create your own level!<a>
- </p>
- """
- )
- view.$('#canvas_container').append(success)
-
-
-
-# Set up the user inputs
-title = view.levelElements.title = $(document.createElement("DIV"))
-title.css
- width: '500px'
- textAlign: 'center'
- fontSize: '20pt'
- position: 'absolute'
- top: '20px'
- left: "#{(peanutty.canvas.width() / 2) - 250}px"
-title.html("Get the Blue Ball in to the Bucket")
-view.$('#canvas_container').append(title)
-
-
-cannonControl = view.levelElements.cannonControl = $(document.createElement("DIV"))
-cannonControl.css
- fontSize: '12pt'
- position: 'absolute'
- top: '60px'
- left: "20px"
-cannonControl.html(
- """
- <h5>Cannon Controls</h5>
- <p>Angle: <input id='cannon_angle' type='text' style='width: 2em' value=45 />&deg;</p>
- <p>Force: <input id='cannon_force' type='text' style='width: 2em' value=10 /></p>
- <a id='fire_cannon' class="btn error">
- Fire Cannon!
- </a>
- <a id='try_again' class="btn primary" style='display: none;'>
- Try Again
- </a>
- """
-)
-view.$('#canvas_container').append(cannonControl)
-
-
-# Cannon Firing
-view.$('#fire_cannon').bind 'click', () =>
- peanutty.addToScript
- command:
- """
- cannonball = peanutty.createBall
- x: 125
- y: 133
- radius: 10
- density: 50
- drawData: {color: new b2d.Common.b2Color(0.1, 0.1, 0.1), alpha: 0.8}
-
- angle = #{view.$('#cannon_angle').val()}
- force = #{view.$('#cannon_force').val()}
- x = Math.cos(Math.PI/(180 / angle)) * force
- y = -1 * Math.sin(Math.PI/(180 / angle)) * force
- cannonball.SetLinearVelocity(new b2d.Common.Math.b2Vec2(x,y))
- """
- time: 0
- view.$('#fire_cannon').hide()
- view.$('#try_again').show()
-
-view.$('#try_again').bind 'click', () =>
- angleVal = view.$('#cannon_angle').val()
- forceVal = view.$('#cannon_force').val()
- level.reset()
- view.$('#cannon_angle').val(angleVal)
- view.$('#cannon_force').val(forceVal)
- view.$('#try_again').hide()
- view.$('#fire_cannon').show()
-
-peanutty.sign('@jaredcosulich', 'jaredcosulich')
-
View
122 src/client/templates/stack_em_level.coffee
@@ -1,122 +0,0 @@
-view.level = 'stack_em'
-Peanutty.createEnvironment()
-
-scale = 20 * (peanutty.canvas.width() / 835)
-peanutty.setScale(scale)
-
-createStar = ({x, y, radius, totalPoints}) =>
- path = []
- points = totalPoints / 4
- for i in [0..points]
- path.push({x: x, y: y})
- path.push({x: x + (radius * Math.pow(i/points, 0.6)), y: y - (radius * Math.pow((points - i)/points, 0.6))})
- path.push({x: x, y: y})
- path.push({x: x - (radius * Math.pow(i/points, 0.6)), y: y - (radius * Math.pow((points - i)/points, 0.6))})
- path.push({x: x, y: y})
- path.push({x: x - (radius * Math.pow(i/points, 0.6)), y: y + (radius * Math.pow((points - i)/points, 0.6))})
- path.push({x: x, y: y})
- path.push({x: x + (radius * Math.pow(i/points, 0.6)), y: y + (radius * Math.pow((points - i)/points, 0.6))})
-
- star =
- start: {x: x, y: y}
- path: path
-
- peanutty.tempShapes.push(star)
- return star
-
-starInfo =
- x: peanutty.canvas.width() / 2
- y: 100
- radius: 12
- totalPoints: 8
-
-star = createStar(starInfo)
-
-peanutty.createGround
- x: peanutty.world.dimensions.width / 2
- y: 50
- width: 600
- height: 10
-
-peanutty.createBall
- x: peanutty.world.dimensions.width / 2
- y: 75
- radius: 20
-
-peanutty.createBox
- x: peanutty.world.dimensions.width / 2
- y: 100
- width: 150
- height: 5
-
-peanutty.createBox
- x: peanutty.world.dimensions.width / 2
- y: 140
- width: 20
- height: 20
-
-peanutty.createBox
- x: peanutty.world.dimensions.width / 2
- y: 200
- width: 20
- height: 20
-
-setInterval(
- (() =>
- return if view.levelElements.success
- for point in star.path
- peanutty.world.QueryPoint(
- ((fixture) =>
- return true if fixture.GetBody().IsAwake()
- return false if view.levelElements.success
- success = view.levelElements.success = $(document.createElement("DIV"))
- success.html(
- """
- <h4>Way to go!</h4>
- <p>
- Got a creative solution?
- Let me know:
- <a href='http://twitter.com/jaredcosulich' target='_blank'>@jaredcosulich</a>
- </p>
- <p>More levels coming soon...</p>
- <p>
- ... or <a href='#create'>create your own level!<a>
- </p>
- """
- )
- success.css
- textAlign: 'center'
- position: 'absolute'
- top: '100px'
- left: '10px'
- view.$('#canvas_container').append(success)
- ),
- new b2d.Common.Math.b2Vec2(point.x/scale, point.y/scale)
- )
- ), 100
-)
-
-instructions = $(document.createElement("DIV"))
-instructions.css
- width: "#{peanutty.canvas.width()}px"
- textAlign: 'center'
- position: 'absolute'
- top: '20px'
- left: 0
-
-header = view.levelElements.header = $(document.createElement("DIV"))
-header.css
- height: '30px'
- fontSize: '20pt'
-header.html("Build a stable tower that reaches the star.")
-instructions.append(header)
-
-note = view.levelElements.note = $(document.createElement("DIV"))
-note.html("The tower will turn gray when it is stable (not about to fall over).<br/>Hint: this is a lot easier if you write some code.")
-
-instructions.append(note)
-view.$('#canvas_container').append(instructions)
-
-view.$('#tools #box').click()
-
-peanutty.sign('@jaredcosulich', 'jaredcosulich')
Please sign in to comment.
Something went wrong with that request. Please try again.