ngx-snake
Version:
Snake game as an angular component, its only the core of the game... you need to add everything around it (controls, score...) yourself :)
51 lines (50 loc) • 1.43 kB
TypeScript
import { OnDestroy } from '@angular/core';
import { Subject } from 'rxjs';
import { GameGrid } from '../definitions';
import * as i0 from "@angular/core";
export declare class GameManagerService implements OnDestroy {
private _grid;
private _grid$;
grid$: import("rxjs").Observable<GameGrid>;
private _gameOver$;
gameOver$: Subject<unknown>;
private _foodEaten$;
foodEaten$: Subject<unknown>;
private _gridSize;
private _snake;
private _nextMoveDir;
private _moveDir;
private _food;
private _interval$;
private _paused;
private _playable;
private _signalSub;
signal$: import("rxjs").Observable<number>;
initialize(height: number, width: number): void;
ngOnDestroy(): void;
start(): void;
changeSpeed(period: number): void;
pause(): void;
reset(): void;
up(): void;
right(): void;
down(): void;
left(): void;
private _endGame;
private _buildEmptyGrid;
private _gridChanged;
private _initSnake;
private _spawnFood;
private _drawSnake;
private _gameCycle;
/**
* Checks if field is not currently occupied (is free to take)
* @param newHead
* @private
*/
private _willCrash;
private _willGrow;
private _increaseSpeed;
static ɵfac: i0.ɵɵFactoryDeclaration<GameManagerService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<GameManagerService>;
}