Giter Club home page Giter Club logo

snake-rs's Introduction

Snake

A Rust implementation of the legendary Snake game, commonly found on old Nokia mobile phones. This project was primarily created to support an associated blog post which aims to help new Rustaceans get to grips with the language.

The game is terminal based and uses Crossterm to take care of cross-platform differences when building the interface and accepting user input.

License

This project is open-source and licensed under the MIT License. See here for more details.

snake-rs's People

Contributors

jrhenderson1988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

noemk2

snake-rs's Issues

u16 cannot be converted to i16

 pub fn transform(&self, direction: Direction, times: u16) -> Self {
    let times = times as i16;
    /*....omitted....*/
}

u16 -> [0, 65535]
i16 -> [-32768, 32767]

For example: If times is 60000_u16, times = times as i16 will get -5536_i16
u16 can be rewritten to i32 (And in another fn: transform_value)

[feature] [question] fast forwarding the snake

Hi! Thanks for the blog post.

I was wandering whether changing in the game.rs

Command::Turn(towards) => {
    if direction != towards && direction.opposite() != towards {
        self.snake.set_direction(towards);
    }
}

to:

Command::Turn(towards) => {
    if direction == towards {
        break;
    } else if direction.opposite() != towards {
        self.snake.set_direction(towards);
    }
}

is the proper way to do add a feature of fast forwarding the snake? Is there any other, maybe more idiomatic way to achieve this that you can think of? ^^

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.