Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 1.52 KB

README.md

File metadata and controls

66 lines (47 loc) · 1.52 KB

Fortran Snake

This is just a short attempt to code a classical "Snake" game in Fortran.

Illustration picture

Installation

1 Raylib

Download, build and install raylib library using instructions from here:

Installing dependecies:

$ sudo dnf install alsa-lib-devel mesa-libGL-devel libX11-devel libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel libatomic

Buliding raylib:

$ git clone --depth 1 https://github.com/raysan5/raylib.git raylib
$ cd raylib/src/
$ make PLATFORM=PLATFORM_DESKTOP # To make the static version.
$ sudo make install # Static version

Testing the installation

$ cd raylib/examples
$ make PLATFORM=PLATFORM_DESKTOP

2 Download and compile Fortran bindings with raylib

$ git clone --depth 1 https://github.com/interkosmos/fortran-raylib
$ cd fortran-raylib
$ make

3 Tune the build script to your needs

In build.sh set the path to the directory containing fortran-raylib code.

4 Compile and run the game

$ ./build.sh
$ ./a.out

Instructions

The game speed, board size, number of snakes and number of food is controlled by modifying the source code.

  • Press 'R' anytime to restart the game
  • Press 'X' anytime to make "Snake #1" grow

All snakes are controlled by a computer. To control "Snake #1" manually, uncomment a line in initialize subroutine. The snake is then controlled by 'ASDW' keys.