Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Q1_1;
- uses Crt;
- var i, Health, Ammo, MaxAmmo, t, ChY, ShotVar, UpdateTime, enY, Score, Point, GLanguage, UpdateTimeTemp, GLanguageTemp: integer;
- Button: Char;
- ShotX, enX: real;
- Game, Menu, EnemyOnScreen: boolean;
- SettingsFile, LanguagesFile: text;
- langs: array[1..50] of string;
- procedure InitStatistics();
- var i: integer;
- begin
- gotoXY(1, 1);
- textColor(LightRed);
- for i := 1 to Health div 10 do
- write('▓');
- gotoXY(13, 1);
- textColor(LightCyan);
- write(Health);
- gotoXY(11, 1);
- write('▌');
- gotoXY(17, 1);
- write(langs[1], ' ▌', ' ', langs[3], ' ', Score);
- gotoXY(1, 2);
- textColor(White);
- for i := 1 to Ammo div 20 do
- write('▌');
- textColor(LightCyan);
- gotoXY(11, 2);
- write('▌');
- if GLanguage = 2 then
- gotoXY(28, 2)
- else if GLanguage = 1 then
- gotoXY(26, 2);
- write('▌');
- gotoXY(13, 2);
- textColor(LightCyan);
- write(Ammo);
- gotoXY(17, 2);
- write(langs[2]);
- end;
- function ZPressed(): boolean;
- begin
- if (Button = #122) or (Button = #1103) or (Button = #53) then
- result := true;
- end;
- function OPressed(): boolean;
- begin
- if (Button = #111) or (Button = #1097) or (Button = #56) then
- result := true;
- end;
- function LPressed(): boolean;
- begin
- if (Button = #108) or (Button = #1076) or (Button = #50) then
- result := true;
- end;
- function APressed(): boolean;
- begin
- if (Button = #97) or (Button = #1092) or (Button = #48) then
- result := true;
- end;
- function KPressed(): boolean;
- begin
- if (Button = #107) or (Button = #1083) or (Button = #52) then
- result := true;
- end;
- function DVPressed(): boolean;
- begin
- if (Button = #59) or (Button = #1078) or (Button = #54) then
- result := true;
- end;
- procedure Shot();
- begin
- gotoXY(round(ShotX), ChY);
- write('*');
- if ShotVar = 1 then
- ShotX:= ShotX + 0.5;
- end;
- procedure NoAmmo();
- begin
- textColor(Cyan);
- gotoXY(25, 2);
- write(langs[4]);
- end;
- procedure Character(y: integer);
- begin
- textColor(Green);
- gotoXY(3, y);
- write('╠►');
- end;
- procedure CharacterMove(UpOrDown: integer);
- begin
- case UpOrDown of
- 1: begin
- ChY := ChY - 1;
- end;
- 2: begin
- ChY := ChY + 1;
- end;
- 0: begin
- ChY := ChY;
- end;
- end;
- if ChY < 5 then
- ChY := 5;
- if ChY > 24 then
- Chy := 24;
- end;
- procedure TestEnemies();
- begin
- if EnemyOnScreen then
- begin
- textColor(LightMagenta);
- gotoXY(round(enX), enY);
- write('◄╡');
- EnX := EnX - 0.01;
- if EnX <= 2 then
- begin
- Health := Health - 10;
- EnX := 79;
- EnemyOnScreen := false;
- end;
- end;
- end;
- procedure AboutCycle();
- begin
- clrScr;
- while true do
- begin
- if KeyPressed then
- Button := ReadKey
- else
- Button := #0;
- textColor(LightGreen);
- gotoXY(1, 1);
- write(langs[5], #10, langs[6], #10, #10, langs[7]);
- gotoXY(1, 10);
- textColor(Green);
- write(langs[8]);
- if (APressed) then
- break;
- end;
- end;
- procedure SettingsCursor();
- begin
- if LPressed then
- Point := Point + 1;
- if OPressed then
- Point := Point - 1;
- if Point > 2 then
- Point := 1;
- if Point < 1 then
- Point := 2;
- textColor(Yellow);
- case Point of
- 1: begin
- gotoXY(5, 7);
- write('*');
- if KPressed then
- begin
- if UpdateTimeTemp <= 50 then
- UpdateTimeTemp := UpdateTimeTemp - 1
- else if UpdateTimeTemp > 50 then
- UpdateTimeTemp := UpdateTimeTemp - 10;
- if UpdateTimeTemp < 1 then
- UpdateTimeTemp := 1;
- end;
- if DVPressed then
- begin
- if UpdateTimeTemp < 50 then
- UpdateTimeTemp := UpdateTimeTemp + 1
- else if UpdateTimeTemp >= 50 then
- UpdateTimeTemp := UpdateTimeTemp + 10;
- if UpdateTimeTemp > 1000 then
- UpdateTimeTemp := 1000;
- end;
- end;
- 2: begin
- gotoXY(5, 9);
- write('*');
- if KPressed then
- begin
- GLanguageTemp := GLanguageTemp - 1;
- if GLanguageTemp < 1 then
- GLanguageTemp := 2;
- end;
- if DVPressed then
- begin
- GLanguageTemp := GLanguageTemp + 1;
- if GLanguageTemp > 2 then
- GLanguageTemp := 1;
- end;
- end;
- end;
- end;
- procedure SettingsCycle();
- var i: integer;
- begin
- clrScr;
- Point := 1;
- while true do
- begin
- if KeyPressed then
- Button := ReadKey
- else
- Button := #0;
- t := t + 1;
- SettingsCursor;
- textColor(Yellow);
- gotoXY(5, 3);
- write(langs[14]);
- textColor(White);
- gotoXY(7, 7);
- write(langs[13], ' >> ', UpdateTimeTemp);
- gotoXY(7, 9);
- write(langs[17], ' >> ');
- if GLanguageTemp = 1 then
- write('EN');
- if GLanguageTemp = 2 then
- write('РУС');
- gotoXY(5, 18);
- textColor(LightGray);
- write(langs[18]);
- gotoXY(5, 20);
- textColor(Magenta);
- write(langs[19]);
- if APressed then
- begin
- close(SettingsFile);
- rewrite(SettingsFile);
- writeln(SettingsFile, UpdateTimeTemp);
- writeln(SettingsFile, GLanguageTemp);
- close(SettingsFile);
- reset(SettingsFile);
- readln(SettingsFile, UpdateTime, GLanguage);
- break;
- end;
- if t mod UpdateTime = 0 then
- clrScr;
- end;
- end;
- procedure MenuCursor();
- var About: boolean;
- begin
- if LPressed then
- Point := Point + 1;
- if OPressed then
- Point := Point - 1;
- if Point > 4 then
- Point := 1;
- if Point < 1 then
- Point := 4;
- textColor(Yellow);
- case Point of
- 1: begin
- gotoXY(5, 8);
- write('*');
- if ZPressed then
- begin
- Game := true;
- Menu := false;
- end;
- end;
- 2: begin
- gotoXY(5, 10);
- write('*');
- if ZPressed then
- begin
- SettingsCycle;
- end;
- end;
- 3: begin
- gotoXY(5, 12);
- write('*');
- if ZPressed then
- AboutCycle();
- end;
- 4: begin
- gotoXY(5, 14);
- write('*');
- if ZPressed then
- begin
- clrscr;
- halt;
- end;
- end;
- end;
- gotoXY(5, 19);
- textColor(LightCyan);
- write(langs[15]);
- textColor(Magenta);
- gotoXY(5, 21);
- write(langs[16]);
- end;
- begin
- assign(SettingsFile, 'settings.cis');
- reset(SettingsFile);
- readln(SettingsFile, UpdateTime, GLanguage);
- UpdateTimeTemp := UpdateTime;
- GLanguageTemp := GLanguage;
- if GLanguage = 1 then
- begin
- assign(LanguagesFile, 'langEN.cil');
- reset(LanguagesFile);
- for i := 1 to 50 do
- readln(LanguagesFile, langs[i]);
- end;
- if GLanguage = 2 then
- begin
- assign(LanguagesFile, 'langRUS.cil');
- reset(LanguagesFile);
- for i := 1 to 50 do
- readln(LanguagesFile, langs[i]);
- end;
- setWindowCaption('Console Invaders');
- hideCursor;
- ChY := 5;
- Health := 100;
- Ammo := 200;
- t := 0;
- ShotX := 4;
- Menu := true;
- Game := false;
- EnemyOnScreen := false;
- enX := 79;
- Score := 0;
- Point := 1;
- while true do
- begin
- while Menu do
- begin
- t := t + 1;
- if KeyPressed then
- Button := ReadKey
- else
- Button := #0;
- textColor(Yellow);
- gotoXY(5, 3);
- write('╠► *** CONSOLE INVADERS --- ◄╡');
- textColor(White);
- gotoXY(7, 8);
- write(langs[9]);
- gotoXY(7, 10);
- write(langs[10]);
- gotoXY(7, 12);
- write(langs[11]);
- gotoXY(7, 14);
- write(langs[12]);
- MenuCursor();
- if t mod UpdateTime = 0 then
- ClrScr;
- end;
- while Game do
- begin
- t := t + 1;
- if KeyPressed then
- Button := ReadKey
- else
- Button := #0;
- InitStatistics;
- if (ZPressed) and (Ammo > 0) and (ShotVar = 0) then
- begin
- ShotVar := 1;
- Ammo := Ammo - 1;
- end;
- if ShotVar = 1 then
- begin
- Shot;
- end;
- if ShotX >= 80 then
- begin
- ShotVar := 0;
- ShotX := 4;
- end;
- if Ammo <= 0 then
- NoAmmo;
- if OPressed then
- CharacterMove(1)
- else if LPressed then
- CharacterMove(2)
- else
- CharacterMove(0);
- Character(ChY);
- if EnemyOnScreen = false then
- begin
- enY := random(19) + 5;
- EnemyOnScreen := true;
- end;
- TestEnemies;
- if Health <= 0 then
- begin
- Menu := true;
- Game := false;
- halt;
- end;
- if (ShotX >= EnX) and (ChY = EnY) then
- begin
- EnemyOnScreen := false;
- Score := Score + 10;
- EnX := 79;
- end;
- if Score >= 500 then
- begin
- clrScr;
- while true do
- begin
- gotoXY(5, 5);
- textColor(random(2) + 13);
- write(langs[20]);
- end;
- end;
- if t mod UpdateTime = 0 then
- clrScr;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement