Hi,
As said in the topic title, I am a newbie so my question could be fun for dinos :)
I want to make a tetris like for my fun.
In this example, left arrow allows to go to the left, right arrow to the right and down arrow allows to drop the piece. I've no problem with this.
The problem is for the rotate key (up arrow). In fact, I have four BMP for my piece. The first is the "normal" piece, the second is the normal piece rotated@90°, the third is rotated@180° and the last is rotated@270°.
So, I decided to write my code like this : if uparrow is pressed and the piece is normal, then change the normal piece into the rotated@90 one. If uparrow is pressed and the piece is the rotated@90 one, then change the rotated@90 by the rotated@180 etc.
I hope you follow what I mean.
This is the code :
Forme_T=LoadImage ("data/skins/defaut/t.bmp")
Forme_T_R1=LoadImage ("data/skins/defaut/t_r1.bmp")
Forme_T_R2=LoadImage ("data/skins/defaut/t_r2.bmp")
Forme_T_R3=LoadImage ("data/skins/defaut/t_r3.bmp")
While Not KeyHit (1)
Cls
DrawImage (Fond2j,0,0); Draw a background image
Text 0,0,"Tetris New Version 0.002"; A great title, isn't it ? :p
DepartPieceY=DepartPieceY+PieceMvtY
If DepartPieceY>=490
DepartPieceY=490
PieceMvty=0
EndIf
If Forme_T=Forme_T And KeyHit(Fleche_Haut)=1 Then ;
Forme_T=Forme_T_R1
ElseIf Forme_T=Forme_T_R1 And KeyHit(Fleche_Haut)=1 Then
Forme_T=Forme_T_R2
ElseIf Forme_T=Forme_T_R2 And KeyHit(Fleche_Haut)=1 Then
Forme_T=Forme_T_R3
ElseIf Forme_T=Forme_T_R3 And KeyHit(Fleche_Haut)=1 Then
Forme_T=Forme_T
EndIf
If KeyHit(Fleche_Gauche)=1
DepartPieceX=DepartPieceX-30
EndIf
If KeyHit(Fleche_Droite)=1
DepartPieceX=DepartPieceX+30
EndIf
If KeyHit(Fleche_Bas)=1
PieceMvty=50
EndIf
If DepartPieceX<=50
DepartPieceX=50
EndIf
If DepartPieceX>=260
DepartPieceX=260
EndIf
DrawImage (Forme_T,DepartPieceX,DepartPieceY)
Flip
Wend
So, everything works fine but the rotation. When I press the key, the piece rotate (Forme_T becomes Forme_T_R1) but if I press the key again, nothing happens...
Please, can you help me ?
As said in the topic title, I am a newbie so my question could be fun for dinos :)
I want to make a tetris like for my fun.
In this example, left arrow allows to go to the left, right arrow to the right and down arrow allows to drop the piece. I've no problem with this.
The problem is for the rotate key (up arrow). In fact, I have four BMP for my piece. The first is the "normal" piece, the second is the normal piece rotated@90°, the third is rotated@180° and the last is rotated@270°.
So, I decided to write my code like this : if uparrow is pressed and the piece is normal, then change the normal piece into the rotated@90 one. If uparrow is pressed and the piece is the rotated@90 one, then change the rotated@90 by the rotated@180 etc.
I hope you follow what I mean.
This is the code :
Forme_T=LoadImage ("data/skins/defaut/t.bmp")
Forme_T_R1=LoadImage ("data/skins/defaut/t_r1.bmp")
Forme_T_R2=LoadImage ("data/skins/defaut/t_r2.bmp")
Forme_T_R3=LoadImage ("data/skins/defaut/t_r3.bmp")
While Not KeyHit (1)
Cls
DrawImage (Fond2j,0,0); Draw a background image
Text 0,0,"Tetris New Version 0.002"; A great title, isn't it ? :p
DepartPieceY=DepartPieceY+PieceMvtY
If DepartPieceY>=490
DepartPieceY=490
PieceMvty=0
EndIf
If Forme_T=Forme_T And KeyHit(Fleche_Haut)=1 Then ;
Forme_T=Forme_T_R1
ElseIf Forme_T=Forme_T_R1 And KeyHit(Fleche_Haut)=1 Then
Forme_T=Forme_T_R2
ElseIf Forme_T=Forme_T_R2 And KeyHit(Fleche_Haut)=1 Then
Forme_T=Forme_T_R3
ElseIf Forme_T=Forme_T_R3 And KeyHit(Fleche_Haut)=1 Then
Forme_T=Forme_T
EndIf
If KeyHit(Fleche_Gauche)=1
DepartPieceX=DepartPieceX-30
EndIf
If KeyHit(Fleche_Droite)=1
DepartPieceX=DepartPieceX+30
EndIf
If KeyHit(Fleche_Bas)=1
PieceMvty=50
EndIf
If DepartPieceX<=50
DepartPieceX=50
EndIf
If DepartPieceX>=260
DepartPieceX=260
EndIf
DrawImage (Forme_T,DepartPieceX,DepartPieceY)
Flip
Wend
So, everything works fine but the rotation. When I press the key, the piece rotate (Forme_T becomes Forme_T_R1) but if I press the key again, nothing happens...
Please, can you help me ?