[READ-ONLY] Mirror of https://github.com/flo-bit/shadow-shmup. Fun and casual top-down, roguelike shoot 'em up browsergame with shadow elements and colorful neon effects flo-bit.dev/shadow-shmup/
browsergame pixijs rapier2d roguelike shoot-em-up typescript webgame
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor

Florian (Aug 4, 2024, 10:34 AM +0200) a0b27c2f 46a951bf

+88 -73
+41 -16
src/app.ts
··· 1 - import Player from './player.js'; 2 - import EnemyManager from './enemy-manager.js'; 3 1 import * as PIXI from 'pixi.js'; 4 2 import { type World, EventQueue } from '@dimforge/rapier2d'; 5 - import { RAPIER } from './rapier.js'; 6 - import ParticleSystem from './particles.js'; 7 - import { Projectile } from './projectile.js'; 8 - import Enemy from './enemy.js'; 3 + import { RAPIER } from './helper/rapier.js'; 9 4 10 5 import Stats from 'stats.js'; 11 6 12 7 import { AdvancedBloomFilter } from 'pixi-filters'; 13 - import PlayerManager from './player-manager.js'; 14 - import ProjectileManager, { ProjectileData } from './projectile-manager.js'; 8 + import { sound } from '@pixi/sound'; 15 9 16 - import { sound } from '@pixi/sound'; 17 - import Controls from './controls.js'; 18 - import { ObstacleManager } from './obstacle-manager.js'; 10 + import ParticleSystem from './visuals/particles.js'; 11 + import { Projectile } from './weapons/projectile.js'; 12 + import Enemy from './enemies/enemy.js'; 13 + import Player from './player/player.js'; 14 + import EnemyManager from './enemies/enemy-manager.js'; 15 + 16 + import PlayerManager from './player/player-manager.js'; 17 + import ProjectileManager, { ProjectileData } from './weapons/projectile-manager.js'; 18 + 19 + import Controls from './helper/controls.js'; 20 + import { ObstacleManager } from './map/obstacle-manager.js'; 19 21 import { WaveManager } from './wave.js'; 20 - import { Item, ItemOptions } from './item.js'; 21 - import { ItemManager } from './item-manager.js'; 22 - import { LightManager } from './light-manager.js'; 23 - import { createNoiseSprite } from './helper.js'; 24 - import { UpgradeManager } from './upgrade-manager.js'; 22 + import { Item, ItemOptions } from './coins/coin.js'; 23 + import { ItemManager } from './coins/coin-manager.js'; 24 + import { LightManager } from './visuals/light-manager.js'; 25 + import { createNoiseSprite } from './helper/helper.js'; 26 + import { UpgradeManager } from './upgrades/upgrade-manager.js'; 25 27 import { Weapon } from './weapons/weapon.js'; 26 28 27 29 export default class Game { ··· 122 124 let gravity = new RAPIER.Vector2(0.0, 0.0); 123 125 let world = new RAPIER.World(gravity); 124 126 127 + // @ts-ignore 125 128 window.RAPIER = RAPIER; 126 129 this.world = world; 127 130 } ··· 137 140 createStats() { 138 141 this.stats = new Stats(); 139 142 document.body.appendChild(this.stats.dom); 143 + } 144 + 145 + showText(x: number, y: number, color: number, text: string) { 146 + const style = new PIXI.TextStyle({ 147 + fontFamily: 'Arial', 148 + fontSize: 36, 149 + fill: color, 150 + align: 'center' 151 + }); 152 + 153 + // Create the text object 154 + const richText = new PIXI.Text({ text, style }); 155 + 156 + richText.anchor.set(0.5); 157 + // Position the text 158 + 159 + richText.position.set(x, y); 160 + 161 + // Add the text to the stage 162 + this.container.addChild(richText); 140 163 } 141 164 142 165 removeStats() { ··· 329 352 330 353 if (enemy && projectile) { 331 354 this.spawnParticles(projectile.shape.x, projectile.shape.y, 10, projectile.color); 355 + 356 + this.showText(enemy.x, enemy.y, projectile.color, projectile.damage.toString()); 332 357 333 358 enemy.impulse(projectile.vx * 200000, -projectile.vy * 200000); 334 359 enemy.takeDamage(projectile.damage);
+1 -1
src/controls.ts src/helper/controls.ts
··· 1 - import Game from './app'; 1 + import Game from '../app'; 2 2 3 3 export default class Controls { 4 4 keys: Record<string, boolean> = {};
+2 -2
src/enemy-manager.ts src/enemies/enemy-manager.ts
··· 1 1 import { Vector2 } from '@dimforge/rapier2d'; 2 - import Game from './app.js'; 2 + import Game from '../app.js'; 3 3 import Enemy, { PentagonEnemy, SphereEnemy, TriangleEnemy } from './enemy.js'; 4 4 5 5 export default class EnemyManager { ··· 23 23 addEnemy(enemyType: typeof Enemy = this.randomEnemyType()) { 24 24 const enemy = new enemyType(this.game); 25 25 this.enemies.push(enemy); 26 - 26 + 27 27 return enemy; 28 28 } 29 29
+7 -7
src/enemy.ts src/enemies/enemy.ts
··· 1 1 import * as PIXI from 'pixi.js'; 2 - import Game from './app'; 3 - import { RAPIER } from './rapier'; 2 + import Game from '../app'; 3 + import { RAPIER } from '../helper/rapier'; 4 4 import { Vector2, type RigidBody } from '@dimforge/rapier2d'; 5 - import Eye from './eye'; 6 - import Player from './player'; 7 - import { GunWeapon } from './weapons/gun'; 8 - import { Projectile } from './projectile'; 5 + import Eye from '../visuals/eye'; 6 + import Player from '../player/player'; 7 + import { GunWeapon } from '../weapons/gun'; 8 + import { Projectile } from '../weapons/projectile'; 9 9 import { sound } from '@pixi/sound'; 10 10 11 11 interface PlayerHit { ··· 718 718 719 719 this.weapon.update(deltaTime); 720 720 } 721 - } 721 + }
src/eye.ts src/visuals/eye.ts
src/helper.ts src/helper/helper.ts
+2 -2
src/item-manager.ts src/coins/coin-manager.ts
··· 1 - import Game from './app'; 2 - import { Item, ItemOptions } from './item'; 1 + import Game from '../app'; 2 + import { Item, ItemOptions } from './coin'; 3 3 4 4 export class ItemManager { 5 5 items: Item[] = [];
+4 -3
src/item.ts src/coins/coin.ts
··· 1 1 import { Collider, RigidBody } from '@dimforge/rapier2d'; 2 - import Game from './app'; 3 2 import * as PIXI from 'pixi.js'; 4 - import { RAPIER } from './rapier'; 5 - import Player from './player'; 3 + import { RAPIER } from '../helper/rapier'; 4 + 5 + import Game from '../app'; 6 + import Player from '../player/player'; 6 7 7 8 export type ItemOptions = { 8 9 x: number;
src/light-manager.ts src/visuals/light-manager.ts
+2 -2
src/light.ts src/visuals/light.ts
··· 1 1 import * as PIXI from 'pixi.js'; 2 - import { RAPIER } from './rapier'; 3 - import Game from './app'; 2 + import { RAPIER } from '../helper/rapier'; 3 + import Game from '../app'; 4 4 import { RigidBody } from '@dimforge/rapier2d'; 5 5 // import 'pixi.js/advanced-blend-modes'; 6 6
+3 -3
src/obstacle-manager.ts src/map/obstacle-manager.ts
··· 1 - import Game from './app'; 1 + import Game from '../app'; 2 2 import * as PIXI from 'pixi.js'; 3 3 import Obstacle from './obstacles'; 4 4 5 5 import Alea from 'alea'; 6 - import { Light } from './light'; 6 + import { Light } from '../visuals/light'; 7 7 8 8 const CELL_SIZE = 1200; 9 9 const OBSTACLE_COUNT_PER_CELL = 40; ··· 252 252 } 253 253 }); 254 254 } 255 - } 255 + }
+3 -3
src/obstacles.ts src/map/obstacles.ts
··· 1 1 import { Collider } from '@dimforge/rapier2d'; 2 - import Game from './app'; 3 - import { RAPIER } from './rapier'; 2 + import Game from '../app'; 3 + import { RAPIER } from '../helper/rapier'; 4 4 import * as PIXI from 'pixi.js'; 5 5 6 6 export default class Obstacle { ··· 40 40 this.game.world.removeCollider(this.collider, false); 41 41 this.container.removeChild(this.graphics); 42 42 } 43 - } 43 + }
src/particles.ts src/visuals/particles.ts
+1 -2
src/player-manager.ts src/player/player-manager.ts
··· 1 - import Game from './app.js'; 2 - import Enemy from './enemy.js'; 1 + import Game from '../app.js'; 3 2 import Player from './player.js'; 4 3 5 4 export default class PlayerManager {
+7 -7
src/player.ts src/player/player.ts
··· 1 - import { GunWeapon } from './weapons/gun.js'; 1 + import { GunWeapon } from '../weapons/gun.js'; 2 2 import * as PIXI from 'pixi.js'; 3 3 4 - import Game from './app'; 5 - import { RAPIER } from './rapier'; 4 + import Game from '../app.js'; 5 + import { RAPIER } from '../helper/rapier.js'; 6 6 import { type RigidBody } from '@dimforge/rapier2d'; 7 - import Eye from './eye.js'; 8 - import { Light } from './light.js'; 9 - import { blendColors } from './helper.js'; 10 - import { Weapon } from './weapons/weapon.js'; 7 + import Eye from '../visuals/eye.js'; 8 + import { Light } from '../visuals/light.js'; 9 + import { blendColors } from '../helper/helper.js'; 10 + import { Weapon } from '../weapons/weapon.js'; 11 11 import { sound } from '@pixi/sound'; 12 12 13 13 export default class Player {
+1 -1
src/projectile-manager.ts src/weapons/projectile-manager.ts
··· 1 - import Game from './app'; 1 + import Game from '../app'; 2 2 import { Projectile } from './projectile'; 3 3 4 4 export type ProjectileData = {
+2 -2
src/projectile.ts src/weapons/projectile.ts
··· 1 1 import * as PIXI from 'pixi.js'; 2 - import { RAPIER } from './rapier'; 3 - import Game from './app'; 2 + import { RAPIER } from '../helper/rapier'; 3 + import Game from '../app'; 4 4 import { ProjectileData } from './projectile-manager'; 5 5 6 6 export class Projectile {
+2
src/rapier.ts src/helper/rapier.ts
··· 1 1 export function RAPIER(): typeof import('@dimforge/rapier2d') { 2 + // @ts-ignore 2 3 if (!window.RAPIER) { 3 4 throw new Error('RAPIER is not initialized yet. Make sure to call setupPhysicsWorld() first.'); 4 5 } 6 + // @ts-ignore 5 7 return window.RAPIER; 6 8 }
-11
src/types/global.d.ts
··· 1 - // src/types/global.d.ts 2 - import * as RAPIER from '@dimforge/rapier2d'; 3 - 4 - export {}; 5 - 6 - declare global { 7 - interface Window { 8 - RAPIER: RAPIER; 9 - world: any; 10 - } 11 - }
+2 -3
src/upgrade-manager.ts src/upgrades/upgrade-manager.ts
··· 1 - import Game from './app'; 2 - import { Item } from './item'; 1 + import Game from '../app'; 2 + import { Item } from '../coins/coin'; 3 3 import { addUpgradeOption } from './upgrades'; 4 4 import { allUpgrades, Upgrade } from './upgrades-player'; 5 - 6 5 7 6 export class UpgradeManager { 8 7 colors_classes = ['bg-sky-500', 'bg-pink-500', 'bg-emerald-500'];
+3 -3
src/upgrades-player.ts src/upgrades/upgrades-player.ts
··· 1 - import Player from './player'; 1 + import Player from '../player/player'; 2 2 import { Icon } from './upgrades'; 3 - import { BallWeapon } from './weapons/ball'; 4 - import { Knife } from './weapons/knife'; 3 + import { BallWeapon } from '../weapons/ball'; 4 + import { Knife } from '../weapons/knife'; 5 5 6 6 export type Upgrade = { 7 7 upgrade: (player: Player) => void;
src/upgrades.ts src/upgrades/upgrades.ts
+1 -1
src/wave.ts
··· 1 1 import Game from './app'; 2 - import Enemy, { PentagonEnemy, SphereEnemy, TriangleEnemy } from './enemy'; 2 + import Enemy, { PentagonEnemy, SphereEnemy, TriangleEnemy } from './enemies/enemy'; 3 3 4 4 type EnemySpawnConfig = { 5 5 type: typeof Enemy;
+1 -1
src/weapons/ball.ts
··· 1 1 import Game from '../app'; 2 2 import { Light } from '../light'; 3 3 import * as PIXI from 'pixi.js'; 4 - import { RAPIER } from '../rapier'; 4 + import { RAPIER } from '../helper/rapier'; 5 5 import { Collider, RigidBody } from '@dimforge/rapier2d'; 6 6 import { Weapon } from './weapon'; 7 7
+1 -1
src/weapons/burst.ts
··· 1 1 import Game from '../app'; 2 2 import { Light } from '../light'; 3 3 import * as PIXI from 'pixi.js'; 4 - import { RAPIER } from '../rapier'; 4 + import { RAPIER } from '../helper/rapier'; 5 5 import { Collider, RigidBody } from '@dimforge/rapier2d'; 6 6 import { Weapon } from './weapon'; 7 7 import { GunWeapon } from './gun';
+1 -1
src/weapons/gun.ts
··· 1 1 import Game from '../app'; 2 - import { Projectile } from '../projectile'; 2 + import { Projectile } from './projectile'; 3 3 4 4 import { sound } from '@pixi/sound'; 5 5
+1 -1
src/weapons/knife.ts
··· 1 1 import Game from '../app'; 2 2 import { Light } from '../light'; 3 3 import * as PIXI from 'pixi.js'; 4 - import { RAPIER } from '../rapier'; 4 + import { RAPIER } from '../helper/rapier'; 5 5 import { Collider, RigidBody, Vector2 } from '@dimforge/rapier2d'; 6 6 import { Weapon } from './weapon'; 7 7