GithubHelp home page GithubHelp logo

201flaviosilva / impacto Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 6.74 MB

A modular javascript canvas render

Home Page: https://201flaviosilva.github.io/Impacto/

License: MIT License

JavaScript 99.76% HTML 0.24%
javascript game-engine impacto canvas rendering-engine

impacto's Introduction

Impacto

Table of Contents

Description

Impacto is a simple render engine for HTML5 canvas. If you have any questions please ask in Discussions (Forum)

Get Started

To get started, you need to install Impacto by NPM Package:

npm install impacto

Use the lib in your project:

import Impacto from "impacto"; // Import the Impacto lib

// Create a simple scene 
class MyScene extends Impacto.Scene {
	start() {
		const myRect = new Impacto.GameObjects.Rectangle(400, 300, 50, 50, "#ff0000"); // Create a red rectangle at position (400x, 300y) with size (50x, 50y)
		this.addChild(myRect); // Add the rectangle to the scene
	}

	update() {
		this.rect2.setAngle(this.rect2.angle + 1); // Rotate the rectangle
	}
}

const game = new Impacto.Game({
	width: 800, // Width of the canvas
	height: 600, // Height of the canvas
	backgroundColor: "#f0f0f0", // Background color of the canvas
	scene: MyScene, // The scene to be rendered
});

For more information about the Impacto API, please check the Doc or check the examples.

impacto's People

Contributors

201flaviosilva avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar

impacto's Issues

[Engine]: Document Code (JSDocs)

JSDocs

  • Impacto.js
  • Game.js
  • Core
    • CoreGameManager.js
  • GameObjects
    • GameObject2D.js
    • Types.js
    • GameObjects.js
    • AudioPlay
      • AudioPlay.js
    • Circle
      • Circle.js
    • Line
      • Line.js
    • Polygon
      • Polygon.js
    • Rectangle
      • Rectangle.js
    • Sprite
      • Animation.js
      • Animations.js
      • Sprite.js
    • Text
      • Options.js
      • Text.js
    • Triangle.js
      • Triangle.js
  • Inputs
    • Inputs.js
    • Keyboard.js
    • Keys.js
    • Mouse.js
  • Scenes
    • Scene.js
  • State
    • AssetsManager.js
    • CanvasState.js
    • GlobalStateManager.js
    • State.js
  • Utils
    • Math.js
    • Utils.js

[Bug]:

Engine Version
0.9.0

Describe the bug
If you CD into docs and run npm start the beautiful Docusaurus site displays on localhost 3000. However, if you run npm run build and npm run serve, a plain looking JSDoc site gets served instead. Somehow the Docusaurus site does not get served outside of your local environment.

To Reproduce
Steps to reproduce the behavior:

  1. CD into docs
  2. Run npm run build
  3. Run npm run serve
  4. You will see a plain JSDoc site

Expected behavior
I expect the exact same, beautiful Docusaurus site to get served outside of my local environment.

Screenshots
npm start displays the correct Docusaurus site:
Screen Shot 2022-12-08 at 9 54 40 AM
Screen Shot 2022-12-08 at 9 54 50 AM

npm run build and npm run serve only displays a JSDoc site:
Screen Shot 2022-12-08 at 9 53 03 AM

Desktop (please complete the following information):

  • OS: MacBook Pro M1 chip
  • Browser: Chrome

Additional context
I saw your comments on Docusaurus threads and I've followed many discussions. However, I think both you and I know how unclear some documentation can be for people who are just getting started.

Framework for tests?

Hey there :)

Does anyone have any idea what might be the most suitable tool for testing this project?
I have a little experience in "jasmine", but nothing too relevant.

(If anyone ever sees this and responds, I would be very happy ๐Ÿ˜… )

Polygon Static Game Object

Some help code used originally for triangle:

import GameObject from "../GameObjectBase.js";
import { CanvasInstance } from "../../Utils/Canvas.js";
import Types from "../Types.js";

export default class Triangle extends GameObject {
	constructor(x, y, vertex1, vertex2, vertex3, fillColor = "#ffffff", strokeColor = "#000000") {
		super(x, y, fillColor, strokeColor);
		this.vertex1 = vertex1;
		this.vertex2 = vertex2;
		this.vertex3 = vertex3;

		this._type = Types.triangle
	}

	get x() { return this._x; }
	get y() { return this._y; }

	// Private
	_renderType() {
		CanvasInstance.context.save();
		CanvasInstance.context.translate(this.x, this.y);

		CanvasInstance.context.beginPath();
		CanvasInstance.context.moveTo(this.vertex1.x, this.vertex1.y);
		CanvasInstance.context.lineTo(this.vertex2.x, this.vertex2.y);
		CanvasInstance.context.lineTo(this.vertex3.x, this.vertex3.y);
		CanvasInstance.context.closePath();
		CanvasInstance.context.stroke();
		CanvasInstance.context.fill();

		CanvasInstance.context.restore();
	}
}

[Engine]: Draw objects and Physics objects

Draw Objects:

Simple objects with no physics.
Example:

  • Text;
  • Triangle;
  • Circle;
  • Square;
  • Etc...;

These objects can:

  • Change position;
  • Scale;
  • Rotate;

Physic Objects:

Objects with are affected by collisions, gravity, etc...
For now, just 2 objects supported:

  • Circle;
  • Square;

These objects can:

  • Everything the other objects do, but will only render, the physics (for now) will not scale and rotate, (only position).

Refs:

[Engine]: Center Rectangle (Pivot Point / Anchor / Origin)

Fix the rectangle position to the center and create 2 new proprieties to the game object:

  • realX: Represents the real X position in the canvas of the rectangle;
  • realY: Represents the real Y position in the canvas of the rectangle;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.