2021-11-25 20:25:28 +01:00
|
|
|
# PixelFaucet Game
|
|
|
|
|
2021-11-29 08:26:51 +01:00
|
|
|
[![GitHub release](https://img.shields.io/github/release/sleepinginsomniac/pixelfaucet.svg)](https://github.com/sleepinginsomniac/pixelfaucet/releases)
|
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
PixelFaucet is a "Game Engine" written in the Crystal programming language and uses SDL2 under the hood to create a window, renderer, and draw pixels.
|
|
|
|
See the [examples](./examples).
|
2021-11-25 20:25:28 +01:00
|
|
|
|
2022-02-27 18:53:20 +01:00
|
|
|
The examples can be built by running the `./scripts/build_examples.rb` script. This will place the binaries in the `examples/build` folder.
|
2021-11-25 20:25:28 +01:00
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
## Setup
|
2021-11-25 20:25:28 +01:00
|
|
|
|
2022-02-27 18:53:20 +01:00
|
|
|
PixelFaucet requires the [crystal](https://crystal-lang.org) compiler which can be installed via [homebrew](https://brew.sh)
|
2021-11-25 20:25:28 +01:00
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
- Install crystal
|
|
|
|
|
|
|
|
```sh
|
|
|
|
brew install crystal
|
|
|
|
```
|
|
|
|
|
|
|
|
- Install sdl2
|
|
|
|
|
|
|
|
```sh
|
|
|
|
brew install sdl2
|
|
|
|
```
|
|
|
|
|
|
|
|
- Create a new project:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
crystal init app my_game
|
|
|
|
```
|
|
|
|
|
|
|
|
- Add the dependency to your `shard.yml`:
|
2021-11-25 20:25:28 +01:00
|
|
|
|
2021-11-29 08:26:51 +01:00
|
|
|
```yaml
|
|
|
|
dependencies:
|
|
|
|
pixelfaucet:
|
|
|
|
github: sleepinginsomniac/pixelfaucet
|
|
|
|
```
|
2021-11-25 20:25:28 +01:00
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
- Run the shards command:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
shards install
|
|
|
|
```
|
2021-11-25 20:25:28 +01:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```crystal
|
|
|
|
require "pixelfaucet/game"
|
|
|
|
|
|
|
|
class Example < PF::Game
|
|
|
|
def update(dt)
|
|
|
|
end
|
|
|
|
|
|
|
|
def draw
|
2022-02-27 18:45:51 +01:00
|
|
|
clear
|
|
|
|
0.upto(width) do |x|
|
|
|
|
0.upto(height) do |y|
|
|
|
|
draw_point(x, y, PF::Pixel.random)
|
|
|
|
end
|
|
|
|
end
|
2021-11-25 20:25:28 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
e = Example.new(100, 60, 5)
|
2021-11-25 20:25:28 +01:00
|
|
|
e.run!
|
|
|
|
```
|
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
## Documentation
|
|
|
|
|
|
|
|
Run `crystal docs` to generate documentation. The documentation can then be found under the `docs` folder.
|
|
|
|
|
2021-11-25 20:25:28 +01:00
|
|
|
## Contributing
|
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
1. Fork it (<https://github.com/sleepinginsomniac/pixelfaucet/fork>)
|
2021-11-25 20:25:28 +01:00
|
|
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
|
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
|
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
|
|
5. Create a new Pull Request
|
|
|
|
|
|
|
|
## Contributors
|
|
|
|
|
2022-02-27 18:45:51 +01:00
|
|
|
- [Alex Clink](https://github.com/sleepinginsomniac) - creator and maintainer
|