Post Reply 
BRICKS, tetris clone
03-28-2014, 01:42 PM (This post was last modified: 12-23-2014 06:55 PM by felissylvestris.)
Post: #1
BRICKS, tetris clone
Now HP Prime have it tetris clone Smile
(press "help" in game for the default key list)

Changelog:

V0.3 (23 december 2014): Fix of many little bugs: centering of text, save game: current and next shapes are now saved, next shape: center and show real orientation, center the new shape when appear, new firmware support (Thx to Han).
V0.2 (6 april 2014): You can now quit and save the game, choose your own keys and reset the game.
V0.1 (28 march 2014): First release

Screenshot:
   

Code:

.zip  BRICKS-v0.3.zip (Size: 4.88 KB / Downloads: 165)
Find all posts by this user
Quote this message in a reply
03-28-2014, 05:12 PM
Post: #2
RE: BRICKS, tetris clone
YES ! Smile Smile

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
03-28-2014, 05:46 PM
Post: #3
RE: BRICKS, tetris clone
I made a video to see the game in action :
http://youtu.be/2XlJQqOwjjU

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
03-28-2014, 08:15 PM
Post: #4
RE: BRICKS, tetris clone
Can you post the source code as a text file ?

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
03-28-2014, 09:23 PM
Post: #5
RE: BRICKS, tetris clone
Works really nice!

My website: ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
03-28-2014, 09:41 PM
Post: #6
RE: BRICKS, tetris clone
(03-28-2014 08:15 PM)patrice Wrote:  Can you post the source code as a text file ?

I was able to open the file in word pad and grab the code from there

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-28-2014, 10:33 PM
Post: #7
RE: BRICKS, tetris clone
Please don't use .hpprgm extension for plain text source code.
.hpprgm extension is exclusively an emulator extension and is a binary file.
Have a look to http://www.hpmuseum.org/forum/thread-993.html

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
04-06-2014, 01:00 PM
Post: #8
RE: BRICKS, tetris clone
New release V0.2: You can now quit and save the game, choose your own keys and reset the game.
Find all posts by this user
Quote this message in a reply
04-08-2014, 07:03 AM
Post: #9
RE: BRICKS, tetris clone
Thanks

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
10-09-2014, 10:08 PM
Post: #10
RE: BRICKS, tetris clone
works with firmware 2014 7 2 (6031) A?


I tried and did not work. I get syntax error on line 319
I then lowered my firmware to 2013 11 25 and it worked perfectly.

but I prefer to keep my firmware update, error could you have?
Find all posts by this user
Quote this message in a reply
10-10-2014, 02:01 PM
Post: #11
RE: BRICKS, tetris clone
It's due to the inclusion of a new keyword: COLOR used to extract or define the colors of functions/expressions/etc in the [Symb] view.

Here's a slightly modified source code that will make the game work on newer firmware:

Code:
//
// BRICKS V0.2
// By Kevin Barbier (kevin@kevin-barbier.org)
//

//
// Globals variables
//

// ---- KEY CONFIG ----
LEFT_KEY:=14;
RIGHT_KEY:=15;
DOWN_KEY:=21;
MAX_DOWN_KEY:=30;
ROTATE_KEY:=19;
PAUSE_KEY:=0;
HELP_KEY:=3;
CHOOSE_KEYS_KEY:=9;
RESET_TO_DEFAULT_KEYS_KEY:=13;
RESET_GAME_KEY:=10;
QUIT_KEY:=4;
// --------------------

SCORE_NB_LINES:=0;
SCORE_NB_POINTS:=0;

BRICK_SIZE:=12;

BRICK_COLORS:={[255, 0, 0], [0, 255, 0], [0, 0, 255], [255,255,0], [255,0,255], [0,255,255]};

BRICKS_TAB_W:=10;
BRICKS_TAB_H:=20;
BRICKS_TAB:=[[-1,-1],[-1,-1]];

NB_SHAPES:=7;
NB_ORIENTATIONS:=4;
SHAPES_MAX_W:=4;
SHAPES_MAX_H:=4;

SHAPES_W:={4,1,4,1,
           2,2,2,2,
           3,2,3,2,
           3,2,3,2,
           3,2,3,2,
           3,2,3,2, 
           3,2,3,2};
           
SHAPES_H:={1,4,1,4,
           2,2,2,2,
           2,3,2,3,
           2,3,2,3,
           2,3,2,3,
           2,3,2,3,
           2,3,2,3};

// Bar, square, half cross, Z left, Z rigth, L left, L rigth

SHAPES:={
         [[1,1,1,1],[0,0,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]],
         [[1,1,1,1],[0,0,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]],
         
         [[1,1,0,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,1,0,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,1,0,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,1,0,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]],
         
         [[0,1,0,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]],
         [[1,0,0,0],[1,1,0,0],[1,0,0,0],[0,0,0,0]],
         [[1,1,1,0],[0,1,0,0],[0,0,0,0],[0,0,0,0]],
         [[0,1,0,0],[1,1,0,0],[0,1,0,0],[0,0,0,0]],

         [[1,1,0,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]],
         [[0,1,0,0],[1,1,0,0],[1,0,0,0],[0,0,0,0]],
         [[1,1,0,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]],
         [[0,1,0,0],[1,1,0,0],[1,0,0,0],[0,0,0,0]],

         [[0,1,1,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,0,0,0],[1,1,0,0],[0,1,0,0],[0,0,0,0]],
         [[0,1,1,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,0,0,0],[1,1,0,0],[0,1,0,0],[0,0,0,0]],

         [[1,0,0,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]],
         [[1,1,0,0],[1,0,0,0],[1,0,0,0],[0,0,0,0]],
         [[1,1,1,0],[0,0,1,0],[0,0,0,0],[0,0,0,0]],
         [[0,1,0,0],[0,1,0,0],[1,1,0,0],[0,0,0,0]],

         [[0,0,1,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]],
         [[1,0,0,0],[1,0,0,0],[1,1,0,0],[0,0,0,0]],
         [[1,1,1,0],[1,0,0,0],[0,0,0,0],[0,0,0,0]],
         [[1,1,0,0],[0,1,0,0],[0,1,0,0],[0,0,0,0]]
         };

//
// Functions declarations
//

INIT_SCREEN();
INIT_BRICKS_TAB();
DRAW_SCREEN();
DRAW_BASE_SCREEN();
DRAW_BRICKS_TAB();
DRAW_CURRENT_MOVING_SHAPE();
FLIP_SCREEN();
GET_NEW_COLOR();
GET_NEW_SHAPE_TYPE();
GET_NEW_ORIENTATION();
WAIT_KEY();
WAIT_MS();
X_TO_SCRPOS();
Y_TO_SCRPOS();
DRAW_BRICK();
GET_SHAPE();
DRAW_SHAPE();
COPY_SHAPE_TO_BRICKS_TAB();
TST_SHAPE_CAN_MOVE();
REMOVE_LINES();
GET_LEVEL();
GET_SPEED();
PAUSE();
HELP();
CHOOSE_KEYS();
CHOOSE_KEY();
RESET_TO_DEFAULT_KEYS();
RESET_GAME();
QUIT();

//
// BRICKS()
//
// Main function, entry point
//

EXPORT BRICKS()
BEGIN

LOCAL X:=3;
LOCAL Y:=1;
LOCAL CURRENT_SHAPE_TYPE:=GET_NEW_SHAPE_TYPE();
LOCAL NEXT_SHAPE_TYPE:=GET_NEW_SHAPE_TYPE();
LOCAL ORIENTATION:=GET_NEW_ORIENTATION();
LOCAL colour:=GET_NEW_COLOR();
LOCAL BEGIN_TICKS;
LOCAL TURN_TIME:=GET_SPEED();

SCORE_NB_LINES:=0;
SCORE_NB_POINTS:=0;

INIT_SCREEN();

IF BRICKS_TAB(1,1)==-1 THEN 

INIT_BRICKS_TAB(); END;

WHILE 1 DO
  DRAW_SCREEN(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour, NEXT_SHAPE_TYPE);
  BEGIN_TICKS:=TICKS;

  WHILE TICKS<BEGIN_TICKS+TURN_TIME DO
    // Quit
    IF ISKEYDOWN(QUIT_KEY)<>0 THEN
      IF QUIT()==1 THEN RETURN 0; END; 
    END;

    // Left
    IF ISKEYDOWN(LEFT_KEY)<>0 AND X>1 THEN
      IF TST_SHAPE_CAN_MOVE(CURRENT_SHAPE_TYPE, X-1, Y, ORIENTATION)<>0 THEN
        X:=X−1;
        DRAW_SCREEN(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour, NEXT_SHAPE_TYPE);
        WAIT_MS(TURN_TIME/10);
      END;
    END;

    // Right
    IF ISKEYDOWN(RIGHT_KEY)<>0 THEN
      IF TST_SHAPE_CAN_MOVE(CURRENT_SHAPE_TYPE, X+1, Y, ORIENTATION)<>0 THEN
        X:=X+1;
        DRAW_SCREEN(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour, NEXT_SHAPE_TYPE);
        WAIT_MS(TURN_TIME/10);
      END;
    END;

    // Down
    IF ISKEYDOWN(DOWN_KEY)<>0 THEN
      WAIT_MS(TURN_TIME/10);
      BREAK;
    END;

    // Max down
    IF ISKEYDOWN(MAX_DOWN_KEY)<>0 THEN
      WHILE TST_SHAPE_CAN_MOVE(CURRENT_SHAPE_TYPE, X, Y+1, ORIENTATION)<>0 DO
        Y:=Y+1;
      END;

      WAIT_MS(TURN_TIME/5);
      BREAK;
    END;
    
    // Rotate
    IF ISKEYDOWN(ROTATE_KEY)<>0 THEN
      LOCAL NEW_ORIENTATION:=ORIENTATION;
      IF NEW_ORIENTATION<4 THEN
        NEW_ORIENTATION:=NEW_ORIENTATION+1;
      ELSE
        NEW_ORIENTATION:=1;
      END;

      IF TST_SHAPE_CAN_MOVE(CURRENT_SHAPE_TYPE, X, Y, NEW_ORIENTATION)<>0 THEN
        ORIENTATION:=NEW_ORIENTATION;
      END;

      DRAW_SCREEN(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour, NEXT_SHAPE_TYPE);
      WAIT_MS(250);
    END;

    // Pause
    IF ISKEYDOWN(PAUSE_KEY)<>0 THEN
      PAUSE();
    END;

    // Help
    IF ISKEYDOWN(HELP_KEY)<>0 THEN
      HELP();
    END;
    
    // Choose keys
    IF ISKEYDOWN(CHOOSE_KEYS_KEY)<>0 THEN
      CHOOSE_KEYS();
    END;

    // Reset to default keys
    IF ISKEYDOWN(RESET_TO_DEFAULT_KEYS_KEY)<>0 THEN
      RESET_TO_DEFAULT_KEYS();
    END;

    // Reset game
    IF ISKEYDOWN(RESET_GAME_KEY)<>0 THEN
      RESET_GAME();

      TURN_TIME:=GET_SPEED();
      Y:=1;
      X:=3;
      CURRENT_SHAPE_TYPE:=NEXT_SHAPE_TYPE;
      NEXT_SHAPE_TYPE:=GET_NEW_SHAPE_TYPE();
      colour:=GET_NEW_COLOR();
      ORIENTATION:=GET_NEW_ORIENTATION();
    END;
  END;
  
  IF TST_SHAPE_CAN_MOVE(CURRENT_SHAPE_TYPE, X, Y+1, ORIENTATION)<>0 THEN
    Y:=Y+1;
  ELSE
    COPY_SHAPE_TO_BRICKS_TAB(CURRENT_SHAPE_TYPE, X, Y, colour, ORIENTATION);
    REMOVE_LINES();
    TURN_TIME:=GET_SPEED();

    IF Y==1 THEN
      WAIT(3);
      BREAK;
    ELSE 
      Y:=1;
      X:=3;
      CURRENT_SHAPE_TYPE:=NEXT_SHAPE_TYPE;
      NEXT_SHAPE_TYPE:=GET_NEW_SHAPE_TYPE();
      colour:=GET_NEW_COLOR();
      ORIENTATION:=GET_NEW_ORIENTATION();
    END;
  END;
END;

END;


//
// INIT_BRICKS_TAB()
//
// Initialize the matrix who contain the game
//

INIT_BRICKS_TAB()
BEGIN

BRICKS_TAB:=[
              [1,1,1,1,1,1,1,1,1,1,1,1,1,1],
              [1,1,1,1,1,1,1,1,1,1,1,1,1,1],
              [1,1,1,1,1,1,1,1,1,1,1,1,1,1],
              [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
            ];

FOR I FROM 1 TO BRICKS_TAB_H DO
  ADDROW(BRICKS_TAB, [0,0,0,0,0,0,0,0,0,0,1,1,1,1], 1);
END;

END;


//
// INIT_SCREEN()
//

INIT_SCREEN()
BEGIN

DIMGROB_P(G1, 320, 240);

END;


//
// DRAW_SCREEN()
//
// Draw all screen: decoration, game tab and current moving shape
//
// X: logical position
// Y: logical position
//

DRAW_SCREEN(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour, NEXT_SHAPE_TYPE)
BEGIN

DRAW_BASE_SCREEN(NEXT_SHAPE_TYPE);
DRAW_BRICKS_TAB();
DRAW_CURRENT_MOVING_SHAPE(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour);

FLIP_SCREEN();

END;


//
// DRAW_BASE_SCREEN()
//
// Draw decorations, score, lines, level and next shape
//
// NEXT_SHAPE_TYPE: type of the next shape
//

DRAW_BASE_SCREEN(NEXT_SHAPE_TYPE)
BEGIN

RECT_P(G1, 0, 0, 319, 239, 0, RGB(225,225,225));
RECT_P(G1, 100, 0, 220, 239, 0, RGB(255,255,255));

FOR I FROM 0 TO 5 DO
  LINE_P(G1, 99−I, 0, 99−I, 239, RGB(I*40, I*40, I*40));
END;

FOR I FROM 0 TO 5 DO
  LINE_P(G1, 221+I, 0, 221+I, 239, RGB(I*40, I*40, I*40));
END;

TEXTOUT_P("Lines", G1, 30, 10, 0);
TEXTOUT_P(SCORE_NB_LINES, G1, 45, 30, 0);

TEXTOUT_P("Score", G1, 30, 100, 0);
TEXTOUT_P(SCORE_NB_POINTS, G1, 45, 120, 0);

TEXTOUT_P("Level", G1, 30, 190, 0);
TEXTOUT_P(GET_LEVEL(), G1, 45, 210, 0);

TEXTOUT_P("Next", G1, 250, 10, 0);
DRAW_SHAPE(NEXT_SHAPE_TYPE, 13, 5, 100, 100, 100, 1);

END;


//
// DRAW_BRICKS_TAB()
//
// Draw the game matrix
//

DRAW_BRICKS_TAB()
BEGIN

FOR I FROM 1 TO BRICKS_TAB_H DO
  FOR J FROM 1 TO BRICKS_TAB_W DO
   IF BRICKS_TAB(I, J)<>0 THEN
     R:=BRICK_COLORS(BRICKS_TAB(I, J), 1);
     G:=BRICK_COLORS(BRICKS_TAB(I, J), 2);
     B:=BRICK_COLORS(BRICKS_TAB(I, J), 3);

     DRAW_BRICK(J, I, R, G, B);
    END; 
  END;
END;

END;


//
// DRAW_CURRENT_MOVING_SHAPE()
//
// X: logical position
// Y: logical position
//

DRAW_CURRENT_MOVING_SHAPE(CURRENT_SHAPE_TYPE, X, Y, ORIENTATION, colour)
BEGIN
R:=BRICK_COLORS(colour, 1);
G:=BRICK_COLORS(colour, 2);
B:=BRICK_COLORS(colour, 3);

DRAW_SHAPE(CURRENT_SHAPE_TYPE, X, Y, R, G, B, ORIENTATION);
END;


//
// FLIP_SCREEN()
//
// Flip double buffer
//

FLIP_SCREEN()
BEGIN

BLIT_P(G0, G1);

END;


//
// GET_NEW_COLOR()
//
// Return: a random new color
//

GET_NEW_COLOR()
BEGIN
  RETURN RANDINT(1, SIZE(BRICK_COLORS));
END;


//
// GET_NEW_SHAPE_TYPE()
//
// Return: a random new shape type
//

GET_NEW_SHAPE_TYPE()
BEGIN
  RETURN RANDINT(1, NB_SHAPES);
END;


//
// GET_NEW_ORIENTATION()
//
// Return: a random new orientation
//

GET_NEW_ORIENTATION()
BEGIN
  RETURN RANDINT(1, NB_ORIENTATIONS);
END;


//
// WAIT_KEY()
//
// ID: ID of the key to wait
//

WAIT_KEY(ID)
BEGIN

WHILE GETKEY<>ID DO
END;

END;


//
// WAIT_MS()
//

WAIT_MS(MS)
BEGIN

LOCAL BEGIN_TICKS:=TICKS;

WHILE TICKS<BEGIN_TICKS+MS DO
  A+A;
END;

END;


//
// X_TO_SCRPOS()
//
// Convert a logical position to an absolute screen position
//
// X: logical position
//
// Return: absolute screen position for X
//

X_TO_SCRPOS(X)
BEGIN

RETURN 100+((X-1)*BRICK_SIZE);

END;


//
// Y_TO_SCRPOS()
//
// Convert a logical position to an absolute screen position
//
// Y: logical position
//
// Return: absolute screen position for Y
//

Y_TO_SCRPOS(Y)
BEGIN

RETURN (Y-1)*BRICK_SIZE;

END;


//
// DRAW_BRICK()
//
// Draw a single brick at the logical position X,Y
//
// X: logical position
// Y: logical position
//

DRAW_BRICK(X, Y, R, G, B)
BEGIN

X:=X_TO_SCRPOS(X);
Y:=Y_TO_SCRPOS(Y);

RECT_P(G1, X, Y, X+BRICK_SIZE, Y+BRICK_SIZE, 0, RGB(R,G,B));

END;


//
// GET_SHAPE()
//
// Return: shape structure from the shape type
//

GET_SHAPE(SHAPE_TYPE, ORIENTATION)
BEGIN
  RETURN SHAPES((SHAPE_TYPE-1)*NB_ORIENTATIONS+ORIENTATION);
END;


//
// DRAW_SHAPE()
//
// X: logical position
// Y: logical position
//

DRAW_SHAPE(SHAPE_TYPE, X, Y, R, G, B, ORIENTATION)
BEGIN

FOR I FROM 1 TO SHAPES_MAX_H DO
  FOR J FROM 1 TO SHAPES_MAX_W DO
    LOCAL CURRENT_SHAPE:=GET_SHAPE(SHAPE_TYPE, ORIENTATION);
    IF CURRENT_SHAPE(I, J)<>0 THEN DRAW_BRICK(X+(J-1), Y+(I-1), R, G, B); END;
  END;
END;

END;


//
// COPY_SHAPE_TO_BRICKS_TAB()
//
// X: logical position
// Y: logical position
//

COPY_SHAPE_TO_BRICKS_TAB(SHAPE_TYPE, X, Y, colour, ORIENTATION)
BEGIN

FOR I FROM 1 TO SHAPES_MAX_H DO
  FOR J FROM 1 TO SHAPES_MAX_W DO
    LOCAL CURRENT_SHAPE:=GET_SHAPE(SHAPE_TYPE, ORIENTATION);
    IF CURRENT_SHAPE(I, J)<>0 THEN BRICKS_TAB(Y+(I-1), X+(J-1)):=colour; END;
  END;
END;

END;


//
// TST_SHAPE_CAN_MOVE()
//
// X: logical position
// Y: logical position
//

TST_SHAPE_CAN_MOVE(SHAPE_TYPE, X, Y, ORIENTATION)
BEGIN
  LOCAL CURRENT_SHAPE:=GET_SHAPE(SHAPE_TYPE, ORIENTATION);

  FOR I FROM 1 TO SHAPES_MAX_H DO
    FOR J FROM 1 TO SHAPES_MAX_W DO
      IF (CURRENT_SHAPE(I, J)<>0) AND (BRICKS_TAB(Y+(I-1), X+(J-1))<>0) THEN
        RETURN 0;
      END;
    END;
  END;
  
  RETURN 1;
END;


//
// REMOVE_LINES()
//
// Remove completed lines
//

REMOVE_LINES()
BEGIN
  LOCAL FLAG:=0;
  LOCAL NB_NEW_LINES:=0;

  FOR I FROM 1 TO BRICKS_TAB_H DO
    FLAG:=1;

    FOR J FROM 1 TO BRICKS_TAB_W DO
      IF BRICKS_TAB(I, J)==0 THEN
        FLAG:=0;
        BREAK; 
      END;
    END;

    IF FLAG==1 THEN
      DELROW(BRICKS_TAB, I);
      ADDROW(BRICKS_TAB, [0,0,0,0,0,0,0,0,0,0,1,1,1,1], 1);
      NB_NEW_LINES:=NB_NEW_LINES+1;
    END;
  END;

  SCORE_NB_LINES:=SCORE_NB_LINES+NB_NEW_LINES;
  SCORE_NB_POINTS:=SCORE_NB_POINTS+((NB_NEW_LINES^2)*10);
END;


//
// GET_LEVEL()
//
// Return: the level compute from score
//

GET_LEVEL()
BEGIN
  RETURN ROUND(SCORE_NB_POINTS/500,0);
END;


//
// GET_SPEED()
//
// Return: the current speed for moving shape
//

GET_SPEED()
BEGIN
  LOCAL SPEED:=800-(100*GET_LEVEL());
  IF SPEED<100 THEN SPEED:=100; END;

  RETURN SPEED;
END;


//
// PAUSE()
//

PAUSE()
BEGIN

WAIT_MS(1000);
WAIT_KEY(PAUSE_KEY);
WAIT_MS(1000);

END;


//
// HELP()
//

HELP()
BEGIN

MSGBOX("BRICKS V0.2");
MSGBOX("DEFAULTS KEYS: Left [A], Right [B], Down [G], Max down [ENTER], Rotate [DEL], Pause [APPS], Quit [ESC],");
MSGBOX("Choose custom keys [VIEWS], Reset to default keys [MENU], Reset game [CAS]");

END;


//
// CHOOSE_KEYS()
//
// Choose custom keys
//

CHOOSE_KEYS()
BEGIN

MSGBOX("Left");
LEFT_KEY:=CHOOSE_KEY();

MSGBOX("Right");
RIGHT_KEY:=CHOOSE_KEY();

MSGBOX("Down");
DOWN_KEY:=CHOOSE_KEY();

MSGBOX("Max down");
MAX_DOWN_KEY:=CHOOSE_KEY();

MSGBOX("Rotate");
ROTATE_KEY:=CHOOSE_KEY();

END;


//
// CHOOSE_KEY()
//

CHOOSE_KEY()
BEGIN

LOCAL KEY:=-1;

WHILE (KEY==-1) OR (KEY==0) OR (KEY==3) OR (KEY==9) OR (KEY==13) OR (KEY==4) OR (KEY==10) DO
  KEY:=GETKEY();
END;

RETURN KEY;

END;


//
// RESET_TO_DEFAULT_KEYS()
//

RESET_TO_DEFAULT_KEYS()
BEGIN

C:=MSGBOX("Are you sure to reset keys to default?", 1);

IF C==1 THEN
  LEFT_KEY:=14;
  RIGHT_KEY:=15;
  DOWN_KEY:=21;
  MAX_DOWN_KEY:=30;
  ROTATE_KEY:=19;
END;

END;


//
// RESET_GAME()
//

RESET_GAME()
BEGIN
  C:=MSGBOX("Are you sure to reset game?", 1);

  // Don't save, reset
  IF C==1 THEN
    INIT_BRICKS_TAB();
  END; 
END;


//
// QUIT()
//

QUIT()
BEGIN
  C:=MSGBOX("Are you sure to quit?", 1);

  // If want to quit, ask if save the game
  IF C==1 THEN
     D:=MSGBOX("Do you want to save game?", 1);

     // Don't save, reset
     IF D==0 THEN
       INIT_BRICKS_TAB();
     END; 
  END;

  RETURN C;
END;

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
10-10-2014, 07:25 PM
Post: #12
RE: BRICKS, tetris clone
if it is so, I marked the syntax error on that word, thanks for spending the new source code has worked perfectly.
Find all posts by this user
Quote this message in a reply
12-23-2014, 07:04 PM
Post: #13
RE: BRICKS, tetris clone
I've realeased a V0.3 with some bugfix.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 7 Guest(s)