2.1.25 • Published 1 year ago

pyramid-game-lib v2.1.25

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Pyramid Game Lib

A simple, easy-to-use library for 3D games and interactive media using the Vite build tool and TypeScript.

Disclaimer

This is semi-actively being developed. Not all the features have been implemented and could change. Do not use this if you are looking for a high-performance game engine.

Why Pyramid Game Lib?

I wanted to build something easy to jump into and deploy while still only writing code (no complex game IDE).

Who should use this?

This library is intended for hobbyist developers who want to play with 3D web technologies to build a game.

What does this do?

The goal is to give you tools to build simple 3D games. It's basically comprised of:

Where can I deploy?

The easiest way to deploy is via Railway with Vite-TypeScript template: https://github.com/NotConspicuous/Vite-Typescript-Railway-Template

Examples

All examples are a work in progress.

Timbotron (Feature demo)

Repository: https://github.com/tcool86/timbotron

Live Demo: https://vite-production-b29b.up.railway.app/

https://user-images.githubusercontent.com/2002449/211242929-f62f7b12-062b-4caa-8fa6-a40dac66eabd.mov

Sample Game (Basic)

Repository: https://github.com/tcool86/didactic-robot

Installation

yarn add 'pyramid-game-lib'

Within the index.html file you will need an element to populate the game (in this example a div with an "app" id: <div id="app"></div>):

<body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
</body>

Within the main.ts file:

import Pyramid from 'pyramid-game-lib';

const app = document.querySelector<HTMLDivElement>('#app')!;

const { Game, Util, Entity } = Pyramid;
const { Box, Sphere } = Entity;
const { Vector3, Vector2 } = Util;

@Box({
    fixed: true,
    color: 0xFFDEAD,
    width: 100,
    height: 0.2,
    depth: 100
})
export class Ground { }

@Sphere({
    color: 0x008080,
    position: new Vector3(3, 2, -3),
    radius: 1
})
export class SpecialBall {
    timer: number = 2;

    setup({ entity }: any) {
        console.log(`Entity: ${entity}`);
    }
    loop({ entity, delta }: any) {
        this.timer += delta;
        if (this.timer > 2) {
            entity.body.applyImpulse(new Vector3(0, 50, 0));
            this.timer = 0;
        }
    }
}

@Game(app)
class SampleGame {
    async setup({ commands }: any) {
        const { create } = await commands;
        create(Ground);
        create(SpecialBall);
    }

    loop({ inputs }: any) {
        const { horizontal, vertical, buttonA, buttonB } = inputs[0];
        if (buttonA) { console.log("A Pressed"); }
        if (buttonB) { console.log("B Pressed"); }
        if (horizontal) { console.log(`Horizontal: ${horizontal}`); }
        if (vertical) { console.log(`Vertical: ${vertical}`); }
    }

    ready() { }
}

new SampleGame();
2.1.18

1 year ago

2.1.19

1 year ago

2.1.25

1 year ago

2.1.24

1 year ago

2.1.21

1 year ago

2.1.22

1 year ago

2.1.20

1 year ago

2.1.16

1 year ago

2.1.17

1 year ago

2.1.14

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

2.1.10

1 year ago

2.1.9

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago