Git Product home page Git Product logo

min-snake's Introduction

Snake in form of snake

This is a snake game written in C#.

Code

             while(true){Console
             .Clear();var q=new
          List<int>{9,4};var r=
          new Random();int ax=r
         .Next(31),ay=r.Next(15
          ),dx=0,dy=0,i,s=0;
     void at(int x,int y,string c){
 Console.SetCursorPosition(x,y);Console
.Write(c);}void d(string c){for(i=0;i<q
.Count; i++){at(q[i],q[++i],c);}}Console.
CursorVisible=false;while(true){if(Console
.KeyAvailable){switch((int)Console.ReadKey(
true).Key){case 37:dx=-1;dy=0;break;case 39
:dx=1;dy=0;break;case 38:dx=0;dy=-1;break;
 case 40: dx=0;dy=1;break;}}d(" ");if(q[0
 ]==ax&&q[1]==ay){q.Add(0);q.Add(s++);ax=
 r.Next(31);ay=r.Next(15);}for(i=q.Count
 -1;i>1;i--)q[i]=q[i-2];q[0]=(q[0]+dx)&
 31;q[1]=(q[1]+dy)&15;for(i=2;i<q.Count
        ;i+=2)if(q[i]==q[0]&&q[i+
        1]==q[1])goto go;d("0"
         );at(ax,ay,"@");at(32,
         0,"SCORE: "+s);Thread
        .Sleep(75);}go:d("x");
         at(0,0,"GAME OVER!"+
        "\n(c) TIMA");Console
        .ReadKey(true);}

I tried to copy a form from the Python logo, but...

Thanks to xero for the Python logo text art

min-snake's People

Contributors

rinrab avatar

Stargazers

 avatar

Watchers

 avatar

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.