hi all,
I've searched for an hour now, and no result so I decided to ask you guys.
I'm building a tetris clone for my internship, and I divided my field into a twodimensional array. if a block lands, that coordinate (x,y) gets turned from 0 to 1.
I got tetris so far that it removes rows, but when a row is removed, existing blocks won't drop down anymore, they hang still in the air.
I'm thinking of giving all Boolean 1 blocks a +1 on the vertical coordinate, but I cant get it to work and I can't find relevant info for it (or i'm reading over it, since my experience with free pascal is 2 months.)
the most important pieces of code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, LCLType,math,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
darkblue: TImage;
fallingblock: TImage;
Label1: TLabel;
lightblue: TImage;
green: TImage;
blockfalling: TTimer;
move: TTimer;
yellow: TImage;
orange: TImage;
red: TImage;
purple: TImage;
horizontal: tlabel;
vertical: tlabel;
procedure blockfallingTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
procedure moveTimer(Sender: TObject);
procedure createblock(b: integer);
procedure pickblock();
private
blockwait, bottomcheck, movement, x, y, shapes: integer;
start,filled: boolean;
img : Timage;
location: array[0..10, 0..20] of integer;
arrfilled: array[0..10, 0..20] of boolean;
arrfilledimg: array[0..10, 0..20] of timage;
public
end;
//irrelevant code here
procedure tform1.createblock(b:integer);
var
a,drop:integer;
fullrow:boolean;
begin
x:=5;
y:=0;
img:= timage.create(application);
img.top:=y*50;
img.left:=x*50;
img.visible:=true;
img.stretch:=true;
img.width:=50;
img.height:=50;
img.enabled:=true;
img.transparent:=true;
img.Parent:=fallingblock.parent;
pickblock();
fallingblock:=img;
fullrow:=true;
for a:=0 to 9 do
begin
if arrfilled[a,b]= false then fullrow:=false;
end;
if fullrow then
begin
for a:=0 to 9 do
begin
arrfilled[a,b]:=false;
arrfilledimg[a,b].visible:=false;
end;
{for drop:=0 to 9 do
begin
if a=1 then
begin
b:=0;
b+1:=1;
a:=0;
end;
for drop:=0 to (b-1) do
begin
//b has to go down 1* (b+1) but how?
//how do i separate the 1/0's in my entire array?
//maybe use locate?
end;
end;}
end;
end;
procedure TForm1.blockfallingTimer(Sender: TObject);
begin
horizontal.caption:=x.tostring;
vertical.caption:=y.tostring;
if (y>=19) or (arrfilled[x,(y+1)]=true) then
begin
arrfilled[x,y] := true;
arrfilledimg[x,y] := fallingblock;
createblock(y);
end
else
begin
y:=y+1;
fallingblock.top := 50 * y;
end;
end;