Skip to content

Commit 136d11e

Browse files
committed
I put tutorials as backgrounds
1 parent 1aabe25 commit 136d11e

File tree

8 files changed

+151
-29
lines changed

8 files changed

+151
-29
lines changed

app.zip

863 Bytes
Binary file not shown.

app/js/elements.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var ElementalSkill = function(types, charge){
4545
}
4646
m.lock = function(element){
4747
m.locks[element] = 1;
48-
console.log(m.locks);
4948
}
5049
m.updateCurrentQ = function(){
5150
m.currentQ = m.charges[m.current];

app/js/initializers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ var black = '#000';
1313
var white = '#fff';
1414
var xlevel;
1515

16+
var xAxis=0;
17+
var yAxis=0;
18+
19+
var currentLevel = 'level1';
1620

1721
var zoomFactor =(innerHeight-100)/dimensions.h;
1822
//var zoomFactor =1;

app/js/levelGenerator.js

Lines changed: 128 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,38 @@ var LevelGenerator = function(level){
1717
m.currentColor = elementColors[m.skills.current];
1818
m.sprite.color = 'hsl('+m.currentColor+',100%, 50%)';
1919
}
20-
return new Level(level.width, monsters, level.factor, platformFunctions, level.pendiente, level.title);
20+
return new Level(level.width, monsters, level.factor, platformFunctions, level.pendiente, level.title, level.backG);
2121

2222
}
23-
var currentLevel = 'level1';
23+
var snowBack = function(){
24+
randomParticles();
25+
}
26+
var blackBack = function(){
27+
ctx.fillStyle='#002';
28+
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
29+
snowBack();
30+
}
31+
var greenBack = function(){
32+
ctx.fillStyle='#121';
33+
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
34+
particles.push(new Particle(-viewport.x+Math.random()*1024,viewport.y+Math.random()*720,4,0,1,Math.random()*360));
35+
}
36+
var blueBack = function(){
37+
ctx.fillStyle='#202';
38+
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
39+
particles.push(new Particle(-viewport.x+Math.random()*1024,viewport.y+Math.random()*720,9,-10,2,30));
40+
}
41+
var stormLoop = 0;
42+
var stormBack = function(){
43+
stormLoop++;
44+
ctx.fillStyle='#000';
45+
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){
46+
ctx.fillStyle='#555';
47+
48+
}
49+
ctx.fillRect(-viewport.x,yAxis+viewport.y,dimensions.w,dimensions.h);
50+
particles.push(new Particle(-viewport.x+Math.random()*1024,viewport.y+Math.random()*720,0,0,2,Math.random()*180));
51+
}
2452
var levels = {
2553
level1: {
2654
codeMonsters: ['a3b4','a3b9','a3b12', 'a3b15', 'a1b24', 'a1b27', 'a1b30', 'a1b35'],
@@ -31,7 +59,20 @@ var levels = {
3159
title: 'The Beginning',
3260
nextl:'boss1',
3361
locks:[0,2],
34-
skill:1
62+
skill:1,
63+
backG: function(){
64+
ctx.ft(' S ',xAxis+200, yAxis-300);
65+
ctx.ft(' -> ',xAxis+600, yAxis-200);
66+
ctx.ft(' SPACE ',xAxis+1800, yAxis-300);
67+
ctx.ft(' D ', xAxis+2600, yAxis-220);
68+
ctx.ft(' ALL ', xAxis+3400, yAxis-320);
69+
ctx.fillStyle=white;
70+
ctx.ft('press to shoot',xAxis+200, yAxis-300);
71+
ctx.ft('press to move forward',xAxis+600, yAxis-200);
72+
ctx.ft('Press to change element', xAxis+2600, yAxis-220);
73+
ctx.ft('press to jump',xAxis+1800, yAxis-300);
74+
ctx.ft('You must to destroy enemies', xAxis+3400, yAxis-320);
75+
}
3576
},
3677
boss1: {
3778
codeMonsters:['x1n4'],
@@ -42,7 +83,12 @@ var levels = {
4283
title: 'Fire Skeleton',
4384
nextl:'level2',
4485
locks:[0,2],
45-
skill:1
86+
skill:1,
87+
backG:function(){
88+
ctx.ft(' BOSS!', xAxis+400, yAxis-350);
89+
ctx.fillStyle=white;
90+
ctx.ft('Destroy the ', xAxis+400, yAxis-350);
91+
}
4692
},
4793
level2: {
4894
codeMonsters: ['a0b4','a2b9','a2b12', 'a0b15', 'a2b18', 'a0b27', 'a2c30', 'a0c35', 'a2c40', 'a0c45'],
@@ -53,7 +99,18 @@ var levels = {
5399
title: 'The Gate',
54100
nextl:'boss2',
55101
locks:[1,3],
56-
skill:2
102+
skill:2,
103+
backG:function(){
104+
ctx.ft(' VIER ', xAxis+400, yAxis-350);
105+
ctx.ft(' D ', xAxis+1600, yAxis-240);
106+
ctx.ft(' SPACE ', xAxis+2600, yAxis-380);
107+
ctx.ft(' charges ', xAxis+4200, yAxis-240);
108+
ctx.fillStyle=white;
109+
ctx.ft('With the stone you can control the elements ', xAxis+400, yAxis-350);
110+
ctx.ft('Press to change to the previous element', xAxis+1600, yAxis-240);
111+
ctx.ft('Press two times to make a double jump', xAxis+2600, yAxis-380);
112+
ctx.ft('Enemies drop for element energy', xAxis+4200, yAxis-240);
113+
}
57114
},
58115
boss2: {
59116
codeMonsters:['x2m4'],
@@ -64,16 +121,51 @@ var levels = {
64121
title: 'Fire Dragon',
65122
nextl:'level3',
66123
locks:[1,3],
67-
skill:2
124+
skill:2,
125+
backG:function(){
126+
ctx.ft(' up flying ', xAxis+400, yAxis-350);
127+
ctx.fillStyle=white;
128+
ctx.ft('Press arrow to shoot enemies', xAxis+400, yAxis-350);
129+
}
68130
},
69131
level3: {
70-
codeMonsters: ['b1b4','b1a9','b2a12', 'b3m15', 'b1a20', 'b2a30', 'b3m40', 'b0m45', 'c1a47', 'c2a55', 'b2a70', 'c3b80'],
132+
codeMonsters: ['b1b4','b1a9','b2a12', 'b2a15', 'b3m20', 'b3m25', 'b0m35', 'b0m40', 'c1a47', 'c2a55', 'b2a70', 'c3b80'],
71133
plats: ['a', 6,'f', 6,'a', 5, 'b', 5,'a', 5,'b',5,'x',8, 'c',9,'a',9],
72134
width: 8400,
73135
factor: 149,
74136
pendiente: -0.5,
75137
title: 'Air Palace',
76-
nextl:'boss3'
138+
nextl:'boss3',
139+
backG:function(){
140+
ctx.ft(' Enter ', xAxis+7650, yAxis-1000);
141+
ctx.ft(' Masters!', xAxis+8650, yAxis-1100);
142+
ctx.fillStyle=white;
143+
ctx.ft('Elements are balanced', xAxis+400, yAxis-350);
144+
ctx.ft(' makes double damage to ', xAxis+700, yAxis-250);
145+
ctx.ft(' makes double damage to ', xAxis+1250, yAxis-350);
146+
ctx.ft(' makes double damage to ', xAxis+1950, yAxis-200);
147+
ctx.ft(' makes double damage to ', xAxis+3650, yAxis-300);
148+
ctx.ft('Press to pause the game', xAxis+7650, yAxis-1000);
149+
ctx.ft('I\'m ready to destroy the ', xAxis+8650, yAxis-1100);
150+
151+
ctx.fillStyle= basicColors[0];
152+
ctx.ft('Air ', xAxis+700, yAxis-250);
153+
ctx.ft(' Air', xAxis+3650, yAxis-300);
154+
ctx.fillStyle= basicColors[1];
155+
ctx.ft(' Water', xAxis+700, yAxis-250);
156+
ctx.ft('Water ', xAxis+1250, yAxis-350);
157+
158+
159+
ctx.fillStyle= basicColors[2];
160+
ctx.ft(' Earth', xAxis+1250, yAxis-350);
161+
ctx.ft('Earth ', xAxis+1950, yAxis-200);
162+
163+
ctx.fillStyle= basicColors[3];
164+
165+
ctx.ft(' Fire', xAxis+1950, yAxis-200);
166+
ctx.ft('Fire ', xAxis+3650, yAxis-300);
167+
168+
}
77169
},
78170
boss3: {
79171
codeMonsters:['x3m4'],
@@ -82,7 +174,8 @@ var levels = {
82174
factor: 50,
83175
pendiente: -0.1,
84176
title: 'Air Master',
85-
nextl:'level4'
177+
nextl:'level4',
178+
backG:blackBack
86179
},
87180
level4:{
88181
codeMonsters:['d3m4','d2m12','d2m20','d0m22', 'b2a28','b2a31','b2a32', 'b0m44', 'b3m50','a1c58','a3c60','a1c62','a3c64','c2b70', 'c2a75', 'd3d91', 'd1d95', 'd3d99'],
@@ -91,7 +184,8 @@ var levels = {
91184
factor: 27,
92185
pendiente: -0.55,
93186
title: 'Earth Palace',
94-
nextl:'boss4'
187+
nextl:'boss4',
188+
backG:greenBack
95189
},
96190
boss4: {
97191
codeMonsters:['x4o4'],
@@ -100,7 +194,8 @@ var levels = {
100194
factor: 50,
101195
pendiente: -0.01,
102196
title: 'Earth Master',
103-
nextl:'level5'
197+
nextl:'level5',
198+
backG:greenBack
104199
},
105200
level5:{
106201
codeMonsters:['b1b4','e1e19','e3e24', 'f1b30','f3b32', 'd3m40', 'd1m44', 'd0m48', 'd2m56', 'e0a67', 'e3a70', 'e1a73'],
@@ -109,7 +204,8 @@ var levels = {
109204
factor: 170,
110205
pendiente: -0.5,
111206
title: 'Water & Fire Montains',
112-
nextl:'boss5'
207+
nextl:'boss5',
208+
backG:blueBack
113209
},
114210
boss5: {
115211
codeMonsters:['x5p5', 'x6q7'],
@@ -118,7 +214,8 @@ var levels = {
118214
factor: 35,
119215
pendiente: -0.1,
120216
title: 'Water & Fire Masters',
121-
nextl:'level6'
217+
nextl:'level6',
218+
backG:blueBack
122219
},
123220
level6:{
124221
codeMonsters:['b2a10', 'b2a12','b2a14','a0f25','a2f26','a2f27','a0f28','b1b38','b3e40','c0b68','c2b70','d1a106','d3m108','f0f110','f2f11','d3m113','d1a115'],
@@ -127,7 +224,8 @@ var levels = {
127224
factor: 16,
128225
pendiente: -0.8,
129226
title: 'Grand Master Palace',
130-
nextl:'boss6a'
227+
nextl:'boss6a',
228+
backG:stormBack
131229
},
132230
boss6a:{
133231
codeMonsters:['x7z4'],
@@ -136,7 +234,8 @@ var levels = {
136234
factor: 700,
137235
pendiente: 1,
138236
title: 'Grand Master',
139-
nextl:'boss6b'
237+
nextl:'boss6b',
238+
backG:stormBack
140239
},
141240
boss6b:{
142241
codeMonsters:['z1r6','z2r6','z3r6','z4r6'],
@@ -145,16 +244,25 @@ var levels = {
145244
factor: 700,
146245
pendiente: 1,
147246
title: 'Element\'s Avatar challenge',
148-
nextl:'ends'
247+
nextl:'ends',
248+
backG:stormBack
149249
},
150250
ends:{
151251
codeMonsters:[],
152252
width: 1800,
153-
plats:['a',2],
253+
plats:['a',3],
154254
factor: 700,
155255
pendiente: 1,
156256
title: 'Grand master mode',
157-
nextl:'ends'
257+
nextl:'ends',
258+
backG:function(){
259+
ctx.ft('Congratulations! you beat the Game!', xAxis+400, yAxis-350);
260+
ctx.ft('==Thanks for playing==', xAxis+600, yAxis-150);
261+
ctx.ft('made by @agar3s', xAxis+1400, yAxis-150);
262+
ctx.ft(' F5 ', xAxis+1600, yAxis+150);
263+
ctx.fillStyle = white;
264+
ctx.ft('press to start the game again', xAxis+1600, yAxis+150);
265+
}
158266
}
159267
}
160268

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

285+
xAxis=0;
286+
yAxis=0;
177287
}
178288

179289
function nextLevel(){
180290
currentLevel = levels[currentLevel].nextl;
181-
console.log(viewport.y);
182291
//ctx.translate(-viewport.x, viewport.y+720);
183292
//viewport
184293
restartLevel(viewport.y);

app/js/levels.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var platformFunctions = {
4444

4545
}
4646

47-
var Level = function(width, enemiesVector, factor, platforms, pendiente, title){
47+
var Level = function(width, enemiesVector, factor, platforms, pendiente, title, backG){
4848
xf = 0;
4949
yf=0;
5050
var m = this;
@@ -83,9 +83,10 @@ var Level = function(width, enemiesVector, factor, platforms, pendiente, title){
8383
};
8484
}
8585
m.generateLevel(platforms, pendiente);
86-
86+
m.backG = backG;
8787
m.draw = function(vx, vy){
8888
m.count++;
89+
backG();
8990
var index = ~~(vx/m.factor);
9091
if(index<0){index=0;}
9192
var limit = index + 1+~~(dimensions.w/m.factor);

app/js/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ var yOld = myhero.sprite.y;
2020
//ctx.transform(1, 0, 0, 1, 0, 0);
2121
var currentScreen = 'i';
2222

23+
var updateBackground = function(xxs){
24+
xAxis+=xxs*0.1;
25+
}
26+
27+
2328
function gameLoop() {
2429
var wx = -viewport.x;
2530
var wy = viewport.y;
@@ -134,6 +139,7 @@ function gameLoop() {
134139
viewport.y-=yyy;
135140
yOld = myhero.sprite.y;
136141
ctx.translate(xxx, yyy);
142+
updateBackground(xxx);
137143

138144
//draw user interface information
139145
}

dist/a.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks.todo

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
+-- platforms
1717

1818
-- messages
19-
-- title
2019
-- backgrounds
20+
+-- title
2121
--- upgrounds
2222
-- color
2323
---- music
@@ -27,10 +27,13 @@
2727
-- events
2828
+-- on player X
2929
+-- on enemy died
30-
-- on level start
31-
-- on level ends
32-
-- on last enemy died
33-
-- on message ends
30+
--- on level start
31+
-- mostrar title
32+
-- tres segundos despues
33+
-- ejecutar msj de bienvenida
34+
--- on level ends
35+
----- on last enemy died
36+
--- on message ends
3437
+-- restart
3538
+-- start
3639
+-- ends
@@ -71,7 +74,7 @@
7174

7275
!-- if a monster fall remove...
7376
- viewport x again
74-
---- enemies with simple AI
77+
+---- enemies with simple AI
7578
---- implements textures for the backgrounds
7679

7780
---- implements sound management

0 commit comments

Comments
 (0)