Skip to content

Commit

Permalink
Merge pull request #23 from rengert/better-grafics
Browse files Browse the repository at this point in the history
Better grafics
  • Loading branch information
rengert authored Sep 30, 2023
2 parents 374895a + 2c1b4c0 commit 9779871
Show file tree
Hide file tree
Showing 45 changed files with 849 additions and 585 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"hit",
"shot",
"collide",
"resize"
"resize",
"migrate"
]
}
],
Expand Down
28 changes: 28 additions & 0 deletions ios/App/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PODS:
- Capacitor (5.3.0):
- CapacitorCordova
- CapacitorCordova (5.3.0)
- CapacitorSplashScreen (5.0.6):
- Capacitor

DEPENDENCIES:
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
- "CapacitorSplashScreen (from `../../node_modules/@capacitor/splash-screen`)"

EXTERNAL SOURCES:
Capacitor:
:path: "../../node_modules/@capacitor/ios"
CapacitorCordova:
:path: "../../node_modules/@capacitor/ios"
CapacitorSplashScreen:
:path: "../../node_modules/@capacitor/splash-screen"

SPEC CHECKSUMS:
Capacitor: 1ac9165943bc4f2137642d218c5ba05df811de69
CapacitorCordova: b9374d68e63ce29e96ab5db994cf14fbefd722c9
CapacitorSplashScreen: 5fa2ab5e46cf5cc530cf16a51c80c7a986579ccd

PODFILE CHECKSUM: 7a859ce68b9d4ff260e7aa4163685f3f2d526323

COCOAPODS: 1.12.1
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test --watch=false --browsers=ChromeHeadless",
"lint": "ng lint"
"lint": "ng lint",
"build:ios": "ng build && npx cap sync ios && npx cap open ios"
},
"private": true,
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/pixijs/pixijs.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Component, ElementRef, NgZone, OnInit } from '@angular/core';
import { PixiGameService } from '../../services/pixi-game.service';
import { GameService } from '../../services/game.service';

@Component({
selector: 'app-pixijs',
template: '',
providers: [PixiGameService],
providers: [GameService],
})
export class PixijsComponent implements OnInit {
constructor(
private readonly elementRef: ElementRef,
private readonly ngZone: NgZone,
private readonly pixiGame: PixiGameService,
private readonly pixiGame: GameService,
) {
}

Expand Down
66 changes: 66 additions & 0 deletions src/app/game-constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { PowerUp } from './models/pixijs/power-up-sprite';
import { PowerUpConfig } from './models/power-up-config.model';

interface Config {
powerUpConfig: PowerUpConfig[];
}

interface GameConfig extends Config {
enemy: {
autoSpawnSpeed: number;
},
ship: {
shotSpeed: number;
}
}

export const GAME_CONFIG: GameConfig = {
enemy: {
autoSpawnSpeed: 1.35, // per second
},
ship: {
shotSpeed: 3, // speed in pixel
},
powerUpConfig: [
{
type: PowerUp.speed,
assetUrl: 'assets/game/power-up-1.json',
animationName: 'power-up-1',
powerUp: {
speed: 0.1,
shot: 0,
energy: 0,
},
},
{
type: PowerUp.shotSpeed,
assetUrl: 'assets/game/power-up-2.json',
animationName: 'power-up-2',
powerUp: {
speed: 0,
shot: 1,
energy: 0,
},
},
{
type: PowerUp.shotPower,
assetUrl: 'assets/game/powerups/bolt/bolt.json',
animationName: 'bolt',
powerUp: {
speed: 0.1,
shot: 0,
energy: 0,
},
},
{
type: PowerUp.shotPower,
assetUrl: 'assets/game/powerups/pill/pill.json',
animationName: 'pill',
powerUp: {
speed: 0.1,
shot: 0,
energy: 1,
},
},
],
};
10 changes: 0 additions & 10 deletions src/app/models/collectable.model.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/app/models/game.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface Game {
date: string;
kills: number;
level: number;
}
8 changes: 0 additions & 8 deletions src/app/models/located-object.model.ts

This file was deleted.

5 changes: 2 additions & 3 deletions src/app/models/pixijs/app-screen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container } from 'pixi.js';
import { PixiGameService } from '../../services/pixi-game.service';
import { GameService } from '../../services/game.service';

export interface AppScreen extends Container {
show?(): Promise<void>;
Expand All @@ -24,8 +24,7 @@ export interface AppScreen extends Container {
}

export interface AppScreenConstructor {
new(service: PixiGameService): AppScreen;
new(service: GameService): AppScreen;

/** List of assets bundles required by the screen */
assetBundles?: string[];
}
10 changes: 6 additions & 4 deletions src/app/models/pixijs/power-up-sprite.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { FrameObject, Texture } from 'pixi.js';
import { PowerUpConfig } from '../power-up-config.model';
import { GameSprite } from './game-sprite';

export enum PowerUp {
speed,
shot,
shotSpeed,
shotPower,
}

export class PowerUpSprite extends GameSprite {
readonly type: PowerUp = PowerUp.speed;
readonly config: PowerUpConfig;

constructor(speed: number, textures: Texture[] | FrameObject[], type: PowerUp) {
constructor(speed: number, textures: Texture[] | FrameObject[], config: PowerUpConfig) {
super(speed, textures);

this.type = type;
this.config = config;
}
}
10 changes: 10 additions & 0 deletions src/app/models/pixijs/ship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@ import { GameSprite } from './game-sprite';
export class Ship extends GameSprite {
shotPower = 1;
shotSpeed = 1;

#energy = 10;

set energy(value: number) {
this.#energy = Math.min(value, 10);
};

get energy(): number {
return this.#energy;
}
}
12 changes: 12 additions & 0 deletions src/app/models/power-up-config.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PowerUp } from './pixijs/power-up-sprite';

export interface PowerUpConfig {
type: PowerUp;
assetUrl: string;
animationName: string;
powerUp: {
speed: number;
shot: number;
energy: number;
};
}
34 changes: 0 additions & 34 deletions src/app/models/render-object.model.ts

This file was deleted.

54 changes: 0 additions & 54 deletions src/app/models/ship.model.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/app/models/shot-object.model.ts

This file was deleted.

31 changes: 7 additions & 24 deletions src/app/popups/credits-popup.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import { Button } from '@pixi/ui';
import { Sprite, Text } from 'pixi.js';
import { PixiGameService } from '../services/pixi-game.service';
import { GameService } from '../services/game.service';
import { Popup } from './popup';

export class CreditsPopup extends Popup {
constructor(private readonly gameService: PixiGameService) {
constructor(gameService: GameService) {
super('Credits');

this.addText(this.panel, 'Idee & Programmierung', 14, -60);
this.addText(this.panel, 'Thomas Renger', 12, -40);
this.addText(this.panel, 'Grafiken', 14, -10);
this.addText(this.panel, 'Kenney (www.kenney.nl)', 12, 10);
this.addText(this.panel, 'Idee & Programmierung', { size: 14 }, { y: -60 });
this.addText(this.panel, 'Thomas Renger', { size: 12 }, { y: -40 });
this.addText(this.panel, 'Grafiken', { size: 14 }, { y: -10 });
this.addText(this.panel, 'Kenney (www.kenney.nl)', { size: 12 }, { y: 10 });

this.addCloseButton(this.panel);
}

private addCloseButton(panel: Sprite): void {
const creditButton = new Button(Sprite.from('assets/ui/yellow_button00.png'));
creditButton.view.width = 190;
creditButton.view.height = 49;
creditButton.view.y = 55;
creditButton.view.x = -95;
const text = new Text('Schließen', { fontFamily: 'DefaultFont', dropShadowColor: '000000', fontSize: 14 });
text.anchor.set(0.5, 0.5);
text.x = 100;
text.y = 20;
creditButton.view.addChild(text);
creditButton.onPress.connect(() => this.gameService.openNavigation(this));
panel.addChild(creditButton.view);
this.addButton('Schließen!', () => gameService.openNavigation(this), 2, this.panel);
}
}
Loading

0 comments on commit 9779871

Please sign in to comment.