Git Product home page Git Product logo

libpp's Introduction

Polyplex Logo

Polyplex Main Library (libpp)

Buy Clipsey a Coffee at ko-fi.com Join the Discord Server

libpp is an XNA like framework written in D. libpp supports OpenGL and will in the future support Vulkan.

The framework is written to be easy to read and understand for people comming from an C#/XNA background.

libpp is the base rendering, input handling, content handling, etc. library for the WIP Polyplex engine.

Top Tier Patrons

  • The Linux Gamer Community

Using libpp

Find libpp on the dub database for instructions on adding libpp as a dependency to your dub project.

Once added, you will need to set logging levels, choose a backend and create a window.

Current capabilities

Polyplex is still very early in development, but libpp can already be used to make simple 2D games, that are relatively easy to port to other platforms. Polyplex packages textures, sounds, etc. into files with the extension ppc. To convert png, jpeg or tga files to .ppc, use ppcc

Examples

PPCC

ppcc -c (or --convert) my_texture.png output will be put in my_texture.ppc.

libpp

Example of simple polyplex application:

import polyplex;
import polyplex.math;
import polyplex.core.window;
import polyplex.core.input;
import polyplex.core.game;
import polyplex.core.color;
import polyplex.core.render;
import polyplex.core.content;
import std.conv;

void main(string[] args) {
  // Show info logs.
  LogLevel |= LogType.Info;
  
  // Select Open GL as a graphics backend.
  // Changing the property and rerunning InitLibraries will:
  // 1. unload the previous graphics backend library from memory
  // 2. bind the new prefered graphics backend.
  ChosenBackend = GraphicsBackend.OpenGL;
  InitLibraries();
  Game my_game = new Game1();
  my_game.Run();
}

class Game1 : Game {
  Texture2D my_texture;

  // Constructor
  this() {
    WindowInfo inf = new WindowInfo();
    inf.Name = "Game1";
    inf.Bounds = new Rectangle(WindowPosition.Undefined, WindowPosition.Undefined, 1080, 1024);
    super(inf);
  }
  
  //Init is run before the game loop starts.
  public override void Init() {
    my_texture = this.Content.LoadTexture("my_texture");
  }
  
  //Update is run before draw in the game loop.
  public override void Update(GameTimes game_time) {
    // Quit game if Q is pressed.
    if (Input.IsKeyDown(KeyCode.Q)) this.Quit();
    
    //FPS counter as window title.
    Window.Title = "FPS: " ~ to!string(AverageFPS);
  }
  
  //Draw is run after the logic update of the game loop.
  public override void Draw(GameTimes game_time) {
  
    //Clears color, generally put first in the Draw method.
    Drawing.ClearColor(Colors.Black);
    
    sprite_batch.Begin();
    sprite_batch.Draw(my_texture, new Rectangle(0, 0, 32, 32), new Rectangle(0, 0, my_texture.Width, my_texture.Height), Color.White);
    sprite_batch.End();
  }
}

You can also check out example_game, which is used as a testbed for new libpp features/fixes.

Notice

libpp uses a modified version of gl3n made to fit the code-style of libpp. Seen in the polyplex.math package.

Notice, the library is written in what would be considered non-idiomatic D.
A styleguide will be drafted at some point and the code will be cleaned up once it's in a more functional state.

libpp's People

Contributors

lunathefoxgirl avatar klrtk avatar

Stargazers

Raymond Lei(雷菩宇) avatar

Watchers

James Cloos avatar AODQ 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.