Giter Club home page Giter Club logo

glove's Introduction

Glove

Glove is a framework for making games. It is implemented in Crystal.

Caution! Glove is experimental. Expect many breaking changes. There are no tests. Do not use this for your own projects.

Example code

Here is a trivial example that renders a card (from assets/card.png):

require "glove"

card =
  Glove::Entity.new.tap do |e|
    e << Glove::Components::Texture.new("assets/card.png")
    e << Glove::Components::Transform.new.tap do |t|
      t.width = 140_f32
      t.height = 190_f32
      t.translate_x = 400_f32
      t.translate_y = 300_f32
    end
  end

scene =
  Glove::Scene.new.tap do |scene|
    scene.spaces << Glove::Space.new.tap do |space|
      space.entities << card
    end
  end

game = Glove::EntityApp.new(800, 600, "Inari")
game.clear_color = Glove::Color::WHITE
game.replace_scene(scene)
game.run

Architecture

  • Glove::EntityApp is a generic game superclass that provides functionality for handling entities, and everything associated with it. Here is how a typical game would build an instance and run the game:

    game = Glove::EntityApp.new(800, 600, "Inari")
    game.clear_color = Glove::Color::WHITE
    scene = Glove::Scene.new.tap do |scene|
      # … build scene here …
    end
    game.replace_scene(scene)
    game.run
  • Glove::Entity is a game object that is visible and/or reacts to user input.

  • Glove::Component is a property of an entity. A common component is Glove::Components::Transform, which adds width, height, rotation, scale, … to an entity. Another common component is Glove::Components::Camera, which marks an entity as being a camera, and defines which part of a space (see below) will be rendered, with what rotation, etc.

  • Glove::Action defines a change to an entity. It can either be instant (e.g. remove entity) or act over time (e.g. move).

  • Glove::Space groups entities in a scene that logically belong together and can interact with each other. Entities in different spaces never interact. For example, one space might contain the game entities, and another space might contain UI elements.

  • Glove::Scene describes a scene (such as the main menu, credits, or in-game screen). It contains one or more spaces.

  • Glove::System describes logic for making changes to a space. A common system is a physics system, which would calculate velocities and update positions.

There are also a handful of simple data classes:

  • Glove::Color
  • Glove::Point
  • Glove::Quad
  • Glove::Rect
  • Glove::Size
  • Glove::Vector

Acknowledgements

This project started out by playing with crystal-gl by Gustavo Giráldez.

glove's People

Contributors

denisdefreyne avatar

Watchers

 avatar

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.