H
Holodoc
Guest
Ich hab so ein Spiel in Pascal geschrieben, und finde den Fehler nicht. Es funktioniert eigentlich alles, aber der Fehler ist total dumm. Wenn nur noch ein Streichholz da ist, und der Benutzer dran ist, soll der Benutzer 1 eingeben. Aber damit die 1 auf dem Bildschirm erscheint muss man 2 mal drücken.
Das Programm ist übrigens noch nicht ganz fertig... Falls jemand Probleme damit hat, dass der Quelltext nicht eingerückt ist, dannn kann ich es natürlich auch - am besten per ICQ - schicken!
Tnx im voraus!
============================================================
program matchgame;
uses crt;
var pos1,x,y,i,y_inc,t_comp,matches : integer;
mm,t_user : char;
user : string[12];
procedure main_menu;
begin
pos1 := 1;
repeat
gotoxy(35,7); textcolor(lightred); write('Main Menu');
if (pos1 = 1) then begin gotoxy(35,10); textcolor(white); end
else begin gotoxy(35,10); textcolor(lightgray); end;
write('Start Game');
if (pos1 = 2) then begin gotoxy(35,12); textcolor(white); end
else begin gotoxy(35,12); textcolor(lightgray); end;
write('Settings');
if (pos1 = 3) then begin gotoxy(35,14); textcolor(white); end
else begin gotoxy(35,14); textcolor(lightgray); end;
write('Quit Game');
repeat mm := readkey; until(mm in ['2','8',chr(13)]);
case mm of
'8' : begin
case pos1 of
1 : begin pos1 := 3; end;
2 : begin pos1 := 1; end;
3 : begin pos1 := 2; end;
end;
end;
'2' : begin
case pos1 of
1 : begin pos1 := 2; end;
2 : begin pos1 := 3; end;
3 : begin pos1 := 1; end;
end;
end;
end;
until (mm = chr(13));
end;
procedure match;
begin
textcolor(lightgray);
gotoxy(x,y);
write(chr(219));
textcolor(darkgray);
for y_inc := 1 to 4 do begin
gotoxy(x,y+y_inc);
write(chr(219));
end;
textcolor(lightgray);
end;
procedure matchdelete;
begin
textcolor(lightgray);
gotoxy(x,y);
write(chr(219));
clreol;
textcolor(darkgray);
for y_inc := 1 to 4 do begin
gotoxy(x,y+y_inc);
write(chr(219));
clreol;
end;
textcolor(lightgray);
end;
procedure writematches;
begin
if (matches > 0) then begin
x := 18;
y := 7;
if (matches = 1) then begin
x := x+4;
match;
matchdelete
end
else begin
for i := 1 to matches do begin
x := x+4;
match;
if (i = matches) then matchdelete;
end;
end;
end
else begin
for y := 7 to 11 do begin
gotoxy(22,y);
clreol;
end;
end;
end;
procedure usertake;
begin
gotoxy(29,19);
write(' ');
if (matches > 2) then begin
repeat t_user := readkey; until (t_user in ['1'..'3']);
end;
if (matches < 3) then begin
repeat t_user := readkey; until (t_user in ['1','2']);
end;
if (matches < 2) then begin
repeat t_user := readkey; until (t_user = '1');
end;
end;
procedure comptake;
begin
if (matches > 2) then begin t_comp := random(3)+1; end;
if (matches < 3) then begin t_comp := random(2)+1; end;
if (matches < 2) then begin t_comp := 1; end;
end;
procedure main_program;
begin
matches := 10;
randomize;
repeat
t_user := '0';
t_comp := 0;
writematches;
if (matches < 10) then delay(1000);
textcolor(lightred); gotoxy(23,17); write(user);
textcolor(lightgray); gotoxy(23,19); write('Take: ');
textcolor(lightred); gotoxy(50,17); write('Computer');
textcolor(lightgray); gotoxy(50,19); write('Take: ');
usertake;
case t_user of
'1' : begin matches := matches-1; end;
'2' : begin matches := matches-2; end;
'3' : begin matches := matches-3; end;
end;
writematches;
textcolor(lightgray); gotoxy(29,19); write(t_user);
if (matches <> 0) then begin
comptake;
textcolor(lightred); gotoxy(23,17); write(user);
textcolor(lightgray); gotoxy(23,19); write('Take: ',t_user);
textcolor(lightred); gotoxy(50,17); write('Computer');
textcolor(lightgray); gotoxy(50,19); write('Take: ');
delay(1000);
gotoxy(56,19);
write(t_comp);
case t_comp of
1 : begin matches := matches-1; end;
2 : begin matches := matches-2; end;
3 : begin matches := matches-3; end;
end;
end;
until (matches <= 0);
writematches;
delay(1500);
end;
begin
user := ('User');
repeat
clrscr;
main_menu;
clrscr;
case pos1 of
1 : begin main_program; end;
2 : begin clrscr; write('Settings'); readln; end;
end;
until (pos1 = 3);
end.
Das Programm ist übrigens noch nicht ganz fertig... Falls jemand Probleme damit hat, dass der Quelltext nicht eingerückt ist, dannn kann ich es natürlich auch - am besten per ICQ - schicken!
Tnx im voraus!
============================================================
program matchgame;
uses crt;
var pos1,x,y,i,y_inc,t_comp,matches : integer;
mm,t_user : char;
user : string[12];
procedure main_menu;
begin
pos1 := 1;
repeat
gotoxy(35,7); textcolor(lightred); write('Main Menu');
if (pos1 = 1) then begin gotoxy(35,10); textcolor(white); end
else begin gotoxy(35,10); textcolor(lightgray); end;
write('Start Game');
if (pos1 = 2) then begin gotoxy(35,12); textcolor(white); end
else begin gotoxy(35,12); textcolor(lightgray); end;
write('Settings');
if (pos1 = 3) then begin gotoxy(35,14); textcolor(white); end
else begin gotoxy(35,14); textcolor(lightgray); end;
write('Quit Game');
repeat mm := readkey; until(mm in ['2','8',chr(13)]);
case mm of
'8' : begin
case pos1 of
1 : begin pos1 := 3; end;
2 : begin pos1 := 1; end;
3 : begin pos1 := 2; end;
end;
end;
'2' : begin
case pos1 of
1 : begin pos1 := 2; end;
2 : begin pos1 := 3; end;
3 : begin pos1 := 1; end;
end;
end;
end;
until (mm = chr(13));
end;
procedure match;
begin
textcolor(lightgray);
gotoxy(x,y);
write(chr(219));
textcolor(darkgray);
for y_inc := 1 to 4 do begin
gotoxy(x,y+y_inc);
write(chr(219));
end;
textcolor(lightgray);
end;
procedure matchdelete;
begin
textcolor(lightgray);
gotoxy(x,y);
write(chr(219));
clreol;
textcolor(darkgray);
for y_inc := 1 to 4 do begin
gotoxy(x,y+y_inc);
write(chr(219));
clreol;
end;
textcolor(lightgray);
end;
procedure writematches;
begin
if (matches > 0) then begin
x := 18;
y := 7;
if (matches = 1) then begin
x := x+4;
match;
matchdelete
end
else begin
for i := 1 to matches do begin
x := x+4;
match;
if (i = matches) then matchdelete;
end;
end;
end
else begin
for y := 7 to 11 do begin
gotoxy(22,y);
clreol;
end;
end;
end;
procedure usertake;
begin
gotoxy(29,19);
write(' ');
if (matches > 2) then begin
repeat t_user := readkey; until (t_user in ['1'..'3']);
end;
if (matches < 3) then begin
repeat t_user := readkey; until (t_user in ['1','2']);
end;
if (matches < 2) then begin
repeat t_user := readkey; until (t_user = '1');
end;
end;
procedure comptake;
begin
if (matches > 2) then begin t_comp := random(3)+1; end;
if (matches < 3) then begin t_comp := random(2)+1; end;
if (matches < 2) then begin t_comp := 1; end;
end;
procedure main_program;
begin
matches := 10;
randomize;
repeat
t_user := '0';
t_comp := 0;
writematches;
if (matches < 10) then delay(1000);
textcolor(lightred); gotoxy(23,17); write(user);
textcolor(lightgray); gotoxy(23,19); write('Take: ');
textcolor(lightred); gotoxy(50,17); write('Computer');
textcolor(lightgray); gotoxy(50,19); write('Take: ');
usertake;
case t_user of
'1' : begin matches := matches-1; end;
'2' : begin matches := matches-2; end;
'3' : begin matches := matches-3; end;
end;
writematches;
textcolor(lightgray); gotoxy(29,19); write(t_user);
if (matches <> 0) then begin
comptake;
textcolor(lightred); gotoxy(23,17); write(user);
textcolor(lightgray); gotoxy(23,19); write('Take: ',t_user);
textcolor(lightred); gotoxy(50,17); write('Computer');
textcolor(lightgray); gotoxy(50,19); write('Take: ');
delay(1000);
gotoxy(56,19);
write(t_comp);
case t_comp of
1 : begin matches := matches-1; end;
2 : begin matches := matches-2; end;
3 : begin matches := matches-3; end;
end;
end;
until (matches <= 0);
writematches;
delay(1500);
end;
begin
user := ('User');
repeat
clrscr;
main_menu;
clrscr;
case pos1 of
1 : begin main_program; end;
2 : begin clrscr; write('Settings'); readln; end;
end;
until (pos1 = 3);
end.