Giter Site home page Giter Site logo

charlie-rbchd / tcod-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomassedovic/tcod-rs

0.0 0.0 0.0 20.59 MB

Rust bindings for libtcod 1.6.3 (the Doryen library/roguelike toolkit)

License: Do What The F*ck You Want To Public License

Makefile 0.01% C 76.05% C++ 15.58% Objective-C 0.62% Rust 7.75%

tcod-rs's Introduction

libtcod bindings for Rust Build Status

libtcod a.k.a. "The Doryen Library" is a smallish library designed for writing roguelikes. It provides a bunch of useful functionality such as:

  • Text-based graphics API that doesn't suck as much as Curses or OpenGL
  • Colours! (like, more than 16)
  • Keyboard and mouse input
  • Path finding
  • Field of view
  • Portable (works on linux, windows and mac)
  • Lots of other stuff

This project provides Rust bindings for libtcod v1.6.3.

This project follows Semantic Versioning. Since we're under 1.0.0 anything goes. The API can change at any time.

Indeed, it probably should change! If you have better ideas on how it make it safer or more familiar to Rust developers, please let us know.

Documentation

We run rustdoc on every new commit:

http://tomassedovic.github.io/tcod-rs/tcod/index.html

But that's mostly useful for types, function signatures, etc. We don't have much in term of actual docs, but you can always check the official ones:

https://libtcod.readthedocs.io/en/stable/

Current status

All raw tcod bindings are available via the tcod-sys crate. In addition we want to provide safe (and more in line with the Rust style) wrappers -- if you can segfault outside of unsafe blocks, that's a bug. The safe bindings are not yet complete, however.

Already Implemented

  • Colors
  • Console
  • Most of the System layer (FPS, time, fullscreen, screenshots)
  • Field of view
  • Map
  • Path finding (both A* and Dijkstra)
  • Pseudorandom number generator (prefer the rand crate, except for places where the API requires the built-in generators)
  • Name generator
  • Image toolkit
  • Line toolkit
  • Noise
  • BSP toolkit

Probably Won't Ever Be Implemented Because Rust Provides This Already

  • Filesystem utilities
  • Containers
  • Compression toolkit (there will probably be a better Rust library for this)

Not Implemented Yet But Should Happen At Some Point In The Future

  • Everything else!

How to use this

tcod-rs depends on libtcod so you need to build or download the official version. The libtcod version known to work is bundled with tcod-sys and Cargo will build it for you, but you need the build dependencies installed.

Alternatively, you can provide the precompiled libtcod library to override the building process. See below.

To use tcod-rs, add this to your game's Cargo.toml:

[dependencies]
tcod = "0.15"

Building on Linux

Run the equivalent of:

$ sudo apt-get install gcc g++ make libsdl2-dev
$ cd yourgame
$ cargo build --release
$ cargo run --release

on your distro.

Building a dynamic library

By default, tcod-rs will build the library statically on Linux as including the code into the executable is usually more convenient. To build a dynamic library specify the dynlib feature for tcod-sys in Cargo.toml

[dependencies.tcod-sys]
version = "*"
features = ["dynlib"]

Building on Windows (with MSVC)

Make sure you have Visual Studio 2013 or later with the C++ tools option installed. You also need the "MSVC ABI" version of the Rust compiler (as opposed to the "GNU ABI" one).

Then, set up the compilation environment, make sure Rust is in your PATH and run Cargo:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat amd64
set PATH=%PATH%;C:\Program Files (x86)\Rust\bin
cd yourgame
cargo build --release
cargo run --release

Building on Windows (with MinGW)

You have to download and install MinGW. Then, add Rust's and MinGW's bin directories to your path and compile your game:

set PATH=%PATH%;C:\Program Files (x86)\Rust\bin;C:\MinGW\bin
cd yourgame
cargo build --release
cargo run --release

Building on Mac OS X

  1. Install Homebrew
  2. Run:
$ brew install pkg-config sdl2
$ cd yourgame
$ cargo build --release
$ cargo run --release

This is based on the instructions from Jared McFarland's roguelike tutorial.


To test this, you can clone this repository directly and run the one of the provided examples:

$ git clone https://github.com/tomassedovic/tcod-rs.git
$ cd tcod-rs
$ cargo run --example keyboard

Using existing binary distribution

If you don't want to build libtcod yourself, you can instruct Cargo to override the build script. See .cargo/config from the repository for an example.

NOTE: The official MinGW pre-built libraries (for Windows) don't seem to work with tcod-rs. We're not sure exactly why this is so we'd appreciate anyone's help!

Contributing

The raw bindings were generated using rust-bindgen and are located at src/ffi.rs. The safe (hopefully?) wrapper was built on top of them at src/lib.rs.

This is far from done, patches to missing functionality wrappers, documentation and examples are very much appreciated. If your patch (any patch -- including typos) gets accepted, you'll get a commit access if you want it.

We accept GitHub as well as regular pull requests (i.e. emailing or tweeting the URL of your feature branch works).

You can regenerate the raw bindings by running:

bindgen -builtins -l tcod include/libtcod.h -o src/ffi.rs

Contributors

License

tcod-rs is licensed under WTFPL v2. See COPYING.txt for the full text of the license (don't worry -- it's really short and to the point).

tcod-rs's People

Contributors

tomassedovic avatar tomob avatar zsparal avatar jgilchrist avatar l3nn0x avatar bastienleonard avatar ggalizzi avatar ilyvion avatar lucanlepus avatar dkaste avatar tyruiop avatar laanwj avatar arcnor avatar indiv0 avatar pranz avatar moredread avatar muhuk avatar huhlig avatar jaredonline avatar mbgg avatar electriccoffee avatar pmsanford avatar abesto avatar kesinger avatar nsmryan 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.