Skip to content

Commit

Permalink
Music game.
Browse files Browse the repository at this point in the history
Credit to Maggie Johnson for initial mock, and Thao Tran for early
development.
  • Loading branch information
NeilFraser committed Dec 12, 2017
1 parent 8da560c commit 364eafc
Show file tree
Hide file tree
Showing 52 changed files with 2,268 additions and 78 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Definitions
##############################

USER_APPS = {index,puzzle,maze,bird,turtle,movie,pond/docs,pond/tutor,pond/duck}
ALL_JSON = {./,index,puzzle,maze,bird,turtle,movie,pond/docs,pond,pond/tutor,pond/duck}
USER_APPS = {index,puzzle,maze,bird,turtle,movie,music,pond/docs,pond/tutor,pond/duck}
ALL_JSON = {./,index,puzzle,maze,bird,turtle,movie,music,pond/docs,pond,pond/tutor,pond/duck}
ALL_TEMPLATES = appengine/template.soy,appengine/index/template.soy,appengine/puzzle/template.soy,appengine/maze/template.soy,appengine/bird/template.soy,appengine/turtle/template.soy,appengine/movie/template.soy,appengine/pond/docs/template.soy,appengine/pond/template.soy,appengine/pond/tutor/template.soy,appengine/pond/duck/template.soy

APP_ENGINE_THIRD_PARTY = appengine/third-party
Expand Down Expand Up @@ -41,6 +41,10 @@ movie-en: common-en
$(SOY_COMPILER) --outputPathFormat appengine/movie/generated/en/soy.js --srcs appengine/movie/template.soy
python build-app.py movie en

music-en: common-en
$(SOY_COMPILER) --outputPathFormat appengine/music/generated/en/soy.js --srcs appengine/music/template.soy
python build-app.py music en

pond-docs-en:
mkdir -p appengine/pond/generated/en/
$(SOY_COMPILER) --outputPathFormat appengine/pond/docs/generated/en/soy.js --srcs appengine/pond/docs/template.soy
Expand All @@ -64,7 +68,7 @@ pond-common-en: common-en
common-en:
$(SOY_COMPILER) --outputPathFormat appengine/generated/en/soy.js --srcs appengine/template.soy

en: index-en puzzle-en maze-en bird-en turtle-en movie-en pond-docs-en pond-tutor-en pond-duck-en genetics-en
en: index-en puzzle-en maze-en bird-en turtle-en movie-en music-en pond-docs-en pond-tutor-en pond-duck-en genetics-en

languages:
$(SOY_EXTRACTOR) --outputFile extracted_msgs.xlf --srcs $(ALL_TEMPLATES)
Expand Down Expand Up @@ -101,6 +105,7 @@ deps:
svn checkout https://github.com/google/closure-library/trunk/third_party/closure/goog/ $(APP_ENGINE_THIRD_PARTY)/third_party_goog
svn checkout https://github.com/ajaxorg/ace-builds/trunk/src-min-noconflict/ $(APP_ENGINE_THIRD_PARTY)/ace
svn checkout https://github.com/google/blockly/branches/develop/ $(APP_ENGINE_THIRD_PARTY)/blockly
svn checkout https://github.com/mudcube/MIDI.js/trunk/@365 $(APP_ENGINE_THIRD_PARTY)/midi-js
svn checkout https://github.com/CreateJS/SoundJS/trunk/lib/ $(APP_ENGINE_THIRD_PARTY)/SoundJS
svn checkout https://github.com/gleitz/midi-js-soundfonts/trunk/FluidR3_GM/acoustic_guitar_nylon-mp3/ $(APP_ENGINE_THIRD_PARTY)/midi-js-soundfonts/guitar
svn checkout https://github.com/gleitz/midi-js-soundfonts/trunk/FluidR3_GM/acoustic_grand_piano-mp3/ $(APP_ENGINE_THIRD_PARTY)/midi-js-soundfonts/piano
Expand Down
10 changes: 10 additions & 0 deletions appengine/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ <h1><a id="back" href="/">Blockly Games</a> : About</h1>
movie. Then publish your movie to Reddit for the world to see.</p>
</td>
</tr>

<tr>
<td>
<img src="index/music.png" height=100 width=100>
</td>
<td>
<p>Music is an introduction to functions. Use functions to compose music.
Then publish your music to Reddit for the world to see.</p>
</td>
</tr>

<tr>
<td>
Expand Down
20 changes: 18 additions & 2 deletions appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application: blockly-games
version: 1
version: beta
runtime: python27
api_version: 1
threadsafe: no
Expand Down Expand Up @@ -66,6 +66,18 @@ handlers:
- url: /movie-reddit
script: reddit.py
secure: always

# Music app.
- url: /music
static_files: music.html
upload: music\.html
secure: always
- url: /music/
static_dir: music
secure: always
- url: /music-reddit
script: reddit.py
secure: always

# Puzzle app.
- url: /puzzle
Expand Down Expand Up @@ -151,6 +163,7 @@ skip_files:
- ^(.*/)?\..*$
# Custom skip patterns.
- ^\w+/sources/.*$
- ^third-party/ace/snippets/.*$
- ^third-party/blockly/appengine/.*$
- ^third-party/blockly/demos/.*$
- ^third-party/blockly/generators/dart.*$
Expand All @@ -160,7 +173,10 @@ skip_files:
- ^third-party/blockly/i18n/.*$
- ^third-party/blockly/msg/json/.*$
- ^third-party/blockly/tests/.*$
- ^third-party/midi-js/.*$
- ^third-party/midi-js-soundfonts/.+[012567]\.mp3*$
- ^third-party/midi-js-soundfonts/.+b[34]\.mp3*$
- ^third-party/third_party_goog/.*$
- ^third-party/ace/snippets/.*$
- ^third-party/JS-Interpreter/[^c].*$ # Only serve compiled.js.
- ^.+\.soy$
- ^.+\.md$
10 changes: 5 additions & 5 deletions appengine/bird/js/bird.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ Bird.levelHelp = function() {
}
if (userBlocks.indexOf('mutation else') == -1) {
var blocks = BlocklyGames.workspace.getTopBlocks(false);
for (var i = 0, block; block = blocks[i]; i++) {
for (var i = 0, block; (block = blocks[i]); i++) {
if (block.type == 'controls_if') {
break;
}
Expand All @@ -468,7 +468,7 @@ Bird.levelHelp = function() {
} else if (BlocklyGames.LEVEL == 6) {
if (userBlocks.indexOf('mutation') == -1) {
var blocks = BlocklyGames.workspace.getTopBlocks(false);
for (var i = 0, block; block = blocks[i]; i++) {
for (var i = 0, block; (block = blocks[i]); i++) {
if (block.type == 'controls_if') {
break;
}
Expand Down Expand Up @@ -500,8 +500,8 @@ Bird.levelHelp = function() {
*/
Bird.reset = function(first) {
// Kill all tasks.
for (var x = 0; x < Bird.pidList.length; x++) {
window.clearTimeout(Bird.pidList[x]);
for (var i = 0; i < Bird.pidList.length; i++) {
window.clearTimeout(Bird.pidList[i]);
}
Bird.pidList = [];

Expand Down Expand Up @@ -782,7 +782,7 @@ Bird.intersectWorm = function() {
*/
Bird.intersectWall = function() {
var accuracy = 0.2 * Bird.BIRD_ICON_SIZE / Bird.MAP_SIZE * 100;
for (var i = 0, wall; wall = Bird.MAP.walls[i]; i++) {
for (var i = 0, wall; (wall = Bird.MAP.walls[i]); i++) {
var wallPoint = wall.getClosestSegmentPoint(Bird.pos);
if (goog.math.Coordinate.distance(wallPoint, Bird.pos) < accuracy) {
return true;
Expand Down
4 changes: 0 additions & 4 deletions appengine/common/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ img[src$="help.png"] {

html[dir="RTL"] .mirrorImg {
transform: scaleX(-1);
-moz-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
-o-transform: scaleX(-1);
-ms-transform: scaleX(-1);
}

#languageMenu {
Expand Down
4 changes: 2 additions & 2 deletions appengine/common/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ BlocklyStorage.monitorChanges_ = function() {
function change() {
if (startCode != BlocklyInterface.getCode()) {
window.location.hash = '';
Blockly.removeChangeListener(bindData);
BlocklyInterface.getWorkspace().removeChangeListener(bindData);
}
}
var bindData = BlocklyGames.workspace.addChangeListener(change);
var bindData = BlocklyInterface.getWorkspace().addChangeListener(change);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion appengine/index/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ goog.require('Index.soy');
/**
* Array of application names.
*/
Index.APPS = ['puzzle', 'maze', 'bird', 'turtle', 'movie',
Index.APPS = ['puzzle', 'maze', 'bird', 'turtle', 'movie', 'music',
'pond-tutor', 'pond-duck'];

/**
Expand Down
Binary file added appengine/index/music.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions appengine/index/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ a {
fill: none;
stroke-dasharray: 180;
stroke-dashoffset: 180;
animation: dash .6s linear forwards;
animation: dash .7s linear forwards;
}

@keyframes dash {
Expand Down Expand Up @@ -116,14 +116,18 @@ a:hover > text {
animation-delay: 0.4s;
}

#icon-pond-tutor {
#icon-music {
animation-delay: 0.5s;
}

#icon-pond-duck {
#icon-pond-tutor {
animation-delay: 0.6s;
}

#icon-pond-duck {
animation-delay: 0.7s;
}

#back-puzzle {
animation-delay: 0.3s;
}
Expand All @@ -144,14 +148,18 @@ a:hover > text {
animation-delay: 0.7s;
}

#back-pond-tutor {
#back-music {
animation-delay: 0.8s;
}

#back-pond-duck {
#back-pond-tutor {
animation-delay: 0.9s;
}

#back-pond-duck {
animation-delay: 1.0s;
}

@keyframes pop {
from {
transform: translate(80px, 50px) scale(0);
Expand Down
25 changes: 17 additions & 8 deletions appengine/index/template.soy
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,47 @@
{call .appLink}
{param app: 'maze' /}
{param x: 16 /}
{param y: 47 /}
{param y: 45 /}
{param contentText}
{msg meaning="Games.maze" desc="IBID"}Maze{/msg}
{/param}
{/call}
{call .appLink}
{param app: 'bird' /}
{param x: 29 /}
{param y: 75 /}
{param x: 26 /}
{param y: 69 /}
{param contentText}
{msg meaning="Games.bird" desc="IBID"}Bird{/msg}
{/param}
{/call}
{call .appLink}
{param app: 'turtle' /}
{param x: 49 /}
{param y: 72 /}
{param x: 41 /}
{param y: 80 /}
{param contentText}
{msg meaning="Games.turtle" desc="IBID"}Turtle{/msg}
{/param}
{/call}
{call .appLink}
{param app: 'movie' /}
{param x: 64 /}
{param y: 48 /}
{param x: 55 /}
{param y: 61 /}
{param contentText}
{msg meaning="Games.movie" desc="IBID"}Movie{/msg}
{/param}
{/call}
{call .appLink}
{param app: 'music' /}
{param x: 69 /}
{param y: 43 /}
{param contentText}
{msg meaning="Games.music" desc="IBID"}Music{/msg}
{/param}
{/call}
{call .appLink}
{param app: 'pond-tutor' /}
{param x: 83 /}
{param y: 53 /}
{param y: 55 /}
{param contentText}
{msg meaning="Games.pondTutor" desc="IBID"}Pond Tutor{/msg}
{/param}
Expand All @@ -110,6 +118,7 @@
{msg meaning="Games.pond" desc="IBID"}Pond{/msg}
{/param}
{/call}

</g>
</svg>
<select id="languageMenu"></select>
Expand Down
20 changes: 16 additions & 4 deletions appengine/js/lib-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ BlocklyInterface.loadBlocks = function(defaultXml, inherit) {
var inherited = inherit &&
BlocklyGames.loadFromLocalStorage(BlocklyGames.NAME,
BlocklyGames.LEVEL - 1);
if (typeof inherit == 'function') {
if (inherited && typeof inherit == 'function') {
inherited = inherit(inherited);
}

Expand Down Expand Up @@ -145,6 +145,14 @@ BlocklyInterface.getCode = function() {
return text;
};

/**
* Return the main workspace.
* @return {Blockly.WorkspaceSvg}
*/
BlocklyInterface.getWorkspace = function() {
return BlocklyGames.workspace;
};

/**
* Save the blocks for this level to persistent client-side storage.
*/
Expand Down Expand Up @@ -200,15 +208,18 @@ BlocklyInterface.nextLevel = function() {
/**
* Highlight the block (or clear highlighting).
* @param {?string} id ID of block that triggered this action.
* @param {boolean=} opt_state If undefined, highlight specified block and
* automatically unhighlight all others. If true or false, manually
* highlight/unhighlight the specified block.
*/
BlocklyInterface.highlight = function(id) {
BlocklyInterface.highlight = function(id, opt_state) {
if (id) {
var m = id.match(/^block_id_([^']+)$/);
if (m) {
id = m[1];
}
}
BlocklyGames.workspace.highlightBlock(id);
BlocklyGames.workspace.highlightBlock(id, opt_state);
};

/**
Expand Down Expand Up @@ -302,7 +313,8 @@ BlocklyInterface.importPrettify = function() {
};

// Export symbols that would otherwise be renamed by Closure compiler.
// storage.js is not compiled and calls setCode and getCode.
// storage.js is not compiled and calls setCode, getCode, and getWorkspace.
window['BlocklyInterface'] = BlocklyInterface;
BlocklyInterface['setCode'] = BlocklyInterface.setCode;
BlocklyInterface['getCode'] = BlocklyInterface.getCode;
BlocklyInterface['getWorkspace'] = BlocklyInterface.getWorkspace;
2 changes: 1 addition & 1 deletion appengine/turtle/js/slider.js → appengine/js/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ goog.require('goog.math');
* @param {number} y The vertical offset of the slider.
* @param {number} width The total width of the slider.
* @param {!Element} svgParent The SVG element to append the slider to.
* @param {Function} opt_changeFunc Optional callback function that will be
* @param {Function=} opt_changeFunc Optional callback function that will be
* called when the slider is moved. The current value is passed.
* @constructor
*/
Expand Down
11 changes: 6 additions & 5 deletions appengine/maze/js/maze.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ goog.require('Maze.soy');
BlocklyGames.NAME = 'maze';

/**
* Go to the next level.
* Go to the next level. Add skin parameter.
* @suppress {duplicate}
*/
BlocklyInterface.nextLevel = function() {
Expand Down Expand Up @@ -509,6 +509,7 @@ Maze.init = function() {
onresize(null);

var toolbox = document.getElementById('toolbox');
// Scale the workspace so level 1 = 1.3, and level 10 = 1.0.
var scale = 1 + (1 - (BlocklyGames.LEVEL / BlocklyGames.MAX_LEVEL)) / 3;
BlocklyGames.workspace = Blockly.inject('blockly',
{'media': 'third-party/blockly/media/',
Expand Down Expand Up @@ -853,8 +854,8 @@ Maze.hidePegmanMenu = function(e) {
*/
Maze.reset = function(first) {
// Kill all tasks.
for (var x = 0; x < Maze.pidList.length; x++) {
window.clearTimeout(Maze.pidList[x]);
for (var i = 0; i < Maze.pidList.length; i++) {
window.clearTimeout(Maze.pidList[i]);
}
Maze.pidList = [];

Expand Down Expand Up @@ -888,7 +889,7 @@ Maze.reset = function(first) {
lookIcon.style.display = 'none';
lookIcon.parentNode.appendChild(lookIcon);
var paths = lookIcon.getElementsByTagName('path');
for (var i = 0, path; path = paths[i]; i++) {
for (var i = 0, path; (path = paths[i]); i++) {
path.setAttribute('stroke', Maze.SKIN.look);
}
};
Expand Down Expand Up @@ -1386,7 +1387,7 @@ Maze.scheduleLook = function(d) {
'rotate(' + deg + ' 0 0) scale(.4)');
var paths = lookIcon.getElementsByTagName('path');
lookIcon.style.display = 'inline';
for (var i = 0, path; path = paths[i]; i++) {
for (var i = 0, path; (path = paths[i]); i++) {
Maze.scheduleLookStep(path, Maze.stepSpeed * i);
}
};
Expand Down
Loading

0 comments on commit 364eafc

Please sign in to comment.