Current collected state Current
Observed since 20 Oct, 19:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
2d-gaming
This is an Angular package fo developing 2d games in angular. [Please Give Feedback Here](https://cwestblue.github.io/deployWeb/forms).
This is an Angular package fo developing 2d games in angular. Please report issues/questions/any ideas to better help this package.
// Create A New File gameArea.ts
import { GameAreaObject } from '2d-gaming';
export class GameArea implements OnInit{
component: GameAreaObject;
constructor() {
this.component = new GameAreaObject('myGame', '300px', '300px');
this.game.gravity = 0;
}
};
// Create A New File game.component.ts
import {GameAreaObject, ObjectComponent, ObjectDesign, PositionObject, ObjectArray } from '2d-gaming';
import {GameArea} from './gameArea.ts':
@Component({
selector: 'app-game',
templateUrl: './game.html'
})
export class GameComponent implements OnInit {
gameObject: GameArea
ngOnInit() {
this.gameObject = new GameArea();
this.gameObject.component.doEveryFrame = (() => this.doPerFrame());
}
start() {
this.gameObject.component.start(); // this starts the game
}
stop() {
this.gameObject.component.stop(); // this stops and resets the game
}
doPerFrame() {
// put code here you want to run everyFrame
}
}
<!--- In game.html Place This-->
<app-game-area></app-game-area>
<button (click)="start()">Start</button>
// Create A New File player.ts
import {GameAreaObject, ObjectComponent, ObjectDesign, PositionObject } from '2d-gaming'
export class Player {
component: ObjectComponent;
position: PositionObject;
design: ObjectDesign;
constructor(public game: GameAreaObject) {
this.design = new ObjectDesign(20, 20, 'square', 'green'); // create a design. we will add this to our player
this.position = new PositionObject(150, 150); // create a position object. we will add this to our player
this.component = new ObjectComponent(this.game, this.design, this.position) // add the design and position to the player.
// we inject a gameObject into the constructor so the player can know what game it belongs to
}
}
// back in game.component.ts
gameObject: GameArea;
playerObject: Player; //Import Player from the previous file
ngOnInit() {
this.gameObject = new GameArea();
this.playerObject = new Player(this.gameObject.component); // Create a new Instance of it and inject the component of the gameObject in its constructor
}
// Im using HostListener. You can use another event detection if you pefer
@HostListener('document:keyup', ['$event'])
onKeyup(e: KeyboardEvent) {
const code = e.keyCode;
this.playerObject.component.clearMovement();
}
@HostListener('document:keydown', ['$event'])
onkeydown(e: KeyboardEvent) {
const code = e.keyCode;
// D Key
if (code === 68) {
this.playerObject.component.moveRight(1.5); // move right
}
// A Key
if (code === 65) {
this.playerObject.component.moveLeft(1.5); //move left
}
// W Key
if (code === 87) {
this.playerObject.moveUp(1.5); // move up
}
// S Key
if (code === 83) {
this.playerObject.component.moveDown(1.5); // move down
}
}
// Create a new file item.ts
import {GameAreaObject, ObjectComponent, ObjectDesign, PositionObject, IPath } from '2d-gaming'
export class item {
component: ObjectComponent;
position: PositionObject;
design: ObjectDesign;
constructor(public game: GameAreaObject) {
this.design = new ObjectDesign(20, 20, 'square', 'red'); // create a design. we will add this to our object
this.position = new PositionObject(100, 100); // create a position object. we will add this to our object
this.component = new ObjectComponent(this.game, this.design, this.position) // add the design and position to the object.
// we inject a gameObject into the constructor so the object can know what game it belongs to
this.component.newPath = {
x: 200, // New X Pos
y: 200, // New Y Pos
speed: 1, // Speed It Moves At
infinit: false // If it stops at designated location or continue after
}
}
}
gameObject: GameArea;
playerObject: Player; //Import Player from the previous file
movingObject: item; //Import item from the previous file
ngOnInit() {
this.gameObject = new GameArea();
this.playerObject = new Player(this.gameObject.component); // Create a new Instance of it and inject the component of the gameObject in its constructor
this.movingObject = new item(this.gameObject.component)
}
Initialize each object like this
var Init = new Object();
| Call | Description | Paramaters |
|---|---|---|
| draw() | draws the object on the canvas | none |
| shoot() | shoots the bullets | none |
| name | Description |
|---|---|
| game | the gameArea it belongs to |
| design | a designObject |
| position | a PositionObject |
| movement | a Movement Object |
| bullets | items your wanting to shoot |
| score | how points stored in this object |
| isBarrier | if object is a barrier |
| Name | Description |
|---|---|
| shape | is type image, square, circle, text |
| width | width of the connected object |
| height | height of the connected Object |
| color | is a color unless shape is image then is an image url |
| text | the text of an text shape |
| Name | Description |
|---|---|
| xPos | x position |
| yPos | y position |
| Name | Description |
|---|---|
| speedY | the speed of the object on the y axis |
| speedX | speed of object on x axis |
| gravity | gravity of object |
| position | a PositionObject |
| Name | Description | paramater |
|---|---|---|
| moveright() | moves object right | speed: number |
| moveLeft() | moves object left | speed: number |
| moveUp() | moves object up | speed: number |
| moveDown() | moves object down | speed: number |
| newPos | moves object to new location | xPos: number, yPos: number, speed: number, infinit: boolean |
| call | Description | Paramaters |
|---|---|---|
| .start() | starts the game | none |
| stop() | stops the game | none |
| .clear() | clears the game area | none |
| .doEveryFrame() | runs every frame | function |
| .everyinterval() | returns true or false. Do somthing every interval | number for when you want the interval to be set at |
| name | Description |
|---|---|
| frame | the current frame your on |
| area | The element container of the game |
| gravity | the gravity of the game |
| crashHandler | handles collides in game |
| height | height of the game |
| width | width of the game |
| gameObjects | all objects in game |
| name | name of the game |
| call | Description | Paramaters |
|---|---|---|
| add() | Adds an Object | item: ObjectComponent |
| addMulti() | Adds array of objects | items: ObjectComponent[] |
| multiply() | adds multiple instances of one object | item: ObjectComponent, howMany: number |
| removeFromGame() | removes its items from the game | none |
| name | Description |
|---|---|
| items | array of objectcomponents |
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@angular/commonEnvironment{
"local_name": "@angular/common",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/compilerEnvironment{
"local_name": "@angular/compiler",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/coreEnvironment{
"local_name": "@angular/core",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/formsEnvironment{
"local_name": "@angular/forms",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/httpEnvironment{
"local_name": "@angular/http",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/platform-browserEnvironment{
"local_name": "@angular/platform-browser",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/platform-browser-dynamicEnvironment{
"local_name": "@angular/platform-browser-dynamic",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@angular/routerEnvironment{
"local_name": "@angular/router",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
core-jsEnvironment{
"local_name": "core-js",
"alias": false,
"peer_metadata": null
} | ^2.4.1 | runtime |
rxjsEnvironment{
"local_name": "rxjs",
"alias": false,
"peer_metadata": null
} | ^5.1.0 | runtime |
zone.jsEnvironment{
"local_name": "zone.js",
"alias": false,
"peer_metadata": null
} | ^0.8.4 | runtime |
@angular/cliEnvironment{
"local_name": "@angular/cli",
"alias": false,
"peer_metadata": null
} | 1.0.0 | development |
@angular/compiler-cliEnvironment{
"local_name": "@angular/compiler-cli",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | development |
@types/jasmineEnvironment{
"local_name": "@types/jasmine",
"alias": false,
"peer_metadata": null
} | 2.5.38 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ~6.0.60 | development |
codelyzerEnvironment{
"local_name": "codelyzer",
"alias": false,
"peer_metadata": null
} | ~2.0.0 | development |
jasmine-coreEnvironment{
"local_name": "jasmine-core",
"alias": false,
"peer_metadata": null
} | ~2.5.2 | development |
jasmine-spec-reporterEnvironment{
"local_name": "jasmine-spec-reporter",
"alias": false,
"peer_metadata": null
} | ~3.2.0 | development |
karmaEnvironment{
"local_name": "karma",
"alias": false,
"peer_metadata": null
} | ~1.4.1 | development |
karma-chrome-launcherEnvironment{
"local_name": "karma-chrome-launcher",
"alias": false,
"peer_metadata": null
} | ~2.0.0 | development |
karma-cliEnvironment{
"local_name": "karma-cli",
"alias": false,
"peer_metadata": null
} | ~1.0.1 | development |
karma-jasmineEnvironment{
"local_name": "karma-jasmine",
"alias": false,
"peer_metadata": null
} | ~1.1.0 | development |
karma-jasmine-html-reporterEnvironment{
"local_name": "karma-jasmine-html-reporter",
"alias": false,
"peer_metadata": null
} | ^0.2.2 | development |
karma-coverage-istanbul-reporterEnvironment{
"local_name": "karma-coverage-istanbul-reporter",
"alias": false,
"peer_metadata": null
} | ^0.2.0 | development |
protractorEnvironment{
"local_name": "protractor",
"alias": false,
"peer_metadata": null
} | ~5.1.0 | development |
ts-nodeEnvironment{
"local_name": "ts-node",
"alias": false,
"peer_metadata": null
} | ~2.0.0 | development |
tslintEnvironment{
"local_name": "tslint",
"alias": false,
"peer_metadata": null
} | ~4.5.0 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ~2.2.0 | development |
Source distribution
{
"shasum": "b6351ba388faa07ece5e0c558e85f292a085cc5c",
"tarball": "https://registry.npmjs.org/2d-gaming/-/2d-gaming-1.2.1.tgz",
"integrity": "sha512-tdnZDMBJoRtS9osbe9xrAjFAwJUWoBtZ5DJea2M6/bA4YymRvvhsAfdAYVzr9f6LLrK0e5x7FoMynNJwA5y46w==",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEQCIH6mvMyfDPjGxLAQ+OOiU4Zneu6mcUeDBOsT5/Mj7MNXAiBugGHHeI5atY/LH5mb6o8Lov3AQgn7fe0/a1uYOCtteQ=="
}
]
}Observed since 20 Oct, 19:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:af6dfc8688be06ac0fb3ee4bbfbbdb84be1fb1a5f9bb9d368e36dc53426e28b7