A simple simulation of old game Snake
Delphi & Pascal (česká wiki)
Category: KMP (Club of young programmers)
Author: Matej Ridzoň
Program: Hadr.pas, Pohyb.pas
File exe: Hadr.exe
need: Had.zip
flow: Had_prezentacia.pdf
Author: Matej Ridzoň
Program: Hadr.pas, Pohyb.pas
File exe: Hadr.exe
need: Had.zip
flow: Had_prezentacia.pdf
A simple simulation of old game Snake. Controls are arrows. The program has inside a simple AI (In beginning it was tester of some aspects of game), which was not totaly completed. Program was compiled in fpc 2.2 - mode object pascal. Program was designed to show, how to use easy units graph, wincrt) and create complex program. I hope, you will like this game and find any inspiration in it.
unit pohyb; {$mode objfpc}{$H+} interface const P=1; L=2; H=3; D=4; type TAIpole=array[1..50,1..100] of longint; procedure AIvypln(y,x:longint;var AIpole:TAIpole;typ:longint); //typ - pre vyssie urovne AI function AIzisti(y,x:longint;AIpole:TAIpole):longint; implementation procedure AIvypln(y,x:longint;var AIpole:TAIpole;typ:longint); var Ri,Rj:longint; begin if (x mod 2)=0 then for Ri:=1 to x do begin if Ri=1 then begin for Rj:=1 to y do begin if Rj=y then AIpole[Ri,Rj]:=D else AIpole[Ri,Rj]:=P; end; end else if Ri=2 then begin for Rj:=1 to y do begin if Rj=1 then AIpole[Ri,Rj]:=H else if Rj=y then AIpole[Ri,Rj]:=D else if (Rj mod 2)=0 then AIpole[Ri,Rj]:=D else AIpole[Ri,Rj]:=L; end; end else if Ri=x then begin for Rj:=1 to y do begin if (Rj mod 2)=0 then AIpole[Ri,Rj]:=L else AIpole[Ri,Rj]:=H; end; end else begin for Rj:=1 to y do begin if (Rj mod 2)=0 then AIpole[Ri,Rj]:=D else AIpole[Ri,Rj]:=H; end; end; end else begin for Ri:=1 to x do for Rj:=1 to y do AIpole[Ri,Rj]:=P; end; end; function AIzisti(y,x:longint;AIpole:TAIpole):longint; begin if AIpole[x,y]=H then AIzisti:=72 else if AIpole[x,y]=L then AIzisti:=75 else if AIpole[x,y]=P then AIzisti:=77 else if AIpole[x,y]=D then AIzisti:=80; end; end.