GithubHelp home page GithubHelp logo

malpenzibo / zengine Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 2.0 5.56 MB

A simple 2D ECS game engine built in Rust

License: MIT License

Rust 99.38% WGSL 0.62%
engine game-engine gamedev rust rust-lang zengine

zengine's People

Contributors

malpenzibo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

risooonho foow

zengine's Issues

Engine logger

Create an engine logger with various output types (console, file, etc...)

Docs with overview of ECS architecture with a focus on key feature

Explain ECS architecture.
Principal feature:

  • Entity with child entity support
  • Component with only data
  • System with a key signature array for select relevant entities to work with
  • Intra system communication with the event bus

A system can request entities with 1,N mandatory component and 0,N optional component for each signature supported.

Entity

Create the entity.

An Entity is composed of a unique id in the scene.

Event system

Create a system that can handle the event loop

Audio & Sound

Load some audio resource and play some sound effect

Controllers don't work

Controller instance isn't stored after opening so the connection it's closed at the end of the function

Refactor store

Remove RefCell from the storage system.

A system now will require a context composes of immutable references to Resource and Set (see Read and ReadSet type) and a data tuple composes of value to Resource and Set (this value could be mutable). Every system should then return a tuple with the same structure of data.

Implement Pong

Add a pong implementation stupid as fuck in the example folder with:

  • no menu
  • 3 textures (background, pad, ball)
  • no animation
  • no sound
  • simple AI
  • bottom pad controlled by the user with both keyboard or controller
  • only gameplay scene
  • no score

Dom like scene

Create a basic scene structure.

Proposed solution

A Scene is composed of a name and a root Node. Every Node has a name and can have from 0 to N child Node.

The Engine should have a method to create the initial state from a scene definition specified in a YAML file.

Update README

Update readme with more information about the project and the youtube video series

Proposed solution

There should be 4 main chapter

  • Intro
  • Main Goal
  • Motivation
  • Youtube video series

Asset loader

Create an extensible asset loader.

Initial support for image and text asset

Refactor

clean & reorganize code and modules

Protect master branch

Protect master branch from mergers from branches that have not passed the build and test action

Auto build and test

Setup a github action for build and test commit on master and pull request.

Protect master Branch with some status check

Entity Resource

Write an Entities Resource to handle all entity id generation in one place

Basic GameLoop

Implement a basic game loop with timing to run at a defined FPS.

The game engine should have a method to specify the game FPS.

Component architecture

Create the basic component architecture.

The should be a method to declare component type (what data a component handle) and a way to create a component manager to handle these components.

A Component manager should have a list<Entity> for every C where C is a component type. Each list should be accessible with the component type name.

Entity is a struct with an entity ID (a simple u32 should be fine) and an instance of component data C.

Signature for entities and system

An entity should have a signature that represents what components it possesses.

A system declares what component an entity should possess in order to be elaborated.

example:

fn main() {
    let component1_id = 0;
    let component2_id = 1;
    let component3_id = 2;
    let component4_id = 3;

    let mut entity_signature: u32 = 0;
    
    // add component to entity signature (bit mask)
    // bit rapresentation example
    // 0 0 0 0 -> no component
    // 0 1 0 0 -> component id 2
    // 0 1 0 1 -> component id: 2, 0
    // 1 1 0 1 -> component id: 3, 2, 0
    // 1 1 1 1 -> component id: 3, 2, 1, 0
    
    entity_signature |= 1 << component2_id;
    
    println!("mask: {}", entity_signature);
    
    // remove component to entity signature (bit mask)
    entity_signature &= !(1 << component2_id);
    
    println!("mask: {}", entity_signature);
    
    entity_signature |= 1 << component1_id;
    
    let mut system_signature = 0;
    
    // setup system signature for request component1 (id = 0)
    // same stuff as before for entity signature
    system_signature |= 1 << component1_id;
    
    // check if entity signature meets system signature
    // example
    // entity signature = 0 1 0 1
    // system signature = 0 0 0 1
    // entity sign & system_sign = 0 0 0 1
    // is equal to system_sign 0 0 0 1? -> yess 
    
    
    let is_matching = (entity_signature & system_signature) == system_signature;
    
    println!("signature match: {}", is_matching);
}

System

Create a way to define a list of systems in the game engine.

A system is an element with an id and a function that can exec computation over a list of components of entities that respect a signature profile.

Every system can define a list of signature profiles. Every signature profile should define 1 to N mandatory component and 0 to N optional component.

User Input axis problems with keyboard source

Describe the bug
When user input is defined like this

axis_mappings: 
  X: 
  - source:
      Keyboard:
        key: D
     scale: 1.0
  - source:
      Keyboard:
        key: A
     scale: -1.0

When A Key is down InputHandler.axis_value(UserInput::X) return correctly -1 but when the D key is clicked (down and then up, A key is still down), InputHandler.axis_value(UserInput::X) no longer return -1.

Event Bus

Create an event bus for system to system communication

InputSystem

A system to define user action in a format like

{
  "axis": {
    "move_y": [
       { "source": "W", "scale": 1.0 },
       { "source": "S", "scale": -1.0 },
       { "source": "Controller1.LeftStick.Y", "scale": 1.0 }
    ],
    "move_x": [
       { "source": "D", "scale": 1.0 },
       { "source": "A", "scale": -1.0 },
       { "source": "Controller1.LeftStick.X", "scale": 1.0 }
    ]
  },
  "actions": {
    "jump": [
       { "source": "SPACEBAR", "mod": "(something like shift, ctrl, alt, etc..." },
       { "source": "Controller1.Button.A" }
    ]
  }
}

that can read events and populate the user actions

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.