Skip to content

Commit

Permalink
Merge pull request #30 from rengert/balancing
Browse files Browse the repository at this point in the history
Balancing
  • Loading branch information
rengert authored Feb 11, 2024
2 parents 94b7805 + 66114b8 commit 0b350b6
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 347 deletions.
2 changes: 1 addition & 1 deletion ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.3.0</string>
<key>CFBundleVersion</key>
<string>4</string>
<string>5</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
12 changes: 6 additions & 6 deletions ios/App/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- Capacitor (5.6.0):
- Capacitor (5.7.0):
- CapacitorCordova
- CapacitorCordova (5.6.0)
- CapacitorSplashScreen (5.0.6):
- CapacitorCordova (5.7.0)
- CapacitorSplashScreen (5.0.7):
- Capacitor

DEPENDENCIES:
Expand All @@ -19,9 +19,9 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/splash-screen"

SPEC CHECKSUMS:
Capacitor: ebfc16cdb8116d04c101686b080342872da42d43
CapacitorCordova: 931b48fcdbc9bc985fc2f16cec9f77c794a27729
CapacitorSplashScreen: 5fa2ab5e46cf5cc530cf16a51c80c7a986579ccd
Capacitor: fc155ee2ee45a2093d716f13cf5aa5a865e2d85a
CapacitorCordova: e825fce1a2e14e4b5730641c7e098dccf74397b7
CapacitorSplashScreen: dd3de3f3644710fa2a697cfb91ec262eece4d242

PODFILE CHECKSUM: f335af037f3993fa7c4aaec9ad935feb22d428fc

Expand Down
605 changes: 312 additions & 293 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/app/game-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Config {
interface GameConfig extends Config {
enemy: {
autoSpawnSpeed: number;
maxCount: number;
},
meteor: {
autoSpawnSpeed: number;
Expand All @@ -23,6 +24,7 @@ interface GameConfig extends Config {
export const GAME_CONFIG: GameConfig = {
enemy: {
autoSpawnSpeed: 1.35, // per second
maxCount: 20,
},
meteor: {
autoSpawnSpeed: 0.35, // per second
Expand Down
6 changes: 2 additions & 4 deletions src/app/models/pixijs/animated-game-sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ export class AnimatedGameSprite extends AnimatedSprite {
destroying = false;
targetX?: number;

// eslint-disable-next-line max-params
constructor(
readonly type: ObjectType,
private readonly explosion: ExplosionService | null,
speed: number,
textures: Texture[] | FrameObject[],
autoUpdate?: boolean) {
super(textures, autoUpdate);
textures: Texture[] | FrameObject[]) {
super(textures);

this.speed = speed;
}
Expand Down
29 changes: 15 additions & 14 deletions src/app/models/pixijs/background-sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ import { Texture, TilingSprite } from 'pixi.js';
export class BackgroundSprite extends TilingSprite {
// eslint-disable-next-line max-params
constructor(
private readonly speedTilepositionY: number,
private readonly speedTilepositionX: number,
texture: Texture,
width: number,
height: number,
private readonly speedY = 0,
private readonly maxY = 1000) {
super(texture, width, height);

this.speedTilepositionY = speedTilepositionY;
this.speedTilepositionX = speedTilepositionX;
private readonly config: {
speedTilePositionY: number,
speedTilePositionX: number,
width: number,
height: number,
speedY?: number,
maxY?: number
}) {
super(texture, config.width, config.height);
}

update(delta: number): void {
this.tilePosition.y += delta * this.speedTilepositionY;
this.tilePosition.x += delta * this.speedTilepositionX;
this.tilePosition.y += delta * this.config.speedTilePositionY;
this.tilePosition.x += delta * this.config.speedTilePositionX;

this.y += delta * this.speedY;
if (this.y > this.maxY) {
if (this.config.speedY) {
this.y += delta * this.config.speedY;
}
if (this.y > (this.config.maxY ?? 1000)) {
this.y = -this.height;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/models/pixijs/rocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ export class Rocket extends AnimatedGameSprite {
constructor(
explosion: ExplosionService,
speed: number,
textures: Texture[] | FrameObject[],
autoUpdate?: boolean) {
super(ObjectType.rocket, explosion, speed, textures, autoUpdate);
textures: Texture[] | FrameObject[]) {
super(ObjectType.rocket, explosion, speed, textures);

this.energy = 1;
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/models/pixijs/ship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ export class Ship extends AnimatedGameSprite {
private readonly shotService: GameShotService,
explosion: ExplosionService,
speed: number,
textures: Texture[] | FrameObject[],
autoUpdate?: boolean) {
super(shipType as unknown as ObjectType, explosion, speed, textures, autoUpdate);
textures: Texture[] | FrameObject[]) {
super(shipType as unknown as ObjectType, explosion, speed, textures);

this.energy = GAME_CONFIG.ships[this.shipType].energy;
this.shotSpeed = GAME_CONFIG.ships[this.shipType].shotSpeed;
Expand Down
5 changes: 2 additions & 3 deletions src/app/services/game-enemy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Ship } from '../models/pixijs/ship';
import { ShipType } from '../models/pixijs/ship-type.enum';
import { BaseService } from './base.service';
import { ExplosionService } from './explosion.service';
import { GameCollectableService } from './game-collectable.service';
import { GameShotService } from './game-shot.service';

@Injectable()
Expand All @@ -16,7 +15,6 @@ export class GameEnemyService extends BaseService {
private enemySprite!: Spritesheet;

constructor(
private readonly collectables: GameCollectableService,
private readonly explosionService: ExplosionService,
private readonly shotService: GameShotService,
) {
Expand All @@ -37,7 +35,8 @@ export class GameEnemyService extends BaseService {
});

const check = Math.floor(this.elapsed);
if (((check % Math.floor(60 / (GAME_CONFIG.enemy.autoSpawnSpeed + (0.1 * (level - 1))))) === 0)
if (this.object.enemies().length < GAME_CONFIG.enemy.maxCount
&& ((check % Math.floor(60 / (GAME_CONFIG.enemy.autoSpawnSpeed + (0.1 * (level - 1))))) === 0)
&& (check !== this.lastEnemySpawn)) {
this.lastEnemySpawn = check;
this.spawn(level);
Expand Down
44 changes: 24 additions & 20 deletions src/app/services/game-landscape.service.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Texture } from 'pixi.js';
import { BackgroundSprite } from '../models/pixijs/background-sprite';
import { ApplicationService } from './application.service';

@Injectable()
export class GameLandscapeService {
private readonly application = inject(ApplicationService);
private readonly landscapes: BackgroundSprite[] = [];

constructor(private readonly application: ApplicationService) {
}

setup(): void {
if (this.landscapes.length) {
throw new Error('do not call setup twice');
}

const background = new BackgroundSprite(
0.25,
0,
Texture.from('assets/game/desert-background-looped.png'),
this.application.screen.width,
this.application.screen.height,
{
speedTilePositionY: 0.25,
speedTilePositionX: 0,
width: this.application.screen.width,
height: this.application.screen.height,
},
);
this.landscapes.push(background);
this.application.stage.addChild(background);

const cloud = new BackgroundSprite(
0,
0.25,
Texture.from('assets/game/clouds-transparent.png'),
this.application.screen.width,
103,
0.75,
this.application.screen.height,
{
speedTilePositionY: 0,
speedTilePositionX: 0.25,
width: this.application.screen.width,
height: 103,
speedY: 0.75,
maxY: this.application.screen.height,
},
);
cloud.y = Math.floor(this.application.screen.height / 2);
this.landscapes.push(cloud);
this.application.stage.addChild(cloud);

const cloud2 = new BackgroundSprite(
0,
0.27,
Texture.from('assets/game/clouds-transparent.png'),
this.application.screen.width,
103,
0.8,
this.application.screen.height,
{
speedTilePositionY: 0,
speedTilePositionX: 0.30,
width: this.application.screen.width,
height: 103,
speedY: 0.85,
maxY: this.application.screen.height,
},
);
cloud2.y = Math.floor(this.application.screen.height / 4);
this.landscapes.push(cloud2);
Expand Down

0 comments on commit 0b350b6

Please sign in to comment.