raylibr
所属分类:工具库
开发工具:R
文件大小:0KB
下载次数:0
上传日期:2022-11-30 13:41:02
上 传 者:
sh-1993
说明: R包包装了Raylib,这是一个简单易用的库,可以享受视频游戏编程,
(R package that wraps Raylib, a simple and easy-to-use library to enjoy videogames programming,)
文件列表:
.Rbuildignore (105, 2022-11-30)
DESCRIPTION (630, 2022-11-30)
LICENSE (45, 2022-11-30)
LICENSE.md (1074, 2022-11-30)
NAMESPACE (14735, 2022-11-30)
R/ (0, 2022-11-30)
R/RcppExports.R (73987, 2022-11-30)
R/audio_stream.R (130, 2022-11-30)
R/bone_info.R (124, 2022-11-30)
R/bounding_box.R (2718, 2022-11-30)
R/camera_2d.R (3798, 2022-11-30)
R/camera_3d.R (4661, 2022-11-30)
R/color.R (3235, 2022-11-30)
R/enums.R (3149, 2022-11-30)
R/extra.R (2160, 2022-11-30)
R/font.R (114, 2022-11-30)
R/functions.R (381320, 2022-11-30)
R/glyph_info.R (4203, 2022-11-30)
R/image.R (116, 2022-11-30)
R/is.R (2259, 2022-11-30)
R/material.R (122, 2022-11-30)
R/material_map.R (3125, 2022-11-30)
R/mesh.R (114, 2022-11-30)
R/model.R (116, 2022-11-30)
R/model_animation.R (136, 2022-11-30)
R/music.R (116, 2022-11-30)
R/npatch_info.R (4594, 2022-11-30)
R/ray.R (2505, 2022-11-30)
R/ray_collision.R (3812, 2022-11-30)
R/raylibr-package.R (201, 2022-11-30)
R/rectangle.R (3443, 2022-11-30)
R/render_texture.R (3297, 2022-11-30)
R/shader.R (118, 2022-11-30)
R/sound.R (2588, 2022-11-30)
... ...
# raylibr
This R package wraps [Raylib](https://www.raylib.com/), a simple and
easy-to-use library to enjoy videogames programming.
## Installation
You can install the development version of `raylibr` from
[GitHub](https://github.com/) with:
``` r
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")`.
``` r
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](https://www.raylib.com/examples.html) 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`](https://github.com/jeroenjanssens/raylibr/blob/HEAD/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`](https://github.com/jeroenjanssens/raylibr/blob/HEAD/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`](https://github.com/jeroenjanssens/raylibr/blob/HEAD/demo/model.R)
### Bounce thousands of transparent balls
Run `demo("balls", package = "raylibr")` to play this demo. Source:
[`demo/balls.R`](https://github.com/jeroenjanssens/raylibr/blob/HEAD/demo/balls.R)
### Animate cubes while playing music
Run `demo("cubes", package = "raylibr")` to play this demo. Source:
[`demo/cubes.R`](https://github.com/jeroenjanssens/raylibr/blob/HEAD/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`](https://github.com/jeroenjanssens/raylibr/blob/HEAD/demo/beatbox.R)
## Acknowledgements
- [Ramon Santamaria](https://twitter.com/raysan5) for creating
[Raylib](https://www.raylib.com/), the C library that makes this all
possible.
- [Dirk Eddelbuettel](https://twitter.com/eddelbuettel) and others for
creating the [Rcpp package](https://www.rcpp.org/), which enables
the interface with Raylib.
- [Mike FC](https://twitter.com/coolbutuseless) for showing me how to
[expose C structs as R
objects](https://github.com/coolbutuseless/cstructr).
- [Jared Lander](https://twitter.com/jaredlander) and team for
allowing me to [present about R &
Raylib](https://www.youtube.com/watch?v=Mudz-ykLKbo) at the NYR
Conference 2022.
- [David Robinson](https://twitter.com/drob) for encouraging me to put
`raylibr` on GitHub.
- [`raylibr`’s
contributors](https://github.com/jeroenjanssens/raylibr/graphs/contributors)
for improving `raylibr` by submitting issues and pull requests.
## License
The `raylibr` package is licensed under the MIT License.
近期下载者:
相关文件:
收藏者: