Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
Empty file added js-shooter-game@1.0.0
Empty file.
7 changes: 5 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[build]
command = "npm run build"
command = "rm -rf node_modules package-lock.json && npm install && npm run build"
publish = "dist"

[build.environment]
NODE_VERSION = "18"
NODE_VERSION = "20"
NODE_ENV = "production"
CI = "false"
NETLIFY_USE_YARN = "false"
NPM_FLAGS = "--no-package-lock"

[context.production.environment]
NODE_ENV = "production"
Expand Down
2,710 changes: 1,772 additions & 938 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"setupFilesAfterEnv": [
"jest-expect-subclass"
],
"testEnvironment": "jsdom",
"moduleNameMapper": {
"\\.(gif|ttf|eot|svg|png|jpg|mp3)$": "<rootDir>/test/mocks/fileMock.js"
}
Expand All @@ -28,33 +29,34 @@
"licenseUrl": "",
"homepage": "",
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/plugin-transform-runtime": "^7.24.1",
"@babel/preset-env": "^7.24.0",
"babel-loader": "^9.1.3",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.10.0",
"style-loader": "^3.3.4",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.0",
"jest-environment-jsdom": "^30.3.0",
"jest-expect-subclass": "^1.0.1",
"raw-loader": "^4.0.2",
"stylelint": "^16.2.1",
"stylelint-config-standard": "^36.0.0",
"stylelint-csstree-validator": "^4.0.0",
"stylelint-scss": "^6.1.0",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"@babel/core": "^7.24.0",
"@babel/plugin-transform-runtime": "^7.24.1",
"@babel/preset-env": "^7.24.0",
"babel-loader": "^9.1.3",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.10.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"phaser": "^4.0.0",
"style-loader": "^3.3.4",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.10.0"
},
"dependencies": {
"phaser": "^3.24.1"
}
}
4 changes: 2 additions & 2 deletions src/Config/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import 'phaser';
import * as Phaser from 'phaser';

const config = {
type: Phaser.AUTO,
Expand All @@ -8,7 +8,7 @@ const config = {
physics: {
default: 'arcade',
arcade: {
debug: false,
debug: true,
gravity: { y: 0 },

},
Expand Down
2 changes: 1 addition & 1 deletion src/Js/Button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';
import Dom from '../Tools/dom';

/**
Expand Down
33 changes: 29 additions & 4 deletions src/Js/ChaserDude.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Entity from './Entity';
import * as Phaser from 'phaser';

/**
* Clase que representa un enemigo perseguidor
Expand All @@ -18,11 +19,19 @@ class ChaserDude extends Entity {
this.setGravityY(800);
this.setScale(3);

// Colisión más estrecha para evitar amontonamiento (15% del ancho)
// Ancho original: 28 * 3 = 84px, 15% = ~12px, offset para centrar
const collisionWidth = 12; // 15% del ancho original
const offsetX = (20 - collisionWidth) / 2; // Centrar colisión
this.body.setSize(collisionWidth, 47);
this.body.setOffset(offsetX, 0);

// Estadísticas del enemigo
this.hp = 1000; // Puntos de vida
this.touch = false; // Indica si está siendo dañado
this.alive = true; // Estado de vida
this.damage = 50; // Daño que inflige al jugador
this.damage = 50;
this.fell = false; // Daño que inflige al jugador
}

/**
Expand All @@ -40,6 +49,14 @@ class ChaserDude extends Entity {
this.setFlipX(false); // Restaura orientación
}
}
// Nueva propiedad
// Añadir método para marcar como caído
fall() {
if (!this.fell) {
this.fell = true;
this.die(); // Llama al método die existente
}
}

/**
* Método update de Phaser - Se ejecuta en cada frame
Expand All @@ -53,20 +70,25 @@ class ChaserDude extends Entity {
);

// Si el jugador está dentro del rango de detección (580px), lo persigue
if (distanceToPlayer < 580) {
if (distanceToPlayer < 780) {
this.huntPlayer();

} else {
// Reproduce animación de reposo
this.play('dudeleft');
}

if (this.y> 750 ){
this.fall();
}
}

/**
* Aplica daño al enemigo
* @param {number} damage - Cantidad de daño a aplicar
*/
damg(damage) {
this.damageOrKill(damage);
return this.damageOrKill(damage);
}

/**
Expand Down Expand Up @@ -94,8 +116,11 @@ class ChaserDude extends Entity {
die() {
// Efecto visual de muerte (tinte negro)
this.setTint('#000');
this.setActive(false);
this.scene.score+= 2000;

this.scene.scoreText.setText(`Score: ${this.scene.score}`);
this.setActive(false);

// Detiene movimiento y física
this.setVelocityX(0);
this.setVelocityY(0);
Expand Down
2 changes: 1 addition & 1 deletion src/Js/Entity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import Phaser from 'phaser';
import * as Phaser from 'phaser';

/**
* Clase base para todas las entidades del juego
Expand Down
2 changes: 1 addition & 1 deletion src/Js/HeartPickup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';

/**
* Clase que representa un corazón recolectable
Expand Down
34 changes: 33 additions & 1 deletion src/Js/JumperDude.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Entity from './Entity';
import HeartPickup from './HeartPickup';
import * as Phaser from 'phaser';

class JumperDude extends Entity {
constructor(config) {
Expand All @@ -14,10 +15,19 @@ class JumperDude extends Entity {
this.body.setSize(28, 47);
this.setGravityY(800);
this.setScale(3);

// Colisión más estrecha para evitar amontonamiento (15% del ancho)
// Ancho original: 28 * 3 = 84px, 15% = ~12px, offset para centrar
const collisionWidth = 12; // 15% del ancho original
const offsetX = (24 - collisionWidth) / 2; // Centrar colisión
this.body.setSize(collisionWidth, 47);
this.body.setOffset(offsetX, 0);

this.hp = 1000;
this.touch = false;
this.alive = true;
this.damage = 50;
this.fell = false;
}

jump(coinToss) {
Expand All @@ -37,9 +47,23 @@ class JumperDude extends Entity {
const headsOrTails = (Math.random() > 0.7);
this.jump(headsOrTails);
}
fall() {
if (!this.fell) {
this.fell = true;



this.die(); // Llama al método die existente
}
}

// this.x < this.scene.cameras.main.scrollX + this.scene.sys.game.canvas.width - 50
update() {
// Verificar si el enemigo cayó (muerte por caída - coordenada Y > 750)
if (this.y> 750 ){
this.fall();
}

if (Phaser.Math.Distance.Between(this.x, this.y, this.scene.player.x, this.scene.player.y) < 580) {
if (this.body.blocked.down) {
this.jumpRandom();
Expand All @@ -52,6 +76,7 @@ class JumperDude extends Entity {
}

damageOrKill(damage) {
// Si ya está muerto, no aplicar daño
this.touch = true;
if (this.touch === true) {
this.hp -= damage;
Expand All @@ -60,14 +85,15 @@ class JumperDude extends Entity {
return true;
}
this.touch = false;

return false;
}
return false;
}

die() {
this.setTint('#000');
this.scene.score+= 2000;
this.scene.scoreText.setText(`Score: ${this.scene.score}`);
this.setActive(false);
this.setVelocityX(0);
this.setVelocityY(0);
Expand All @@ -80,6 +106,12 @@ class JumperDude extends Entity {
this.scene.heartsGroup.add(heart);
}

// Añadir puntuación por matar JumperDude (2000 puntos)
if (this.scene && this.scene.score !== undefined && this.scene.scoreText) {
this.scene.score += 2000;
this.scene.scoreText.setText(`Score: ${this.scene.score}`);
}

setTimeout(() => {
this.setVisible(false);
}, 3000);
Expand Down
2 changes: 1 addition & 1 deletion src/Js/Laser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import Phaser from 'phaser';
import * as Phaser from 'phaser';

/**
* Clase que representa un láser/proyectil disparado por el jugador
Expand Down
2 changes: 1 addition & 1 deletion src/Js/LaserGroup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';
import Laser from './Laser';

export default class LaserGroup extends Phaser.Physics.Arcade.Group {
Expand Down
2 changes: 1 addition & 1 deletion src/Js/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Player extends Entity {
texture: 'stand',
});
// Configuración física del jugador
this.body.setSize(160, 200);
this.body.setSize(177, 210);
this.setScale(0.5);
this.setGravityY(520);
this.setCollideWorldBounds(true); // Colisionar con límites del mundo
Expand Down
2 changes: 1 addition & 1 deletion src/Js/Slash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';

export default class Slash extends Phaser.Physics.Arcade.Sprite {
constructor(scene, x, y, key) {
Expand Down
2 changes: 1 addition & 1 deletion src/Js/SlashGroup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';
import Slash from './Slash';

export default class SlashGroup extends Phaser.Physics.Arcade.Group {
Expand Down
2 changes: 1 addition & 1 deletion src/Scenes/BootScene.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';
import logo from '../assets/backgroun.jpg';

// eslint-disable-next-line no-undef
Expand Down
2 changes: 1 addition & 1 deletion src/Scenes/CreditsScene.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef, no-unused-expressions */
import Phaser from 'phaser';
import * as Phaser from 'phaser';
import Button from '../Js/Button';

export default class CreditsScene extends Phaser.Scene {
Expand Down
2 changes: 1 addition & 1 deletion src/Scenes/GameOverScene.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Phaser from 'phaser';
import * as Phaser from 'phaser';
import Button from '../Js/Button';
import Dom from '../Tools/dom';
import LocalStorage from '../Tools/localStorage';
Expand Down
Loading
Loading