Giter Site home page Giter Site logo

rogiersbart / raylibr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeroenjanssens/raylibr

0.0 0.0 0.0 82.58 MB

R package that wraps Raylib, a simple and easy-to-use library to enjoy videogames programming

Home Page: https://jeroenjanssens.github.io/raylibr/

License: Other

C++ 41.01% C 13.85% R 43.92% GLSL 1.22%

raylibr's Introduction

raylibr

This R package wraps Raylib, a simple and easy-to-use library to enjoy videogames programming.

Installation

You can install the development version of raylibr from GitHub with:

remotes::install_github("jeroenjanssens/raylibr")

raylibr is tested regularly on macOS, Linux, and Windows.

Features

Raylib, the C library that the raylibr package wraps, enables you to work with:

  • Real-time 2D and 3D graphics
  • Keyboard and mouse interactivity
  • Music and sound effects
  • Physics simulations and collision detection
  • Animated models and shaders
  • Multitouch, gesture recognition, and even VR headsets

The raylibr package allows you to do all of this from R, and adds the following usability improvements for R users:

  • Function and class names are in snake_case (instead of PascalCase used by Raylib)
  • Use R vectors and matrices (they’re automatically converted to Raylib’s Vector2, Vector3, etc.)
  • Vectorized drawing functions (enjoy buttery-smooth animations by letting C++ do the looping)
  • Use R color names (e.g., use "hotpink" instead of 0xff69b4ff or list(r = 255, g = 105, b = 180))
  • Use only 8 keys to get started (because raylibr is an anagram of library)

Examples

Here’s a “Hello, World!” script to give you an idea of how to use raylibr. You can run this script using demo("helloworld", package = "raylibr").

library(raylibr)

init_window(600, 400, "R & Raylib: Hello, World!")

while (!window_should_close()) {
  alpha <- abs(sin(get_time()))
  begin_drawing()
  clear_background("black")
  draw_circle(300, 200, seq(150, 10, by = -10), c("red", "white"))
  draw_text(c("hello,", "world!"), 225, c(120, 220), 64, fade("black", alpha))
  draw_fps(10, 10)
  end_drawing()
}

close_window()

This script produces the following animation:

While basic, it illustrates how to create a window, how to draw shapes (in a vectorized manner), and how to work with colors. Just imagine what you can do if you add a little keyboard interactivity and some sound effects!

Below are a few more examples to whet your appetite. Run demo(package = "raylibr") to see all available demos in R or visit Raylib’s examples page to see even more examples in C.

Build your own raycaster

Run demo("raycaster", package = "raylibr") to reminisce the 90s and learn how raycasters work. Source: demo/raycaster.R

Play a game of snake

Run demo("snake", package = "raylibr") to play this game. Use the arrow keys to control the snake. Source: demo/snake.R

Load 3D models and apply post-processing shaders

Run demo("model", package = "raylibr") to play this demo. Select a different shader with the left and right arrow keys. Source: demo/model.R

Bounce thousands of transparent balls

Run demo("balls", package = "raylibr") to play this demo. Source: demo/balls.R

Animate cubes while playing music

Run demo("cubes", package = "raylibr") to play this demo. Source: demo/cubes.R

Beatbox like Jeroen

Run demo("beatbox", package = "raylibr") to drop some beats. Press the [a-zA-Z] keys to play the 52 samples recorded by yours truly. Silence the cacophony by pressing Space. Source: demo/beatbox.R

Acknowledgements

License

The raylibr package is licensed under the MIT License.

raylibr's People

Contributors

jeroenjanssens avatar gladius1 avatar ramiromagno 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.