Skip to content

Commit

Permalink
permanently sticking with joystick (#165)
Browse files Browse the repository at this point in the history
* npm audit fix

* fixed joystick overflow over board grid

* formally remove hammerjs
  • Loading branch information
kubikowski committed Jul 9, 2021
1 parent 44551fd commit 0994394
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 52 deletions.
23 changes: 6 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@angular/platform-browser": "~12.1.1",
"@angular/platform-browser-dynamic": "~12.1.1",
"@angular/router": "~12.1.1",
"hammerjs": "^2.0.8",
"nipplejs": "^0.9.0",
"rxjs": "~6.6.7",
"subsink": "^1.0.2",
Expand All @@ -35,7 +34,6 @@
"@angular-devkit/build-angular": "~12.1.1",
"@angular/cli": "~12.1.1",
"@angular/compiler-cli": "~12.1.1",
"@types/hammerjs": "^2.0.40",
"@types/jasmine": "~3.8.1",
"@types/jasminewd2": "~2.0.10",
"@types/node": "^16.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<joystick (move)="handleJoystick($event)"
[style.width]="(snekWidth$ | async) * 20 + 'px'"
[style.height]="(snekHeight$ | async) * 20 + 'px'">
</joystick>

<ng-container *ngIf="snekGame$ | async as snekGame">

<div class="snek-grid-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
width: max-content;
border: solid 2px var(--border-color);
border-radius: 5px;
user-select: none;
overflow: hidden;

> .snek-grid-row {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { JoystickOutputData } from 'nipplejs';
import { Observable } from 'rxjs';
import { SnekGame } from 'src/app/pages/not-found/snek/models/state/snek-game.model';
import { SnekResolutionService } from 'src/app/pages/not-found/snek/services/core/snek-resolution.service';
import { SnekStateService } from 'src/app/pages/not-found/snek/services/core/snek-state.service';
import { SnekUserInputService } from 'src/app/pages/not-found/snek/services/core/snek-user-input.service';

@Component({
selector: 'snek-grid',
Expand All @@ -11,10 +14,20 @@ import { SnekStateService } from 'src/app/pages/not-found/snek/services/core/sne
})
export class SnekGridComponent {
public readonly snekGame$: Observable<SnekGame>;
public readonly snekWidth$: Observable<number>;
public readonly snekHeight$: Observable<number>;

constructor(
private readonly snekResolutionService: SnekResolutionService,
private readonly snekStateService: SnekStateService,
private readonly snekUserInputService: SnekUserInputService,
) {
this.snekGame$ = this.snekStateService.snekGame$;
this.snekWidth$ = this.snekResolutionService.snekWidth$;
this.snekHeight$ = this.snekResolutionService.snekHeight$;
}

public handleJoystick(event: JoystickOutputData): void {
this.snekUserInputService.handleJoystick(event);
}
}
5 changes: 0 additions & 5 deletions src/app/pages/not-found/snek/snek.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { JoystickOutputData } from 'nipplejs';
import { SnekDialogService } from 'src/app/pages/not-found/snek/services/core/snek-dialog.service';
import { SnekResolutionService } from 'src/app/pages/not-found/snek/services/core/snek-resolution.service';
import { SnekStateService } from 'src/app/pages/not-found/snek/services/core/snek-state.service';
Expand All @@ -10,7 +9,6 @@ import { SnekStatisticsService } from 'src/app/pages/not-found/snek/services/per
@Component({
selector: 'snek',
template: `
<joystick (move)="handleJoystick($event)"></joystick>
<snek-grid></snek-grid>
<snek-options></snek-options>
`,
Expand Down Expand Up @@ -40,7 +38,4 @@ export class SnekComponent {
private readonly snekStatisticsService: SnekStatisticsService,
) { }

public handleJoystick(event: JoystickOutputData): void {
this.snekUserInputService.handleJoystick(event);
}
}
12 changes: 0 additions & 12 deletions src/app/shared/hammer/hammer-config.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/shared/hammer/shared-hammer.module.ts

This file was deleted.

Empty file.
1 change: 1 addition & 0 deletions src/app/shared/joystick/joystick.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:host {
position: absolute;
cursor: pointer;
width: 100%;
height: 100%;
z-index: 3;
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/joystick/joystick.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { create, JoystickManager, JoystickManagerOptions, JoystickOutputData } f

@Component({
selector: 'joystick',
templateUrl: './joystick.component.html',
template: '',
styleUrls: [ './joystick.component.scss' ],
})
export class JoystickComponent implements AfterViewInit, OnDestroy {
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import 'hammerjs';
import { AppModule } from 'src/app/app.module';
import { environment } from 'src/environments/environment';

Expand Down

0 comments on commit 0994394

Please sign in to comment.