Code Monkey home page Code Monkey logo

bbggez's Introduction

Brooks Builds Community GGEZ Crate

This project is by and for all of us Brooks Builds community members who are using GGEZ to learn how to program in Rust, and of course make some games. Brooks will be reviewing pull requests and issues regularly on his stream.

The origin story for this library is Hacktoberfest. It can be daunting to begin contibuting to open source software, especially if we are new to a language or framework. This project is meant to be a jumping off point for beginners and veterans to Rust and GGEZ alike get some pull requests in and get their t-shirt!

Are there GGEZ utility crates already? Of course there are. But this one is special as its by and for this community. We may be re-implementing some of the features that the other GGEZ libraries have but this is primarily a learning experience project.

Code of Conduct

We are using the Brooks Builds code of conduct.

Contributing

There are many ways to contibute to this project. The easiest way is to submit and message on issues. We can't promise that we will implement every request that we get, but we can discuss why we want to go in a certain direction.

If you want to get involved and write some code then follow these steps to contribute.

It doesn't matter what level of developer you or how much Rust you know. If you want to pair with a community member please mention this in the comments and I can pair with you.

  1. Find an issue that isn't currently being worked on that sounds interesting (there will be a comment stating that the developer is working on the issue if it is being worked on)
  2. Write a comment stating that you're going to work on the issue
  3. Feel free to ask any clarifying questions about the issue. It is possible that some issues won't have pull requests accepted as they don't match the direction that we want to go with the project.
  4. Fork the repository
  5. Clone the repository to your local environment
  6. Make sure you have Rust installed
  7. Run the tests with the command cargo test to make sure that everything is working as expected
  8. Make your changes locally
  9. Add tests for any code you write
  10. Add documentation for any code you write
  11. Run the tests again to make sure that the tests are still working
  12. If you added or changed a feature add or change the appropriate example
  13. Push your code to your GitHub account
  14. Pull request your changes

If you are adding a pull request for Hacktoberfest, note that your pull request doesn't need to be accepted to get counted. Get that t-shirt!

We are more than happy to have documentation pull-requests, they are a great way to get started with open source.

Using the Library

You can run an example to show how to use the library with the command `cargo run --example

bbggez's People

Contributors

andcotoli avatar baileyn avatar brookspatton avatar dannyfritz avatar ovalnine avatar plwai avatar twe4ked avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bbggez's Issues

Do we want to wrap around ggez

I'm not sure we do for this library, maybe another project?

Also what would that look like in code. Let's create a discussion here.

Create a Mesh Struct

Functions that create meshes are starting to get messy.

We could create a mesh structure to store them in the same place.

Timer function

Sometimes we want things to happen every n seconds. This could be useful for adding food on a regular schedule, or anything else in real time.

I'm thinking of something similar to what @dannyfritz is doing here

Create wrapper for running the game in the main.rs file

Currently our main.rs file looks like:

use fluid::*;
use ggez::{ContextBuilder, event};
use ggez::conf::Conf;

fn main() {
    let mut conf = Conf::new();
    conf.window_mode = conf.window_mode
        .dimensions(1860.0/2.0, 1015.0)
        .resizable(true);
    conf.window_setup = conf.window_setup.title("Fluid Resistance");
    let (mut context, mut event_loop) = ContextBuilder::new("Fluid Resistance", "Brookzerker")
        .conf(conf)
        .build()
        .expect("Game context was not able to be created");
    let mut game = Game::new(&mut context);

    match event::run(&mut context, &mut event_loop, &mut game) {
        Ok(_) => println!("Exited cleanly"),
        Err(error) => println!("Error occured: {}", error),
    };
}

I think we can simplify this by creating a wrapper where we pass in what we need, and the library will take care of creating and running the game.

It could look something like

use fluid::*;

fn main() {
    match bbggez::run(Game, "Fluid Resistance", "Brookzerker") {
        Ok(_) => println!("Exited cleanly"),
        Err(error) => println!("Error occured: {}", error),
    };
}

What do we think about this?

Add random dark colors

We have random light colors for use on dark backgrounds. It would also be nice to have random dark colors for use on bright backgrounds

Random location in arena

It would be nice to have a function that takes in the arena size and returns a random location inside the arena.

New File Structure

To avoid merge conflicts, and make the code more organized, I've made up this file structure.

src folder

multiple_part_module/
  - module_part_1.rs
  - module_part_2.rs
tests/
  - module_1_test.rs
  - module_2_test.rs
  - ...
module_1.rs
module_2.rs
module_3.rs
main.rs

main.rs

extern crate random //Crates that won't get exported

pub extern crate ggez //Expose ggez so users can do custom things

pub mod module_1
pub mod module_2
pub mod module_3
mod private_module

Mesh for triangle

The ecosystem project creates a triangle, that would be nice to have in the library.

The triangle should be equilateral in size.

re-export ggez from the library

We can re-export GGEZ as we are already using it in the library. That we if we don't need to worry about bringing in the wrong version when making a game, and we don't need to add anything else into the crates.toml file.

Create mesh wrapper for circles

We want to easily create circles when writing GGEZ programs like

self.utility.create_circle(x, y, radius, color)

And then we would get a mesh back of the color

Tests fail sometimes.

I just ran the tests and received a failure. There's not a genuine issue because running the tests again were successful, but I think this should still be addressed.

Nicholass-MacBook-Pro:bbggez nbailey$ cargo test
   Compiling bbggez v0.5.0 (/Users/nbailey/git/bbggez)
    Finished dev [unoptimized + debuginfo] target(s) in 4.89s
     Running target/debug/deps/bbggez-02d635cba9813948

running 3 tests
test tests::generates_random_location ... ok
test tests::creates_a_random_color ... ok
test tests::creates_a_random_dark_color ... FAILED

failures:

---- tests::creates_a_random_dark_color stdout ----
thread 'tests::creates_a_random_dark_color' panicked at 'assertion failed: color.r + color.g + color.b !=
    another_color.r + another_color.g + another_color.b', src/lib.rs:163:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.


failures:
    tests::creates_a_random_dark_color

test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

Currently the tests creates_a_random_color, creates_a_random_dark_color, and generates_random_location can potentially fail at random due to the random nature of functions being defined.

Currently, creates_a_random_color and creates_a_random_dark_color have tests that create one random color after another and vaguely assert that they're not equal. Due to the random nature of the functions it's possible, but not probable, that they'll be the same.

assert!(color.r + color.g + color.b != another_color.r + another_color.g + another_color.b);

Making this strictly check if ther, g, and b values are the same would definitely increase the entropy, but I think it could still fail because there are no guarantees that the exact same color won't be generated twice in a row.

The generates_random_location follows suit by testing two generated locations

assert_ne!(first, second);

Mesh for asteroid

For the food in the ecosystem project that goes bad we are creating a strange kind of circle thing. This ends up looking like an asteroid or corrupted circle.

A mesh generator for this would be great.

Create an entity structure

We often use very similar structures each challenge. For example the Ball struct. We can probably create a entity structure that will allow us to skip manually creating this type of structure over and over again.

An example ball struct: fluid resistance Ball

What we would want on it

  • base structure
  • location
  • velocity
  • acceleration
  • mass
  • mesh

Functions

  • new
  • move
  • apply force
  • get speed

Add a logo for the project

We need to create a logo for the project so that we look good. Lets start a conversation on what one would look like

get delta time

It would be nice to get the difference between the previous frame and the current frame. This is known as the delta time.

This number can be used to make the animations smooth and not dependent on hardware speed.

export rand

We use the rand crate a lot in our games. Let's export it the same way we did #12 so we don't need to add it to every cargo.toml file we create.

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.