As the title implies, I need help with programming in the shooting function for the space ship. I'm supposed to program a Space Invaders clone in good ol' pascal using non other than the CRT library; that means no graphics, just characters to interpret the game's graphics. As of now I managed to code-in the spacebar function to create the bullet, but what I want to do now is to move the bullet upwards.
Code:
USES crt;
CONST
max_row = 40; //Matrix dimensions
max_col = 80;
Spacebar = #32;
// Can_Shoot checks the posibility to shoot, not yet implemented
// Shooting checks if the user y pressing the spacebar key
PROCEDURE Bullet_Creation(var Can_Shoot : boolean; var Shooting : char);
BEGIN
REPEAT
Shooting := readkey;
IF Shooting = Spacebar AND Can_Shoot THEN
BEGIN
gotoxy(9,9);
writeln('I');
Can_Shoot := false;
END;
UNTIL keypressed;
END;
// Main Program
var Can_Shoot : boolean;
Shooting : char;
MATRIX : ARRAY[1..max_row,1..max_col] OF char;
i,j : byte;
BEGIN
Bullet_Creation(Can_Shoot,Shooting);
//Print Matrix
for i:=1 to max_row do
begin
for j:=1 to max_col do
write (MATRIX[i,j]);
writeln;
end;
readln();
END.
Thanks in advance!
Psycho.
PD: As you can see, the gameplay field is supposed to be a matrix.
Bookmarks