Skip to content

Commit

Permalink
I put tutorials as backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
agar3s committed Sep 13, 2014
1 parent 1aabe25 commit 136d11e
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 29 deletions.
Binary file modified app.zip
Binary file not shown.
1 change: 0 additions & 1 deletion app/js/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var ElementalSkill = function(types, charge){
}
m.lock = function(element){
m.locks[element] = 1;
console.log(m.locks);
}
m.updateCurrentQ = function(){
m.currentQ = m.charges[m.current];
Expand Down
4 changes: 4 additions & 0 deletions app/js/initializers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var black = '#000';
var white = '#fff';
var xlevel;

var xAxis=0;
var yAxis=0;

var currentLevel = 'level1';

var zoomFactor =(innerHeight-100)/dimensions.h;
//var zoomFactor =1;
Expand Down
147 changes: 128 additions & 19 deletions app/js/levelGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,38 @@ var LevelGenerator = function(level){
m.currentColor = elementColors[m.skills.current];
m.sprite.color = 'hsl('+m.currentColor+',100%, 50%)';
}
return new Level(level.width, monsters, level.factor, platformFunctions, level.pendiente, level.title);
return new Level(level.width, monsters, level.factor, platformFunctions, level.pendiente, level.title, level.backG);

}
var currentLevel = 'level1';
var snowBack = function(){
randomParticles();
}
var blackBack = function(){
ctx.fillStyle='#002';
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
snowBack();
}
var greenBack = function(){
ctx.fillStyle='#121';
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
particles.push(new Particle(-viewport.x+Math.random()*1024,viewport.y+Math.random()*720,4,0,1,Math.random()*360));
}
var blueBack = function(){
ctx.fillStyle='#202';
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
particles.push(new Particle(-viewport.x+Math.random()*1024,viewport.y+Math.random()*720,9,-10,2,30));
}
var stormLoop = 0;
var stormBack = function(){
stormLoop++;
ctx.fillStyle='#000';
if(stormLoop%220==0||stormLoop%221==0||stormLoop%224==0||stormLoop%225==0||stormLoop%228==0||stormLoop%229==0||stormLoop%230==0||stormLoop%231==0){
ctx.fillStyle='#555';

}
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
particles.push(new Particle(-viewport.x+Math.random()*1024,viewport.y+Math.random()*720,0,0,2,Math.random()*180));
}
var levels = {
level1: {
codeMonsters: ['a3b4','a3b9','a3b12', 'a3b15', 'a1b24', 'a1b27', 'a1b30', 'a1b35'],
Expand All @@ -31,7 +59,20 @@ var levels = {
title: 'The Beginning',
nextl:'boss1',
locks:[0,2],
skill:1
skill:1,
backG: function(){
ctx.ft(' S ',xAxis+200, yAxis-300);
ctx.ft(' -> ',xAxis+600, yAxis-200);
ctx.ft(' SPACE ',xAxis+1800, yAxis-300);
ctx.ft(' D ', xAxis+2600, yAxis-220);
ctx.ft(' ALL ', xAxis+3400, yAxis-320);
ctx.fillStyle=white;
ctx.ft('press to shoot',xAxis+200, yAxis-300);
ctx.ft('press to move forward',xAxis+600, yAxis-200);
ctx.ft('Press to change element', xAxis+2600, yAxis-220);
ctx.ft('press to jump',xAxis+1800, yAxis-300);
ctx.ft('You must to destroy enemies', xAxis+3400, yAxis-320);
}
},
boss1: {
codeMonsters:['x1n4'],
Expand All @@ -42,7 +83,12 @@ var levels = {
title: 'Fire Skeleton',
nextl:'level2',
locks:[0,2],
skill:1
skill:1,
backG:function(){
ctx.ft(' BOSS!', xAxis+400, yAxis-350);
ctx.fillStyle=white;
ctx.ft('Destroy the ', xAxis+400, yAxis-350);
}
},
level2: {
codeMonsters: ['a0b4','a2b9','a2b12', 'a0b15', 'a2b18', 'a0b27', 'a2c30', 'a0c35', 'a2c40', 'a0c45'],
Expand All @@ -53,7 +99,18 @@ var levels = {
title: 'The Gate',
nextl:'boss2',
locks:[1,3],
skill:2
skill:2,
backG:function(){
ctx.ft(' VIER ', xAxis+400, yAxis-350);
ctx.ft(' D ', xAxis+1600, yAxis-240);
ctx.ft(' SPACE ', xAxis+2600, yAxis-380);
ctx.ft(' charges ', xAxis+4200, yAxis-240);
ctx.fillStyle=white;
ctx.ft('With the stone you can control the elements ', xAxis+400, yAxis-350);
ctx.ft('Press to change to the previous element', xAxis+1600, yAxis-240);
ctx.ft('Press two times to make a double jump', xAxis+2600, yAxis-380);
ctx.ft('Enemies drop for element energy', xAxis+4200, yAxis-240);
}
},
boss2: {
codeMonsters:['x2m4'],
Expand All @@ -64,16 +121,51 @@ var levels = {
title: 'Fire Dragon',
nextl:'level3',
locks:[1,3],
skill:2
skill:2,
backG:function(){
ctx.ft(' up flying ', xAxis+400, yAxis-350);
ctx.fillStyle=white;
ctx.ft('Press arrow to shoot enemies', xAxis+400, yAxis-350);
}
},
level3: {
codeMonsters: ['b1b4','b1a9','b2a12', 'b3m15', 'b1a20', 'b2a30', 'b3m40', 'b0m45', 'c1a47', 'c2a55', 'b2a70', 'c3b80'],
codeMonsters: ['b1b4','b1a9','b2a12', 'b2a15', 'b3m20', 'b3m25', 'b0m35', 'b0m40', 'c1a47', 'c2a55', 'b2a70', 'c3b80'],
plats: ['a', 6,'f', 6,'a', 5, 'b', 5,'a', 5,'b',5,'x',8, 'c',9,'a',9],
width: 8400,
factor: 149,
pendiente: -0.5,
title: 'Air Palace',
nextl:'boss3'
nextl:'boss3',
backG:function(){
ctx.ft(' Enter ', xAxis+7650, yAxis-1000);
ctx.ft(' Masters!', xAxis+8650, yAxis-1100);
ctx.fillStyle=white;
ctx.ft('Elements are balanced', xAxis+400, yAxis-350);
ctx.ft(' makes double damage to ', xAxis+700, yAxis-250);
ctx.ft(' makes double damage to ', xAxis+1250, yAxis-350);
ctx.ft(' makes double damage to ', xAxis+1950, yAxis-200);
ctx.ft(' makes double damage to ', xAxis+3650, yAxis-300);
ctx.ft('Press to pause the game', xAxis+7650, yAxis-1000);
ctx.ft('I\'m ready to destroy the ', xAxis+8650, yAxis-1100);

ctx.fillStyle= basicColors[0];
ctx.ft('Air ', xAxis+700, yAxis-250);
ctx.ft(' Air', xAxis+3650, yAxis-300);
ctx.fillStyle= basicColors[1];
ctx.ft(' Water', xAxis+700, yAxis-250);
ctx.ft('Water ', xAxis+1250, yAxis-350);


ctx.fillStyle= basicColors[2];
ctx.ft(' Earth', xAxis+1250, yAxis-350);
ctx.ft('Earth ', xAxis+1950, yAxis-200);

ctx.fillStyle= basicColors[3];

ctx.ft(' Fire', xAxis+1950, yAxis-200);
ctx.ft('Fire ', xAxis+3650, yAxis-300);

}
},
boss3: {
codeMonsters:['x3m4'],
Expand All @@ -82,7 +174,8 @@ var levels = {
factor: 50,
pendiente: -0.1,
title: 'Air Master',
nextl:'level4'
nextl:'level4',
backG:blackBack
},
level4:{
codeMonsters:['d3m4','d2m12','d2m20','d0m22', 'b2a28','b2a31','b2a32', 'b0m44', 'b3m50','a1c58','a3c60','a1c62','a3c64','c2b70', 'c2a75', 'd3d91', 'd1d95', 'd3d99'],
Expand All @@ -91,7 +184,8 @@ var levels = {
factor: 27,
pendiente: -0.55,
title: 'Earth Palace',
nextl:'boss4'
nextl:'boss4',
backG:greenBack
},
boss4: {
codeMonsters:['x4o4'],
Expand All @@ -100,7 +194,8 @@ var levels = {
factor: 50,
pendiente: -0.01,
title: 'Earth Master',
nextl:'level5'
nextl:'level5',
backG:greenBack
},
level5:{
codeMonsters:['b1b4','e1e19','e3e24', 'f1b30','f3b32', 'd3m40', 'd1m44', 'd0m48', 'd2m56', 'e0a67', 'e3a70', 'e1a73'],
Expand All @@ -109,7 +204,8 @@ var levels = {
factor: 170,
pendiente: -0.5,
title: 'Water & Fire Montains',
nextl:'boss5'
nextl:'boss5',
backG:blueBack
},
boss5: {
codeMonsters:['x5p5', 'x6q7'],
Expand All @@ -118,7 +214,8 @@ var levels = {
factor: 35,
pendiente: -0.1,
title: 'Water & Fire Masters',
nextl:'level6'
nextl:'level6',
backG:blueBack
},
level6:{
codeMonsters:['b2a10', 'b2a12','b2a14','a0f25','a2f26','a2f27','a0f28','b1b38','b3e40','c0b68','c2b70','d1a106','d3m108','f0f110','f2f11','d3m113','d1a115'],
Expand All @@ -127,7 +224,8 @@ var levels = {
factor: 16,
pendiente: -0.8,
title: 'Grand Master Palace',
nextl:'boss6a'
nextl:'boss6a',
backG:stormBack
},
boss6a:{
codeMonsters:['x7z4'],
Expand All @@ -136,7 +234,8 @@ var levels = {
factor: 700,
pendiente: 1,
title: 'Grand Master',
nextl:'boss6b'
nextl:'boss6b',
backG:stormBack
},
boss6b:{
codeMonsters:['z1r6','z2r6','z3r6','z4r6'],
Expand All @@ -145,16 +244,25 @@ var levels = {
factor: 700,
pendiente: 1,
title: 'Element\'s Avatar challenge',
nextl:'ends'
nextl:'ends',
backG:stormBack
},
ends:{
codeMonsters:[],
width: 1800,
plats:['a',2],
plats:['a',3],
factor: 700,
pendiente: 1,
title: 'Grand master mode',
nextl:'ends'
nextl:'ends',
backG:function(){
ctx.ft('Congratulations! you beat the Game!', xAxis+400, yAxis-350);
ctx.ft('==Thanks for playing==', xAxis+600, yAxis-150);
ctx.ft('made by @agar3s', xAxis+1400, yAxis-150);
ctx.ft(' F5 ', xAxis+1600, yAxis+150);
ctx.fillStyle = white;
ctx.ft('press to start the game again', xAxis+1600, yAxis+150);
}
}
}

Expand All @@ -174,11 +282,12 @@ function restartLevel(wy){
currentEnemy= undefined;
xlevel = LevelGenerator(level);

xAxis=0;
yAxis=0;
}

function nextLevel(){
currentLevel = levels[currentLevel].nextl;
console.log(viewport.y);
//ctx.translate(-viewport.x, viewport.y+720);
//viewport
restartLevel(viewport.y);
Expand Down
5 changes: 3 additions & 2 deletions app/js/levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var platformFunctions = {

}

var Level = function(width, enemiesVector, factor, platforms, pendiente, title){
var Level = function(width, enemiesVector, factor, platforms, pendiente, title, backG){
xf = 0;
yf=0;
var m = this;
Expand Down Expand Up @@ -83,9 +83,10 @@ var Level = function(width, enemiesVector, factor, platforms, pendiente, title){
};
}
m.generateLevel(platforms, pendiente);

m.backG = backG;
m.draw = function(vx, vy){
m.count++;
backG();
var index = ~~(vx/m.factor);
if(index<0){index=0;}
var limit = index + 1+~~(dimensions.w/m.factor);
Expand Down
6 changes: 6 additions & 0 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ var yOld = myhero.sprite.y;
//ctx.transform(1, 0, 0, 1, 0, 0);
var currentScreen = 'i';

var updateBackground = function(xxs){
xAxis+=xxs*0.1;
}


function gameLoop() {
var wx = -viewport.x;
var wy = viewport.y;
Expand Down Expand Up @@ -134,6 +139,7 @@ function gameLoop() {
viewport.y-=yyy;
yOld = myhero.sprite.y;
ctx.translate(xxx, yyy);
updateBackground(xxx);

//draw user interface information
}
Expand Down
2 changes: 1 addition & 1 deletion dist/a.js

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions tasks.todo
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
+-- platforms

-- messages
-- title
-- backgrounds
+-- title
--- upgrounds
-- color
---- music
Expand All @@ -27,10 +27,13 @@
-- events
+-- on player X
+-- on enemy died
-- on level start
-- on level ends
-- on last enemy died
-- on message ends
--- on level start
-- mostrar title
-- tres segundos despues
-- ejecutar msj de bienvenida
--- on level ends
----- on last enemy died
--- on message ends
+-- restart
+-- start
+-- ends
Expand Down Expand Up @@ -71,7 +74,7 @@

!-- if a monster fall remove...
- viewport x again
---- enemies with simple AI
+---- enemies with simple AI
---- implements textures for the backgrounds

---- implements sound management
Expand Down

0 comments on commit 136d11e

Please sign in to comment.