Giter VIP home page Giter VIP logo

cnake's Introduction

Hello, world! ๐Ÿ’ป

veloek's GitHub stats-dark veloek's GitHub stats-light

Top Langs-dark Top Langs-light

cnake's People

Contributors

istarnion avatar veloek avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

istarnion

cnake's Issues

Remove all unicode

They might appear different. We can get by with regular ascii characters.

Update highscore on-the-fly

If game->points > highscore then update highscore right away rather than waiting for game over to do it. I think this makes more sense.

`rand_int` generates numbers in range [min, (min+max))

The rand_int function in game.c generates numbers in range [min, (min+max)), which is not in line with the documenting comment that describes the range as [min, max).
This manifests itself only when min != 0. This happens in create_candy() when finding a free spot.

This test program verifies the bug (unless you are (un)lucky):

#if 0
cc $0
./a.out
rm -f a.out
exit 0
#endif

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

static inline int
rand_bug(int min, int max)
{
    double r = (double)rand() / (double)RAND_MAX;
    return (int)(r * max) + min;
}

// Verify that the input is bugged
static inline int
verify(int n, int min, int max)
{
    return (n < min || n >= max);
}
int
main(int num_args, char *args[])
{
    // Try 10000 times to see if we can get a out of range resultqq
    for(int i=0; i<10000; ++i)
    {
        if(verify(rand_bug(10, 11), 10, 11))
        {
            puts("rand_bug is bugged");
            break;
        }
    }
}

Introduce versioning

The app should have the version printed out in the status bar.
The version should be derived from git tags, i.e. git describe --tags.

Do collision detection

  • Colliding with walls or self should restart game
  • Colliding with candy should remove candy (and bump score)

Persist highscore

Store highscore to make it persistent between runs.

Should listen for updates in case some other instance of the game is using the same highscore store.

Show score

Print score somewhere in the screen, perhaps in some kind of status bar at the bottom with potentially more information like speed, time playes, credits, etc.

Keep a highscore

Highscore should be persisted between runs.

Could also consider writing to file.

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.