Skip to content

Commit

Permalink
Finnito
Browse files Browse the repository at this point in the history
  • Loading branch information
debone committed Oct 3, 2021
1 parent 3ea1638 commit 9a36311
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 21 deletions.
Binary file added assets/sprites/spark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,34 @@
}

body {
background: rgb(71, 146, 112);
background: linear-gradient(
180deg,
rgba(71, 146, 112, 1) 0%,
rgba(209, 222, 143, 1) 25%,
rgba(209, 222, 143, 1) 66%,
rgba(193, 142, 89, 1) 67%,
rgba(193, 142, 89, 1) 95%,
rgba(146, 71, 71, 1) 100%
);
/*
background: rgb(133, 169, 135);
background: linear-gradient(
rgba(133, 169, 135, 1) 66%,
rgba(181, 136, 59, 1) 66%
);

background: rgb(74, 20, 57);
background: linear-gradient(
180deg,
rgba(74, 20, 57, 1) 0%,
rgba(146, 71, 71, 1) 11%,
rgba(133, 169, 135, 1) 25%,
rgba(133, 169, 135, 1) 66%,
rgba(181, 136, 59, 1) 67%,
rgba(181, 136, 59, 1) 93%,
rgba(145, 112, 74, 1) 100%
);*/
}

#game-container {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config = {
},
width: 1600,
height: 600,
backgroundColor: "#85a987",
backgroundColor: "#d1de8f",
//"render.transparent": true,
parent: "game-container",
physics: {
Expand Down
64 changes: 50 additions & 14 deletions js/SceneMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,46 @@ export class SceneMain extends Phaser.Scene {

this.cursors = this.input.keyboard.createCursorKeys();

this.player = this.add.group({
key: "player",
x: 400,
y: height,
frameQuantity: 100
});
this.player = this.add
.group({
key: "player",
x: 400,
y: height,
frameQuantity: 100
})
.setTint(0x4a1439);

this.playerPos = new Phaser.Math.Vector2(400, height);
this.playerVel = new Phaser.Math.Vector2(0, 0);
this.playerAcc = new Phaser.Math.Vector2(0, 0);

this.particles = this.add.particles("spark");
this.emitterBottom = this.particles.createEmitter({
alpha: { start: 1, end: 0 },
scale: { start: 0.5, end: 2.5 },
//tint: { start: 0xff945e, end: 0xff945e },
speed: 10,

angle: { min: -5, max: 10 },
rotate: { min: -180, max: 180 },
lifespan: { min: 2000, max: 2100 },

frequency: 11
});

this.emitterTop = this.particles.createEmitter({
alpha: { start: 1, end: 0 },
scale: { start: 0.5, end: 2.5 },
//tint: { start: 0xff945e, end: 0xff945e },
speed: 10,

angle: { min: -5, max: 10 },
rotate: { min: -180, max: 180 },
lifespan: { min: 2000, max: 2100 },

frequency: 11
});

this.cameras.main.startFollow(this.playerPos);
//this.cameras.main.followOffset.set(-300, 0);

Expand Down Expand Up @@ -708,7 +737,7 @@ export class SceneMain extends Phaser.Scene {
this.graphics.lineStyle(3, 0x4b83c0, 1);
this.graphics.lineBetween(curr, water, curr, terrain);
}
this.graphics.lineStyle(3, 0xb5883b, 1);
this.graphics.lineStyle(3, 0xc18e59, 1);
this.graphics.lineBetween(curr, terrain, curr, maxY);
}
}
Expand Down Expand Up @@ -739,10 +768,12 @@ export class SceneMain extends Phaser.Scene {
}

gameOver() {
this.scene.run("SceneGameOver");
this.cameras.main.stopFollow();
this.gameIsOver = true;
this.missionMarker.setText("");
if (!this.gameIsOver) {
this.scene.run("SceneGameOver");
this.cameras.main.stopFollow();
this.gameIsOver = true;
this.missionMarker.setText("");
}
}

renderMarker() {
Expand Down Expand Up @@ -785,9 +816,11 @@ export class SceneMain extends Phaser.Scene {
}

update(time, delta) {
this.text.setText(parseInt(this.playerPos.x, 10));
this.text.x = this.cameras.main.scrollX + this.width / 2;
this.text.y = 100;
if (this.debug) {
this.text.setText(parseInt(this.playerPos.x, 10));
this.text.x = this.cameras.main.scrollX + this.width / 2;
this.text.y = 100;
}

//Gravity
this.playerAcc.y += 0.05;
Expand All @@ -799,6 +832,9 @@ export class SceneMain extends Phaser.Scene {
}
this.playerPos.add(this.playerAcc);

this.emitterTop.setPosition(this.playerPos.x, this.playerPos.y - 9);
this.emitterBottom.setPosition(this.playerPos.x, this.playerPos.y + 9);

this.graphics.clear();

this.renderTerrain();
Expand Down
47 changes: 41 additions & 6 deletions js/SceneMainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class SceneMainMenu extends Phaser.Scene {
this.load.image("player", "assets/sprites/player.png");
this.load.image("fremen", "assets/sprites/fremen.png");
this.load.image("cave", "assets/sprites/cave.png");
this.load.image("spark", "assets/sprites/spark.png");
}

create() {
Expand All @@ -40,13 +41,44 @@ export default class SceneMainMenu extends Phaser.Scene {
.setOrigin(0.5, 0.5)
.setVisible(false);

this.player = this.add.group({
key: "player",
x: width / 2,
y: height / 2,
frameQuantity: 100
this.player = this.add
.group({
key: "player",
x: width / 2,
y: height / 2,
frameQuantity: 100
})
.setTint(0x4a1439);

this.particles = this.add.particles("spark");
this.emitterBottom = this.particles.createEmitter({
alpha: { start: 1, end: 0 },
scale: { start: 0.5, end: 2.5 },
//tint: { start: 0xff945e, end: 0xff945e },
speed: 10,

angle: { min: -5, max: 10 },
rotate: { min: -180, max: 180 },
lifespan: { min: 2000, max: 2100 },

frequency: 11
});

this.emitterTop = this.particles.createEmitter({
alpha: { start: 1, end: 0 },
scale: { start: 0.5, end: 2.5 },
//tint: { start: 0xff945e, end: 0xff945e },
speed: 10,

angle: { min: -5, max: 10 },
rotate: { min: -180, max: 180 },
lifespan: { min: 2000, max: 2100 },

frequency: 11
});

//this.emitter.startFollow(this.player);

this.input.keyboard.on("keydown", (event) => {
this.scene.start("SceneMain");
});
Expand Down Expand Up @@ -98,6 +130,9 @@ export default class SceneMainMenu extends Phaser.Scene {

this.playerPos.add(this.playerAcc);

this.emitterTop.setPosition(this.playerPos.x, this.playerPos.y - 9);
this.emitterBottom.setPosition(this.playerPos.x, this.playerPos.y + 9);

if (this.playerPos.x > this.cameras.main.worldView.width * 1.5) {
this.playerPos.x = -200;
this.playerPos.y = this.height - 250 * Math.random();
Expand Down Expand Up @@ -132,7 +167,7 @@ export default class SceneMainMenu extends Phaser.Scene {
for (let curr = this.cameras.main.worldView.x - 1000; curr < maxX; curr++) {
let terrain = this.calculateHeight(curr);

this.graphics.lineStyle(3, 0xb5883b, 1);
this.graphics.lineStyle(3, 0xc18e59, 1);
this.graphics.lineBetween(curr, terrain, curr, maxY);
}
}
Expand Down

0 comments on commit 9a36311

Please sign in to comment.