tutorial fixed, particles
This commit is contained in:
parent
5196dcf778
commit
aea12aeaa2
@ -26,13 +26,22 @@ function drawPlayingUI() {
|
||||
|
||||
switch(tutState) {
|
||||
case tutorialStates.getCereal:
|
||||
text("Objective: eat breakfast",10,ch-30,"black",2);
|
||||
curCtx.globalAlpha = 0.5;
|
||||
rect(150,ch-15,300,30,"white");
|
||||
curCtx.globalAlpha = 1;
|
||||
text("Objective: eat breakfast",10,ch-25,"black",2);
|
||||
break;
|
||||
case tutorialStates.getMail:
|
||||
text("Objective: bring in the mail",10,ch-30,"black",2);
|
||||
curCtx.globalAlpha = 0.5;
|
||||
rect(170,ch-15,340,30,"white");
|
||||
curCtx.globalAlpha = 1;
|
||||
text("Objective: bring in the mail",10,ch-25,"black",2);
|
||||
break;
|
||||
case tutorialStates.goToBed:
|
||||
text("Objective: go back to bed",10,ch-30,"black",2);
|
||||
curCtx.globalAlpha = 0.5;
|
||||
rect(150,ch-15,300,30,"white");
|
||||
curCtx.globalAlpha = 1;
|
||||
text("Objective: go back to bed",10,ch-25,"black",2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ var constants = {
|
||||
offset_y: 35
|
||||
},
|
||||
defaultX: 575,
|
||||
defaultY: -150
|
||||
defaultY: -155
|
||||
}
|
||||
|
||||
};
|
@ -15,6 +15,9 @@ Objective.prototype.draw = function() {
|
||||
|
||||
Objective.prototype.update = function() {
|
||||
if(rectrect(this,player)) {
|
||||
for(var j=0;j<50;j++) {
|
||||
Particles.push(new Particle(this.x,this.y));
|
||||
}
|
||||
this.callback();
|
||||
return true;
|
||||
}
|
||||
|
42
docs/assets/js/playing/particles.js
Normal file
42
docs/assets/js/playing/particles.js
Normal file
@ -0,0 +1,42 @@
|
||||
class Particle {
|
||||
constructor(x,y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.size = rand(2,8);
|
||||
var angle = rand(0,2262)/360;
|
||||
var speed = rand(5,10);
|
||||
this.vel = {x:Math.cos(angle) * speed,y:Math.sin(angle) * speed};
|
||||
this.timer = rand(25,50);
|
||||
}
|
||||
}
|
||||
|
||||
Particle.prototype.draw = function() {
|
||||
rect(this.x,this.y,this.size,this.size,"#baba30");
|
||||
}
|
||||
|
||||
Particle.prototype.update = function() {
|
||||
if(this.timer <= 0) {
|
||||
return true;
|
||||
}
|
||||
--this.timer;
|
||||
this.x += this.vel.x;
|
||||
this.y += this.vel.y;
|
||||
this.vel.y += 0.1;
|
||||
return false;
|
||||
}
|
||||
|
||||
var Particles = [];
|
||||
function updateParticles() {
|
||||
for(var i=0;i<Particles.length;i++) {
|
||||
if(Particles[i].update()) {
|
||||
Particles.splice(i,1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawParticles() {
|
||||
for(var i=0;i<Particles.length;i++) {
|
||||
Particles[i].draw();
|
||||
}
|
||||
}
|
@ -48,13 +48,13 @@ function handlePlaying() {
|
||||
case tutorialStates.getCereal:
|
||||
break;
|
||||
case tutorialStates.getMail:
|
||||
if(!player.holdingBox) {
|
||||
if(boxOnTable) {
|
||||
tutState = tutorialStates.goToBed;
|
||||
}
|
||||
break;
|
||||
case tutorialStates.goToBed:
|
||||
if(player.x > 560) {
|
||||
|
||||
globalState = globalStates.end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -81,6 +81,7 @@ function handlePlaying() {
|
||||
}
|
||||
|
||||
updateLife();
|
||||
updateParticles();
|
||||
updateObjectives();
|
||||
}
|
||||
|
||||
@ -95,6 +96,9 @@ function drawPlaying() {
|
||||
if(boxOnTable) {
|
||||
imgIgnoreCutoff(sprites.boxNoOutline,-140,116,0,4,4);
|
||||
}
|
||||
|
||||
drawParticles();
|
||||
|
||||
// drawWorldBlocks();
|
||||
player.draw();
|
||||
|
||||
|
@ -72,6 +72,7 @@ Matthew West
|
||||
|
||||
<script src="assets/js/playing/playing.js"></script>
|
||||
<script src="assets/js/playing/objective.js"></script>
|
||||
<script src="assets/js/playing/particles.js"></script>
|
||||
|
||||
<script src="assets/js/titleScreen/titleScreen.js"></script>
|
||||
<script src="assets/js/UI/ui.js"></script>
|
||||
|
Reference in New Issue
Block a user