TBlock
 MARCO BIANCHINI
 bianco@arcanet.it

This Component allow you to easy play block in your application.

unit T_BLOCK;


// DATA:      INIZIO:    FINE:      LAVORO:
//
//  13-07-97,  04:18:16   ??:??:??,  TROPPO STANCO PER CONCLUDERE
//                                   QUALCOSA DI BUONO...
//  14-07-97,  01:36:10,  03:44:05,  QUASI FINITO.
//  29-08-97,  00:54:11,  04:09:58,  AGGIUNTO LA PREVIEW FORM.
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,winprocs,
  wintypes,extctrls;

CONST
 LINES=24;
 COLUMNS=17;
 COLORI:ARRAY[0..15] OF TCOLOR = (CLBLACK,CLMAROON,CLGREEN,CLOLIVE,CLNAVY,
                                CLPURPLE,CLTEAL,CLGRAY,CLSILVER,CLRED,
                                CLLIME,CLYELLOW,CLBLUE,CLFUCHSIA,
                                CLAQUA,CLWHITE);
type
  TBLOCK=class(TGraphicControl)
  private
   { Private declarations }
   Piece:ARRAY[1..2,0..2] OF TCOLOR;
   LX,LY,CX,CY:INTEGER;
   SIL,SFC:BOOLEAN;
   Vet:array[0..COLUMNS,0..LINES,1..2] of TCOLOR;
   P_COUNT:INTEGER;
   DELETEDL:INTEGER;
   NCOLORI:INTEGER;
   SQX:INTEGER;
   P_CAPT:TCAPTION;
   snp:boolean;
   F_PREW:TFORM;   //FORM PREW
   P_SIZE:INTEGER; //DIMENSIONI PREW
   PROCEDURE DISEGNA_PEZZ(CONST X,Y:INTEGER;CONST VEDI:BOOLEAN);
   PROCEDURE VUOTA_COLONNA(CONST G:INTEGER);
   FUNCTION CHECK_FULL:BOOLEAN;
   PROCEDURE SAVE_POSITION;
   PROCEDURE SHOW_PREW;

   PROCEDURE SET_SNP(VALUE:BOOLEAN);
   PROCEDURE SET_SQUARE_DIM(VALUE:INTEGER);
   PROCEDURE SET_NCOLORI(VALUE:INTEGER);
   PROCEDURE NOT_(VALUE:INTEGER);
   PROCEDURE SET_CAPTION(VALUE:TCAPTION);
   PROCEDURE SET_P_SIZE(S:INTEGER);
  protected
    { Protected declarations }
   procedure Paint; override;
  public
    { Public declarations }
   FUNCTION MOVE_DOWN:INTEGER;
   FUNCTION MOVE_LEFT:BOOLEAN;
   FUNCTION MOVE_RIGHT:BOOLEAN;
   FUNCTION HELP_ME:BOOLEAN;
   FUNCTION SEND_BOTTOM:INTEGER;
   PROCEDURE NEW_GAME; // INIZIALIZZA IL GIOCO
   PROCEDURE ROTATE;
  published
    { Published declarations }
   Constructor Create(AOwner:TComponent); OVERRIDE;
   PROPERTY NumberOfPieces:INTEGER READ P_COUNT WRITE NOT_;
   PROPERTY LastDeletedPieces:INTEGER READ DELETEDL WRITE NOT_;
   PROPERTY NumberOfColors:INTEGER READ NCOLORI WRITE SET_NCOLORI;
   PROPERTY ShowBorderColor:BOOLEAN READ SIL WRITE SIL;
   PROPERTY ShowFillColor:BOOLEAN READ SFC WRITE SFC default True;
   PROPERTY ShowNextpiece:BOOLEAN READ SNP WRITE SET_SNP;
   PROPERTY SquareDimension:INTEGER READ SQX WRITE SET_SQUARE_DIM;
   PROPERTY PreviewSize:INTEGER READ P_SIZE WRITE SET_P_SIZE;
   PROPERTY PreviewCaption:TCAPTION READ P_CAPT WRITE SET_CAPTION;
 end;

procedure Register;

implementation

 ...


Property
 NumberOfColors:Integer;
  This value must be between 5 and 14. It represent the number of
  avaiable color to create the object.
 
 NumberOfPieces:Integer;
  RunTime Read Only.
  Return the current piece's number.
 
 PrewCaption:TCaption;
  The caption of the preview form.
 
 PreviewSize:Integer;
  The size of the square in the preview form.
  The preview form will be automatically resized when this value
  change.

 ShowBorderColor:Boolean;
  If true show the border color of any square
  If false the border color is clBlack (BackGround).

 ShowBorderColor:Boolean;
  If true show the fill color of any square
  If false the fill color is clBlack (BackGround).

 ShowNextPiece:Boolean;
  If true the preview form is visible.
  If False ''  ''      ''  '' not visible but loaded in memory.
 
 SquareDimension:Integer;
  Set the dimension in pixel of any square in the component area.
  Height and width will be automatically updated.
  NOTE:
   If you resize the control at Run/Design Time this value is not 
   updated, but anyway the control try to fill automatically the 
   control area.

Methods:
  FUNCTION MOVE_DOWN:INTEGER;
   This function try to move down the current piece.
   If OK it return 0;
   If the piece is stopped it return 1,set the next piece as current
   piece and create a new next piece.
   It return 2 if after stopped you can not insert an other piece.

  FUNCTION MOVE_LEFT:BOOLEAN; / FUNCTION MOVE_RIGHT:BOOLEAN;
   These functions returns true if the current piece can be moved
   Right or Left rispectively. 

  FUNCTION HELP_ME:BOOLEAN;
   This function set the first square's color of the next piece
   as clWhite. The white piece is particular because when the
   piece is stopped, it delete all the square of the same color
   of the piece below him.
   This function return false only if the first square's color of
   the next piece is clWhite.

  FUNCTION SEND_BOTTOM:INTEGER;
   Send to the bottom the piece and return the number of traslations.

  PROCEDURE NEW_GAME; // INIZIALIZZA IL GIOCO
   This procedure must be called to initialize a new game.  

  PROCEDURE ROTATE;
   Rotate the current an the next piece.

 HHAAAHHUU....
  It's late...
  I must sleep...
  I hope this file help you, if not, look the demo
  or Mail me any question (bianco@arcanet.it) about it.

Ciao,
  Marco Bianchini
  Via Tassi 6 San Felice S/P (MO) ITALY
  41038
  Tel. +39 535 82534
                                    
 
 


 
 