Tetris Hard Drop

Hi all!
I am having troubles with my copy of tetris game. I have difficulty in making a hard drop, I made a temporary solution with somthing like this:

[OBJECT PIECE]
(STEP EVENT)
if (key_space_press){
hard_drop = true;
alarm[1] = 1;
}

(ALARM[1] EVENT)
/* Here i check collision and other stuff and make piece falling down
and I have something like this*/

if !(hard_drop){
alarm[1] = myControl.mySpeed;
} else {
alarm[1] = 1;
}

All in all.. i made a "hard drop" sending the object piece to alarm[1] and setting it in 1 to make piece falling faster

I am working with grids. I have my board in a grid called boardDynamic in wich I draw and move my piece
and another grid called boardLanded in wich i have all pieces who have landed moreover i check collisions here and I have all my pieces in a 4x4 grid.
I want to calculate the drop of my piece and try to draw a " ghost " piece in the position that is supossed to will go to fall.
I hope you can understand me .. I try several things but nothing work exactly how I want
 
Last edited:
M

maratae

Guest
I guess the code for a hard-drop should be similar to a ghost piece. I think once you can calculate the ghost position it would be easy to 'hard-drop' pieces into that position. Depending on your code, check the grid on the vertical lines your piece is occupying and start drawing the piece on the place there's the first collision -1 and upwards. I think it all comes down on how you're designing it.
 
Thanks for reply! Look I am using ds_grid as a matrix. I have an array call boardDynamic in wich I save my boards (because i thought to put a multiplayer later) in my dynamic board I draw my current piece. However when that current piece landed I saved in my other board wich is other array called boardLanded and keep all my landed piece there and destroy the current piece.. soo.. when game start.. create a new object called piece wich is a ds_grid of 4x4 and I pass that value to my boardDynamic and check the collision of my current piece position in my boardLanded if there no potential collision just continue falling else just I make it landed and destroy it
Perhaps I make a mess with ds_grid but I am trying to implement this idea with the knowledge that I have
gamedevelopment.tutsplus.com/tutorials/implementing-tetris-collision-detection--gamedev-852
If you need know somthing more let me know!
Yesterday I tried a drop hard in the way that you say but didnt work

/* First i tried to looking for the bottom of my piece and save in an array*/
for(j=0; j < 4; j++){
if (piece[# j, potential[1]] > 0){
if (get_line[j] == 0) {
get_line[j]= piece[# j, potential[1]];
}else{
get_line[j+1] = piece[# j, potential[1]];
}
}
}

/*Here i tried to get the last and the first value of the "width" of bottom of my piece*/
for(i=0; i < 4; i++){
if (get_line > 0){
last_value = i;
if(first_value==-1) then first_value = i;
}
}

/*And here i tried to looking down if my piece will collide with somthing*/
for(i= potential[1]; i < ds_grid_height(landed_board); i++){
for(j=first_value; j < last_value ; j++){
if (landed_board[# j, i] > 0){
return i-1;
}
}
}
 
Last edited:
Top