Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: secretrobotron/crunch
base: 663e09a191
...
head fork: secretrobotron/crunch
compare: 2243176a45
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 13, 2012
Nicolas Silva level stuff ef4e91e
Nicolas Silva merge 2243176
View
120 src/engine/level.js
@@ -1,6 +1,6 @@
define(["./game-logic", "engine/entity","engine/beats", "components/sprite", "entities/platform", "entities/monster", "entities/pigeon", "engine/loader",
- "text!sprites/background.json", "text!sprites/coin.json", "text!sprites/spikes.json", "text!sprites/bumper.json"],
- function(GameLogic, Entity, Beats, SpriteComponent, PlatformEntity, MonsterEntity, PigeonEntity, Loader, BG_SPRITE_SRC, COIN_SRC, SPIKE_SRC, BUMPER_SRC){
+ "text!sprites/background.json", "text!sprites/coin.json", "text!sprites/spikes.json", "text!sprites/bumper.json","text!levels/level01.json"],
+ function(GameLogic, Entity, Beats, SpriteComponent, PlatformEntity, MonsterEntity, PigeonEntity, Loader, BG_SPRITE_SRC, COIN_SRC, SPIKE_SRC, BUMPER_SRC, LVL01_SRC){
var loadOnce = true;
var collectSfx = null;
var springSfx = null;
@@ -11,6 +11,8 @@ define(["./game-logic", "engine/entity","engine/beats", "components/sprite", "en
var COIN_JSON = JSON.parse(COIN_SRC);
var SPIKE_JSON = JSON.parse(SPIKE_SRC);
var BUMPER_JSON = JSON.parse(BUMPER_SRC);
+ var LVL01_JSON = JSON.parse(LVL01_SRC);
+ var collectSfx = null;
if( Loader.IsAudioAvailable() ) {
if (loadOnce == false)
@@ -144,7 +146,115 @@ define(["./game-logic", "engine/entity","engine/beats", "components/sprite", "en
scene.add(bump);
}
+
+
+
+ this.buildSceneFromJson = function(scene, lvl) { //-------------- ****
+ var x = setupOptions.levelOrigin[0];
+ // Make the platforms go lower down
+ var EXTEND_PLATFORMS = 15;
+ var RANDOM_Z = 0.05;
+
+ for (var b in lvl.blocks) {
+ var floorEntity = new PlatformEntity({
+ position: [lvl.blocks[b].x + lvl.blocks[b].l/2
+ , setupOptions.levelOrigin[1] + lvl.blocks[b].y - EXTEND_PLATFORMS + 5
+ , -RANDOM_Z + 2*Math.random()],
+ width: lvl.blocks[b].l,
+ height: EXTEND_PLATFORMS,
+ moving: lvl.blocks[b].moving,
+ falling: false
+ });
+
+ GameLogic.AddGameObject(floorEntity);
+ scene.add(floorEntity);
+ }
+
+ for (var bump in lvl.bumpers) {
+ this.spawnBumper(scene, lvl.bumpers[bump].x
+ , setupOptions.levelOrigin[1] + lvl.bumpers[bump].y - 7.5);
+ }
+
+ for (var c in lvl.coin) {
+ this.spawnCoin(scene, lvl.coins[c].x, lvl.coins[c].y + 6);
+ }
+
+ this.buildBackground(scene);
+
+ var monsters = 0;
+ var SAFE_ZONE = 5;
+ while(monsters--){
+ var monsterEntity = new MonsterEntity({
+ position: [SAFE_ZONE + Math.random()*(setupOptions.goalAtY-SAFE_ZONE), 115, 0],
+ rotation: [0, 0, 0],
+ });
+ GameLogic.AddGameObject(monsterEntity);
+ scene.add(monsterEntity);
+ }
+
+ var pigeons = 10;
+ var SAFE_ZONE = 5;
+ while(pigeons--){
+ var pigeonEntity = new PigeonEntity({
+ position: [SAFE_ZONE + Math.random()*(setupOptions.goalAtY-SAFE_ZONE), Math.random()*3 + 8, 0],
+ rotation: [0, 0, 0],
+ });
+ GameLogic.AddGameObject(pigeonEntity);
+ scene.add(pigeonEntity);
+ }
+
+
+ // Make the platforms go lower down
+ var firstBlock = true;
+ while (x < setupOptions.goalAtY) {
+ var h = 4 + Math.random() * 4;
+ var w = 6 + Math.random() * 8;
+ // Make sure the first platform reach to 3
+ if (w+x < 5) {
+ w = 5-x;
+ }
+ x += w * 1.3;
+ var isMoving = false;
+ var isFalling = false;
+ if (!firstBlock && Math.random() < 0.3) {
+ isMoving = true;
+ } else if (!firstBlock && Math.random() < 0.2) {
+ //disabled, collision bugs
+ //isFalling = true;
+ }
+ var px = x;
+ var py = setupOptions.levelOrigin[1] + h;
+
+ //dump( '{"x": '+px+', "y":'+py+', "l":' +w+', "isMoving":'+isMoving+'},\n');
+
+ if (Math.random() > 0.2) {
+ this.spawnCoin(scene, x - w + 2*w*Math.random(), setupOptions.levelOrigin[1] + h);
+ }
+ if (Math.random() > 0.96) {
+ var bx = x/2 + 10;
+ var by = setupOptions.levelOrigin[1];
+ this.spawnBumper(scene, bx, by);
+ }
+ }
+
+ Beats.beatEvents.push( function(){
+ var camX = scene.cubicvr.camera.position[0];
+ var pigeonEntity = new PigeonEntity({
+ position: [camX, Math.random()*5 + 7, 0],
+ rotation: [0, 0, 0],
+ });
+ GameLogic.AddGameObject(pigeonEntity);
+ scene.add(pigeonEntity);
+ });
+
+
+ };
+
this.buildToScene = function(scene) {
+
+ this.buildSceneFromJson(scene,LVL01_JSON);
+ return;
+
var x = setupOptions.levelOrigin[0];
// Make the platforms go lower down
var EXTEND_PLATFORMS = 20;
@@ -166,8 +276,12 @@ define(["./game-logic", "engine/entity","engine/beats", "components/sprite", "en
//disabled, collision bugs
//isFalling = true;
}
+ var px = x;
+ var py = setupOptions.levelOrigin[1] + h;
+
+ dump( '{"x": '+px+', "y":'+py+', "l":' +w+', "isMoving":'+isMoving+'},\n');
var floorEntity = new PlatformEntity({
- position: [x, setupOptions.levelOrigin[1] + h - EXTEND_PLATFORMS/2-4, -RANDOM_Z + 2*Math.random()],
+ position: [px, py, -RANDOM_Z + 2*Math.random()],
width: w,
height: h + EXTEND_PLATFORMS,
moving: isMoving,
View
2  src/entities/player.js
@@ -17,6 +17,8 @@ define(["engine/entity", "components/sprite", "engine/schedule", "text!sprites/p
//speed[0] = 0.8;
}
+ ///console.log("player " + p.position[0] + " " + p.position[1]);
+
if(p.speed[1] < -0.001) {
p.setAnimation("jumpDown");
} else if (p.speed[1] > 0.001) {
View
199 src/levels/level01.json
@@ -0,0 +1,199 @@
+{
+ "foo":0,
+ "blocks": [
+ {
+ "x":0
+ , "y":4
+ , "l":40
+ , "moving": false
+ },
+ {
+ "x":42
+ , "y":6
+ , "l":40
+ , "moving": false
+ },
+ {
+ "x":84
+ , "y":10
+ , "l":40
+ , "moving": true
+ },
+ {
+ "x":132
+ , "y":30
+ , "l":40
+ , "moving": true
+ },
+ {
+ "x":168
+ , "y":10
+ , "l":40
+ , "moving": true
+ },
+ {
+ "x":211
+ , "y":9
+ , "l":19
+ , "moving": false
+ },
+ {
+ "x":242
+ , "y":11
+ , "l":18
+ , "moving": true
+ },
+ {"x": 12.5, "y":-10.907651661322621, "l":25, "isMoving":false},
+{"x": 237.67035684091115, "y":4.359201033945135, "l":9.623762536450926, "isMoving":true},
+{"x": 255.38773271605413, "y":3.988710272724825, "l":13.6287506731869, "isMoving":false},
+{"x": 267.09026321333374, "y":4.099806807925156, "l":9.001946536368909, "isMoving":true},
+{"x": 282.480707940621, "y":5.436102667748781, "l":11.838803636374815, "isMoving":true},
+{"x": 293.5365612638091, "y":6.325267396861002, "l":8.50450255629855, "isMoving":false},
+{"x": 309.7092197309692, "y":7.598762845373265, "l":12.440506513200067, "isMoving":false},
+{"x": 320.9650483763002, "y":7.4934195032331194, "l":8.658329727177716, "isMoving":false},
+{"x": 329.31591473072825, "y":7.757502933155144, "l":6.423743349560044, "isMoving":false},
+{"x": 345.67317727628034, "y":5.714830907614598, "l":12.582509650424683, "isMoving":true},
+{"x": 359.0156129732241, "y":4.172781684829824, "l":10.263412074572145, "isMoving":false},
+{"x": 375.3629863394774, "y":4.302010297778377, "l":12.574902589425612, "isMoving":false},
+{"x": 389.64731728681306, "y":7.862190234456618, "l":10.987946882565879, "isMoving":true},
+{"x": 401.66822089507923, "y":4.7027604576778455, "l":9.24684892943549, "isMoving":true},
+{"x": 413.4735156709899, "y":5.54850933932323, "l":9.080995981469762, "isMoving":true},
+{"x": 421.30831000546067, "y":4.408315403897056, "l":6.026764872669823, "isMoving":true},
+{"x": 430.52323847066316, "y":6.166119666633546, "l":7.088406511694244, "isMoving":false},
+{"x": 445.5914340182328, "y":7.138020496405536, "l":11.590919651976648, "isMoving":false},
+{"x": 454.6690994114254, "y":5.566932578365876, "l":6.982819533225069, "isMoving":false},
+{"x": 470.6964621166819, "y":4.219989739564365, "l":12.328740542504985, "isMoving":false},
+{"x": 483.76914738669467, "y":4.712273220479025, "l":10.055911746163645, "isMoving":false},
+{"x": 501.5885088024701, "y":5.676180802347238, "l":13.707201089058017, "isMoving":false},
+{"x": 515.3104088218955, "y":7.178749692120966, "l":10.555307707250329, "isMoving":true},
+{"x": 525.749542885315, "y":4.406867208684929, "l":8.0301031257073, "isMoving":true},
+{"x": 542.8636904382561, "y":5.099862842531387, "l":13.16472888687771, "isMoving":true},
+{"x": 552.7831314899274, "y":6.390775645345901, "l":7.630339270516429, "isMoving":false},
+{"x": 561.9792155634143, "y":7.3789405381419435, "l":7.073910825759145, "isMoving":false},
+{"x": 571.1176552209549, "y":5.913431054061928, "l":7.029568967338919, "isMoving":true},
+{"x": 589.1649274540792, "y":7.695554287492308, "l":13.882517102403323, "isMoving":false},
+{"x": 605.4853121629991, "y":6.019366915425223, "l":12.554142083784477, "isMoving":true},
+{"x": 614.478239003739, "y":5.026648844948236, "l":6.91763603133838, "isMoving":false},
+{"x": 630.9120378402336, "y":5.206718053863425, "l":12.641383720380476, "isMoving":false},
+{"x": 644.5009559254195, "y":4.028228250138871, "l":10.453013911681445, "isMoving":false},
+{"x": 654.0881510698359, "y":7.832343382457507, "l":7.374765495704967, "isMoving":false},
+{"x": 664.0932412129861, "y":7.659719256550137, "l":7.6962231870385995, "isMoving":false},
+{"x": 678.2212745750259, "y":4.758462986713075, "l":10.86771797079987, "isMoving":true},
+{"x": 687.6209371014763, "y":5.506276539284344, "l":7.230509635731136, "isMoving":true},
+{"x": 701.5346073635184, "y":7.258383279427685, "l":10.702823278493874, "isMoving":true},
+{"x": 717.6043723395567, "y":6.943504394860409, "l":12.361357673875602, "isMoving":false},
+{"x": 730.3262492345116, "y":7.438531006747096, "l":9.786059149965308, "isMoving":false},
+{"x": 747.7629604682697, "y":6.089089684599471, "l":13.412854795198594, "isMoving":false},
+{"x": 757.5012454112106, "y":5.017517542745635, "l":7.490988417646765, "isMoving":true},
+{"x": 775.2040387209087, "y":7.796106910567431, "l":13.617533315152365, "isMoving":false},
+{"x": 786.3084103077948, "y":6.550552273035655, "l":8.541824297604766, "isMoving":true},
+{"x": 797.288378675902, "y":4.0273621550400955, "l":8.446129513928565, "isMoving":false},
+{"x": 813.9128125235763, "y":6.263831417348605, "l":12.78802603667262, "isMoving":true},
+{"x": 823.7777575721695, "y":6.180398348028222, "l":7.588419268148591, "isMoving":false},
+{"x": 841.8658828629202, "y":5.251066079291618, "l":13.91394253134665, "isMoving":false},
+{"x": 854.4128451992636, "y":5.180215226298859, "l":9.65150948949492, "isMoving":false},
+{"x": 867.9304112593394, "y":7.741531451319656, "l":10.398127738519808, "isMoving":false},
+{"x": 882.7456447800968, "y":6.87740618959761, "l":11.396333477505697, "isMoving":false},
+{"x": 892.5789191221284, "y":5.888672332392746, "l":7.564057186178187, "isMoving":true},
+{"x": 909.324778479315, "y":6.960562165420765, "l":12.881430274758976, "isMoving":false},
+{"x": 925.0600551190653, "y":6.315400801066602, "l":12.104058953654064, "isMoving":false},
+{"x": 940.9546831409352, "y":6.090423132040403, "l":12.226636939899937, "isMoving":true},
+{"x": 950.7061542064196, "y":6.33369003484688, "l":7.501131588834083, "isMoving":false},
+{"x": 964.5069465494112, "y":5.291379398925001, "l":10.615994109993535, "isMoving":false},
+{"x": 982.4678824251625, "y":4.017132854040533, "l":13.816104519808722, "isMoving":false},
+{"x": 992.5859662401634, "y":5.715428719373886, "l":7.783141396154519, "isMoving":false},
+{"x": 1004.7460705646719, "y":5.393520131652189, "l":9.353926403468009, "isMoving":true},
+{"x": 1012.5605528713908, "y":7.074422920774848, "l":6.01114023593764, "isMoving":true},
+{"x": 1025.051053249162, "y":5.483521365029969, "l":9.608077213670043, "isMoving":true},
+{"x": 1043.1019151797814, "y":7.913643919855309, "l":13.88527840816886, "isMoving":true},
+{"x": 1058.7947513271813, "y":6.665229391902465, "l":12.071412421076836, "isMoving":false},
+{"x": 1076.3133351777858, "y":7.500192131975136, "l":13.475833731234314, "isMoving":true},
+{"x": 1091.376104096684, "y":5.0108144688780385, "l":11.586745322229454, "isMoving":false},
+{"x": 1100.3803189858227, "y":7.575742856244265, "l":6.926319145491285, "isMoving":false},
+{"x": 1118.3719487589558, "y":6.120676438492504, "l":13.83971521010243, "isMoving":false},
+{"x": 1133.5213769446348, "y":7.793967050033141, "l":11.653406296676117, "isMoving":false},
+{"x": 1145.29687003554, "y":7.7773224382586505, "l":9.058071608388607, "isMoving":false},
+{"x": 1161.5596484058335, "y":7.664497828853388, "l":12.509829515610427, "isMoving":true},
+{"x": 1177.5518160182976, "y":5.7110393659706356, "l":12.301667394203138, "isMoving":true},
+{"x": 1191.1209665818471, "y":5.817486826533681, "l":10.437808125807342, "isMoving":false},
+{"x": 1201.4616638118396, "y":7.3509877939200985, "l":7.954382484609521, "isMoving":false},
+{"x": 1213.602851829586, "y":7.852421657000402, "l":9.339375398266432, "isMoving":false},
+{"x": 1221.7019165256552, "y":4.600887069049749, "l":6.23004976620704, "isMoving":true},
+{"x": 1237.3730223172993, "y":5.573459715790618, "l":12.054696762803193, "isMoving":false},
+{"x": 1254.305881393864, "y":5.0494964624699, "l":13.025276212742082, "isMoving":true},
+{"x": 1268.7035773373755, "y":4.613968687219705, "l":11.075150725778013, "isMoving":false},
+{"x": 1285.8611145998555, "y":4.529258999803834, "l":13.198105586523063, "isMoving":false},
+{"x": 1302.8986124138507, "y":4.68844030375408, "l":13.105767549227222, "isMoving":false},
+{"x": 1314.8080956705744, "y":4.632535680728189, "l":9.16114096671043, "isMoving":true},
+{"x": 1323.2063681512752, "y":6.6683582175451015, "l":6.4602096005391525, "isMoving":false},
+{"x": 1335.5321382536179, "y":5.294018718041977, "l":9.481361617186685, "isMoving":true},
+{"x": 1350.4867816766516, "y":7.060163510735972, "l":11.503571863872088, "isMoving":true},
+{"x": 1367.5768367292007, "y":5.924397190143814, "l":13.146196194268594, "isMoving":true},
+{"x": 1383.7681253662145, "y":4.457974542691623, "l":12.454837413087532, "isMoving":false},
+{"x": 1393.1241160030397, "y":5.038820823444469, "l":7.196915874480879, "isMoving":false},
+{"x": 1404.9926386800603, "y":7.193957845228789, "l":9.129632828477334, "isMoving":true},
+{"x": 1414.1886634326709, "y":7.968295626214701, "l":7.073865194315853, "isMoving":true},
+{"x": 1422.8689342266177, "y":7.621591041494263, "l":6.677131379959081, "isMoving":true},
+{"x": 1440.568326024501, "y":4.862779516359522, "l":13.614916767602441, "isMoving":true},
+{"x": 1453.2394849208986, "y":7.578807655401054, "l":9.747045304921333, "isMoving":false},
+{"x": 1465.9252212898398, "y":4.797848198340109, "l":9.758258745339383, "isMoving":true},
+{"x": 1474.4327283177277, "y":7.2564162908656265, "l":6.544236175298376, "isMoving":true},
+{"x": 1483.775379463316, "y":6.66949881976107, "l":7.186654727375787, "isMoving":false},
+{"x": 1501.0971092917446, "y":5.940990118023719, "l":13.324407560329647, "isMoving":false},
+{"x": 1511.4254997836329, "y":4.311593375749538, "l":7.944915762991029, "isMoving":false},
+{"x": 1526.943112585354, "y":7.701283509618532, "l":11.936625232093062, "isMoving":true},
+{"x": 1534.9790701176332, "y":4.639145880263996, "l":6.181505794061103, "isMoving":false},
+{"x": 1543.5193564924878, "y":7.3148120785078286, "l":6.569451057580439, "isMoving":false},
+{"x": 1559.9484526774163, "y":6.124432023273442, "l":12.637766296098812, "isMoving":true},
+{"x": 1574.181308561989, "y":6.472238600887241, "l":10.948350680440553, "isMoving":true},
+{"x": 1582.5931241480944, "y":6.064769667814035, "l":6.470627373927184, "isMoving":true},
+{"x": 1592.1291472058415, "y":5.12973505601267, "l":7.335402352113111, "isMoving":true},
+{"x": 1608.3452555266927, "y":7.958224889962389, "l":12.47392947757781, "isMoving":true},
+{"x": 1617.238776118804, "y":5.03768963036366, "l":6.841169686239557, "isMoving":false},
+{"x": 1630.7934025855275, "y":4.098001878451902, "l":10.426635743633334, "isMoving":true},
+{"x": 1645.1744256123732, "y":6.507820148936728, "l":11.062325405265938, "isMoving":false},
+{"x": 1658.9818992890998, "y":5.294276724588081, "l":10.621133597481986, "isMoving":false},
+{"x": 1669.5738906881795, "y":5.5576252672664435, "l":8.147685691599794, "isMoving":true},
+{"x": 1680.5933182363353, "y":7.450330638819446, "l":8.476482729350622, "isMoving":false},
+{"x": 1689.3722282967053, "y":5.715806161770933, "l":6.753007738746088, "isMoving":true},
+{"x": 1702.380628568479, "y":4.531720263870609, "l":10.006461747518312, "isMoving":true},
+{"x": 1716.51004599603, "y":7.331347591165713, "l":10.868782636577542, "isMoving":false},
+{"x": 1728.6767944017085, "y":7.272326926033646, "l":9.359037235137318, "isMoving":true},
+{"x": 1746.8208565751715, "y":7.574637474525723, "l":13.956970902663821, "isMoving":true},
+{"x": 1755.094146021973, "y":6.11614993381509, "l":6.364068805231872, "isMoving":false},
+{"x": 1773.030980168328, "y":6.778934344884984, "l":13.797564727965316, "isMoving":false},
+{"x": 1788.1125836112697, "y":7.51360231050514, "l":11.601233417647414, "isMoving":false},
+{"x": 1796.3978023289644, "y":6.261561371109952, "l":6.373245167457564, "isMoving":true},
+{"x": 1805.4691740819396, "y":4.748817115085624, "l":6.9779782715194285, "isMoving":false},
+{"x": 1814.9675033181522, "y":5.218585251816626, "l":7.306407104778917, "isMoving":false},
+{"x": 1833.0082867480405, "y":5.722660379832846, "l":13.877525715298741, "isMoving":true},
+{"x": 1844.9570848303638, "y":4.277112708990201, "l":9.191383140248593, "isMoving":true},
+{"x": 1862.9599972962817, "y":7.398267442060289, "l":13.848394204552271, "isMoving":true},
+{"x": 1873.6182801617988, "y":4.392147405302893, "l":8.198679127320762, "isMoving":false},
+{"x": 1885.5518226745278, "y":6.3356874400816725, "l":9.179648086714531, "isMoving":false},
+{"x": 1893.8666647892103, "y":4.8189207988514156, "l":6.396032395909612, "isMoving":true},
+{"x": 1908.9398625722588, "y":7.962618949587238, "l":11.594767525421844, "isMoving":true},
+{"x": 1919.0407434008478, "y":5.0685222793818445, "l":7.769908329683838, "isMoving":false},
+{"x": 1932.3519951810722, "y":4.356296634134633, "l":10.23942444632647, "isMoving":false},
+{"x": 1947.0456740732777, "y":5.431619680513377, "l":11.302829917081182, "isMoving":true},
+{"x": 1965.1564460320992, "y":5.366105614731396, "l":13.931363045247323, "isMoving":false},
+{"x": 1978.882122952018, "y":6.312282579989773, "l":10.558213015322227, "isMoving":true},
+{"x": 1989.3369061596343, "y":4.890624296914937, "l":8.042140928935513, "isMoving":true},
+{"x": 2007.2035487941394, "y":6.899352813505878, "l":13.743571257311544, "isMoving":false}
+
+
+ ],
+ "bumpers": [
+ { "x":82.0, "y":6 },
+ { "x":126.0, "y":8 }
+
+ ],
+ "coins": [
+ {"x":20, "y":3},
+ {"x":20.1, "y":3},
+ {"x":20.2, "y":3},
+ {"x":20.3, "y":3},
+ {"x":20.4, "y":3},
+ {"x":20.5, "y":3}
+ ]
+}

No commit comments for this range

Something went wrong with that request. Please try again.