Created
March 13, 2012 18:30
-
-
Save studentIvan/2030515 to your computer and use it in GitHub Desktop.
pascal chess board drawing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USES CRT, GRAPH; | |
VAR | |
gd, gm: integer; | |
x, y: integer; | |
{chess_board} | |
c_offset, c_side, c_step, | |
c_cursor_x, c_cursor_y, | |
c_cl_black, c_cl_white, | |
c_pixels_offset: integer; | |
c_black: boolean; | |
{/chess_board} | |
BEGIN | |
clrscr; | |
gd:=detect; | |
initgraph(gd, gm, ''); | |
{chess_board_draw} | |
c_side:=400; | |
c_offset:=10; | |
c_cl_black:=8; | |
c_cl_white:=15; | |
c_pixels_offset:=3; | |
if (c_side mod 8) <> 0 then | |
begin | |
closegraph; | |
writeln('c_side error'); | |
readkey; | |
exit; | |
end; | |
c_step:=c_side div 8; | |
c_black:=false; | |
setcolor(c_cl_black); | |
setlinestyle(0, 0, 3); | |
for y:=8 downto 1 do | |
begin | |
c_cursor_x:=0; | |
for x:=1 to 8 do | |
begin | |
if c_black then | |
begin | |
setfillstyle(1, c_cl_black); | |
c_black:=false; | |
end | |
else | |
begin | |
setfillstyle(1, c_cl_white); | |
c_black:=true; | |
end; | |
bar(c_cursor_x+c_offset, c_cursor_y+c_offset, | |
c_cursor_x+c_offset+c_step, c_cursor_y+c_offset+c_step); | |
c_cursor_x:=c_cursor_x+c_step; | |
end; | |
if c_black then c_black:=false else c_black:=true; | |
c_cursor_y:=c_cursor_y+c_step; | |
end; | |
rectangle(c_offset-c_pixels_offset, c_offset-c_pixels_offset, | |
c_offset+c_side+c_pixels_offset, c_offset+c_side+c_pixels_offset); | |
{/chess_board_draw} | |
readkey; | |
closegraph; | |
END. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment