Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
4467 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  Tetris

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Tetris

n°1848836
smallmadtv
tain t'es la toi !!!
Posté le 09-02-2009 à 11:16:19  profilanswer
 

Salut,
 
Je débute en C++, je suis tjs en train d'apprendre  les bases du langage. Mais j'ai besoin d'un challenge pour mieux progresser...  
 
J'ai donc décider de tenter de faire un Tetris. Je commence de Zero! et j'ai juste commencé a réfléchir sur comment le programme devrait se structurer.
 
Auriez vous des informations sur un Tetris en C++ ?
 
Je suppose que d'autre s'y on déjà frotté?  
 
Ciao  
Andy

mood
Publicité
Posté le 09-02-2009 à 11:16:19  profilanswer
 

n°1848868
Joel F
Real men use unique_ptr
Posté le 09-02-2009 à 12:54:45  profilanswer
 

Bah en vrac : va certainement déjà commencé par une modélisation objet de ton truc.
 
Dans ton jeu, tu as 2 niveaux : la visualisation et le modèle interne de l'état de la partie. En gros, quelles sont les entités qui rentrent en jeu pr l'affichage et pr le jeu en lui même. Certaine existeront dans les deux (les pièces par exemple) mais auront des comportements potentiellement différent. Il est bon de voir à découpler évolution du jeu et affichage en outre.
 
Après, comme toute appli interactive, va falloir prendre en compte le temps qui passe et le caractère asynchrone des interactions avec le joueur.  
 
Quand cette réflexion sera mené, on avisera pour le code :o

n°1848904
smallmadtv
tain t'es la toi !!!
Posté le 09-02-2009 à 13:39:08  profilanswer
 

Mmmm, intéressant...
 
Ton approche a un nom? C'est issu d'une théorie quelconque?  
 
Je dois dire que j'ai déjà programmé en Basic/Fortran/VBA/VB et meme assembleur. Mais les programmes étaient simples...  
 
le code ne me fait pas vraiment peur.
 
C'est plus dans la structuration... que se soit pour Tetris ou pour autre chose...
 
++  
 


---------------
Un Mars par jour en forme toujours
n°1848929
Joel F
Real men use unique_ptr
Posté le 09-02-2009 à 14:00:54  profilanswer
 

bah UML quoi :E

n°1849155
youen
Posté le 09-02-2009 à 21:43:16  profilanswer
 

Tu débutes en C++ ou en programmation en général ? Si tu débutes en programmation en général, je te conseillerais plutôt de commencer par essayer de trouver comment résoudre les problèmes bas niveau (comme dit Joel F, affichage des pièces, récupérer les actions du joueur, gérer l'écoulement du temps, etc.) avant de penser à la structure haut niveau du jeu.
 
Peut-être essayer déjà d'afficher une pièce du jeu, puis quand ça marche, la faire se déplacer à droite ou à gauche avec le clavier, et quand ça marche, tu pourra penser à la logique du jeu en lui même (collision des pièces, détection des lignes pleines, faire descendre le tout quand tu fais une ligne, etc.).
 
Il faudra que tu choisisses les technologies à utiliser pour faire tout ça (SDL, DirectX, ou que sais-je).
 
L'idée serait de savoir déjà a peu près comment tu va pouvoir faire chaque élément du jeu avant de penser à les mettre ensemble (je ne dis pas du tout que ce n'est pas important, au contraire, mais simplement que tu ne pourra pas concevoir l'architecture générale du programme si tu n'as aucune idée du fonctionnement de chaque élément de l'ensemble).

n°1849217
tomsoft
Posté le 09-02-2009 à 23:32:54  profilanswer
 

j'ose meme pas balancer le code du tetris que j'ai codé l'an dernier avant d'apprendre la POO,  
 
avec glut,  
 
c'est assez immonde, mais juste pour le plaisir :
 

Code :
  1. // Tetris en OpenGL
  2. // dev par tomas, 12/2007
  3. #include <GL/glut.h>
  4. #include <iostream>
  5. #include <sstream>
  6. #include <math.h>
  7. using namespace std;
  8. #define COLS 10
  9. #define ROWS 19
  10. #define BLOCKSIZE 0.1
  11. #define OFFSET 0.01
  12. #define FALLSPEED 1
  13. int ** gameArray;
  14. int ** movingParts;
  15. int nxtPiece;
  16. int score(0);
  17. bool gameState(true);
  18. int speed(1000);
  19. int nxtLevel(0);
  20. bool mirror(false);
  21. void initGameArray();
  22. void initMovingParts();
  23. void affichage();
  24. void clavier(unsigned char touche,int x,int y);
  25. GLvoid fall(int val);
  26. void moveDownMovingParts();
  27. bool isMoveableDown(int x, int y);
  28. void moveLRMovingParts(char touche);
  29. bool isMoveableLR(char touche, int x, int y);
  30. void rotateMovingParts();
  31. int determinePivot();
  32. bool isBlockFree(int x, int y);
  33. int chooseNewPiece();
  34. bool initNewPiece();
  35. bool isGameOver();
  36. void drawContainer();
  37. void drawNxtPiece();
  38. void scanRows();
  39. void removeRow(int inxdRow);
  40. void afficheStr(const string &chaine, void* font, float x, float y);
  41. string makeStrScore();
  42. void pauseGame();
  43. typedef struct {
  44. float x; float y; float r; float g; float b;
  45. } block;
  46. typedef struct {
  47. float r; float g; float b;
  48. } color;
  49. color colorsBlock[8] = {
  50. {0.0, 0.0, 0.0},{0.0, 0.0, 1.0},{0.0, 1.0, 0.0},{0.0, 1.0, 1.0},
  51. {1.0, 0.0, 0.0},{1.0, 0.0, 1.0},{1.0, 1.0, 0.0},{1.0, 1.0, 1.0}
  52. };
  53. int main(int argc,char **argv){
  54. initGameArray();
  55. initMovingParts();
  56. glutInit(&argc,argv);
  57. glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
  58. glutInitWindowPosition(0,0);
  59. glutInitWindowSize(400,400);
  60. glutCreateWindow("TetrisCore v0.01" );
  61. glClearColor(0.0,0.0,0.0,0.0);
  62. glColor3f(1.0,1.0,1.0);
  63. glPointSize(2.0);
  64. glutDisplayFunc(affichage);
  65. glutKeyboardFunc(clavier);
  66. glutTimerFunc(speed, fall, 10);
  67. glutMainLoop();
  68. return 0;
  69. }
  70. void initGameArray(){
  71. gameArray = new int * [ROWS];
  72. for (int i = 0; i < ROWS; i++)
  73.  gameArray[i] = new int[COLS];
  74. for (int i=0; i < ROWS; i++)
  75.  for (int j=0; j < COLS; j++)
  76.   gameArray[i][j] = 0;
  77. }
  78. void initMovingParts(){
  79. movingParts = new int * [4];
  80. for (int i = 0; i < 4; i++){
  81.  movingParts[i] = new int[3]; // x, y, indxClr
  82.  for (int j = 0; j < 3; j++)
  83.   movingParts[i][j] = -1;
  84. }
  85. chooseNewPiece();
  86. initNewPiece();
  87. }
  88. void affichage(){
  89. glClear(GL_COLOR_BUFFER_BIT);
  90. drawContainer();
  91. drawNxtPiece();
  92. string strScore = makeStrScore();
  93. afficheStr(strScore, GLUT_BITMAP_HELVETICA_18, 0.25, -0.9);
  94. float yf, xf;
  95. int i(0), j(0), iplus(1), stopi(ROWS), stopj(COLS), colorXY;
  96. if (mirror){
  97.  i = ROWS;
  98.  stopi = 0;
  99.  iplus = -1;
  100. }
  101. for (yf = -0.85 ; i < stopi; i+=iplus, yf+=0.1) {
  102.  for (j=0, xf = -0.85; j < COLS; j++, xf+=0.1) {
  103.   colorXY = gameArray[i][j];
  104.   for (int k = 0; k < 4; k++)
  105.    if (movingParts[k][0] == j && movingParts[k][1] == i)
  106.     colorXY = movingParts[k][2];
  107.   if (colorXY != 0){
  108.    glBegin(GL_POLYGON);
  109.    glColor3f(colorsBlock[colorXY].r,colorsBlock[colorXY].g,colorsBlock[colorXY].b);
  110.    glVertex2f(xf - BLOCKSIZE / 2 + OFFSET / 2, yf - BLOCKSIZE / 2 + OFFSET / 2);
  111.    glVertex2f(xf + BLOCKSIZE / 2 - OFFSET / 2, yf - BLOCKSIZE / 2 + OFFSET / 2);
  112.    glVertex2f(xf + BLOCKSIZE / 2 - OFFSET / 2, yf + BLOCKSIZE / 2 - OFFSET / 2);
  113.    glVertex2f(xf - BLOCKSIZE / 2 + OFFSET / 2, yf + BLOCKSIZE / 2 - OFFSET / 2);
  114.    glEnd();
  115.   }
  116.  }
  117. }
  118. glutSwapBuffers();
  119. glFlush();
  120. }
  121. void clavier(unsigned char touche,int x,int y){
  122. switch (touche){
  123.  case 'p':
  124.   pauseGame();
  125.  case 's':
  126.   moveDownMovingParts();
  127.   glutPostRedisplay();
  128.   break;
  129.  case 'a' : case 'd' :
  130.   moveLRMovingParts(touche);
  131.   glutPostRedisplay();
  132.   break;
  133.  case 'w' :
  134.   rotateMovingParts();
  135.   glutPostRedisplay();
  136.   break;
  137.  case 'm' :
  138.   mirror = !mirror;
  139.   glutPostRedisplay();
  140. }
  141. }
  142. void drawContainer(){
  143. glBegin(GL_LINE);
  144. glColor3f(1.0, 1.0, 1.0);
  145. glVertex2f(-0.95, -0.95);
  146. glVertex2f(-0.95, 0.75);
  147. glVertex2f(0.15, -0.95);
  148. glVertex2f(0.15, 0.75);
  149. glVertex2f(-0.95, -0.95);
  150. glVertex2f(0.15, -0.95);
  151. glEnd();
  152. }
  153. void drawNxtPiece(){
  154. int ** nxtPieceBlocks;
  155. nxtPieceBlocks = new int * [4];
  156. for (int i = 0; i < 4; i++){
  157.  nxtPieceBlocks[i] = new int[3]; // x, y, indxClr
  158.  for (int j = 0; j < 3; j++)
  159.   nxtPieceBlocks[i][j] = -1;
  160. }
  161. switch (nxtPiece){
  162.  case 0 :
  163.   nxtPieceBlocks[0][0] = 5; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 4;
  164.   nxtPieceBlocks[1][0] = 5; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 4;
  165.   nxtPieceBlocks[2][0] = 5; nxtPieceBlocks[2][1] = ROWS-3; nxtPieceBlocks[2][2] = 4;
  166.   nxtPieceBlocks[3][0] = 5; nxtPieceBlocks[3][1] = ROWS-4; nxtPieceBlocks[3][2] = 4;
  167.   break;
  168.  case 1 :
  169.   nxtPieceBlocks[0][0] = 5; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 2;
  170.   nxtPieceBlocks[1][0] = 5; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 2;
  171.   nxtPieceBlocks[2][0] = 6; nxtPieceBlocks[2][1] = ROWS-1; nxtPieceBlocks[2][2] = 2;
  172.   nxtPieceBlocks[3][0] = 6; nxtPieceBlocks[3][1] = ROWS-2; nxtPieceBlocks[3][2] = 2;
  173.   break;
  174.  case 2 :
  175.   nxtPieceBlocks[0][0] = 5; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 6;
  176.   nxtPieceBlocks[1][0] = 5; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 6;
  177.   nxtPieceBlocks[2][0] = 6; nxtPieceBlocks[2][1] = ROWS-2; nxtPieceBlocks[2][2] = 6;
  178.   nxtPieceBlocks[3][0] = 6; nxtPieceBlocks[3][1] = ROWS-3; nxtPieceBlocks[3][2] = 6;
  179.   break;
  180.  case 3 :
  181.   nxtPieceBlocks[0][0] = 6; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 3;
  182.   nxtPieceBlocks[1][0] = 6; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 3;
  183.   nxtPieceBlocks[2][0] = 5; nxtPieceBlocks[2][1] = ROWS-2; nxtPieceBlocks[2][2] = 3;
  184.   nxtPieceBlocks[3][0] = 5; nxtPieceBlocks[3][1] = ROWS-3; nxtPieceBlocks[3][2] = 3;
  185.   break;
  186.  case 4 :
  187.   nxtPieceBlocks[0][0] = 5; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 7;
  188.   nxtPieceBlocks[1][0] = 5; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 7;
  189.   nxtPieceBlocks[2][0] = 5; nxtPieceBlocks[2][1] = ROWS-3; nxtPieceBlocks[2][2] = 7;
  190.   nxtPieceBlocks[3][0] = 6; nxtPieceBlocks[3][1] = ROWS-3; nxtPieceBlocks[3][2] = 7;
  191.   break;
  192.  case 5 :
  193.   nxtPieceBlocks[0][0] = 6; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 5;
  194.   nxtPieceBlocks[1][0] = 6; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 5;
  195.   nxtPieceBlocks[2][0] = 6; nxtPieceBlocks[2][1] = ROWS-3; nxtPieceBlocks[2][2] = 5;
  196.   nxtPieceBlocks[3][0] = 5; nxtPieceBlocks[3][1] = ROWS-3; nxtPieceBlocks[3][2] = 5;
  197.   break;
  198.  case 6 :
  199.   nxtPieceBlocks[0][0] = 5; nxtPieceBlocks[0][1] = ROWS-1; nxtPieceBlocks[0][2] = 1;
  200.   nxtPieceBlocks[1][0] = 5; nxtPieceBlocks[1][1] = ROWS-2; nxtPieceBlocks[1][2] = 1;
  201.   nxtPieceBlocks[2][0] = 5; nxtPieceBlocks[2][1] = ROWS-3; nxtPieceBlocks[2][2] = 1;
  202.   nxtPieceBlocks[3][0] = 6; nxtPieceBlocks[3][1] = ROWS-2; nxtPieceBlocks[3][2] = 1;
  203.   break;
  204. }
  205. float yf, xf;
  206. int i, j, colorXY;
  207. for (i = ROWS-4, yf = -0.65 ; i < ROWS; i++, yf+=0.1) {
  208.  for (j = 5, xf = 0.55; j < 7; j++, xf+=0.1) {
  209.   colorXY = 0;
  210.   for (int k = 0; k < 4; k++)
  211.    if (nxtPieceBlocks[k][0] == j && nxtPieceBlocks[k][1] == i)
  212.     colorXY = nxtPieceBlocks[k][2];
  213.   if (colorXY != 0){
  214.    glBegin(GL_POLYGON);
  215.    glColor3f(colorsBlock[colorXY].r,colorsBlock[colorXY].g,colorsBlock[colorXY].b);
  216.    glVertex2f(xf - BLOCKSIZE / 2 + OFFSET / 2, yf - BLOCKSIZE / 2 + OFFSET / 2);
  217.    glVertex2f(xf + BLOCKSIZE / 2 - OFFSET / 2, yf - BLOCKSIZE / 2 + OFFSET / 2);
  218.    glVertex2f(xf + BLOCKSIZE / 2 - OFFSET / 2, yf + BLOCKSIZE / 2 - OFFSET / 2);
  219.    glVertex2f(xf - BLOCKSIZE / 2 + OFFSET / 2, yf + BLOCKSIZE / 2 - OFFSET / 2);
  220.    glEnd();
  221.   }
  222.  }
  223. }
  224. }
  225. void moveDownMovingParts(){
  226. bool canMoveDown (true);
  227. for (int i = 0; i < 4; i++){
  228.  canMoveDown = isMoveableDown(movingParts[i][0],movingParts[i][1]);
  229.  if (!canMoveDown){
  230.   scanRows();
  231.   break;
  232.  }
  233. }
  234. if (canMoveDown)
  235.  for (int i = 0; i < 4; i++)
  236.   movingParts[i][1]--;
  237. }
  238. bool isMoveableDown(int x, int y){
  239. if (y-1 < 0 || gameArray[y-1][x] != 0){
  240.  for (int i = 0; i < 4; i++){
  241.   gameArray[movingParts[i][1]][movingParts[i][0]] = movingParts[i][2];
  242.  }
  243.  initNewPiece();
  244.  return false;
  245. }
  246. return true;
  247. }
  248. void moveLRMovingParts(char touche){
  249. bool canMoveLR (true);
  250. for (int i = 0; i < 4; i++){
  251.  canMoveLR = isMoveableLR(touche,movingParts[i][0],movingParts[i][1]);
  252.  if (!canMoveLR)
  253.   break;
  254. }
  255. if (canMoveLR)
  256.  for (int i = 0; i < 4; i++){
  257.   if (touche == 'a')
  258.    movingParts[i][0]--;
  259.   else
  260.    movingParts[i][0]++;
  261.  }
  262. }
  263. bool isMoveableLR(char touche, int x, int y){
  264. if (touche == 'a'){
  265.  if (x-1 < 0  || gameArray[y][x-1] != 0)
  266.   return false;
  267. }
  268. else {
  269.  if (x+1 > COLS-1  || gameArray[y][x+1] != 0)
  270.   return false;
  271. }
  272. return true;
  273. }
  274. void rotateMovingParts(){
  275. int indxPivot = determinePivot();
  276. bool isOk = true;
  277. for (int i = 0; i < 4; i++){
  278.  if (i == indxPivot)
  279.   continue;
  280.  int x = movingParts[indxPivot][0] - ( movingParts[i][1] - movingParts[indxPivot][1] );
  281.  int y = movingParts[indxPivot][1] + ( movingParts[i][0] - movingParts[indxPivot][0] );
  282.  isOk = isBlockFree(x,y);
  283.  if (!isOk)
  284.   break;
  285. }
  286. if (isOk){
  287.  for (int i = 0; i < 4; i++){
  288.   if (i == indxPivot)
  289.    continue;
  290.   int x = movingParts[indxPivot][0] - ( movingParts[i][1] - movingParts[indxPivot][1] );
  291.   int y = movingParts[indxPivot][1] + ( movingParts[i][0] - movingParts[indxPivot][0] );
  292.   movingParts[i][0] = x;
  293.   movingParts[i][1] = y;
  294.  }
  295. }
  296. }
  297. int determinePivot(){
  298. float x(0);
  299. float y(0);
  300. for (int i = 0; i < 4; i++){
  301.  x += movingParts[i][0];
  302.  y += movingParts[i][1];
  303. }
  304. x = static_cast<int> (round(x/4));
  305. y = static_cast<int> (round(y/4));
  306. for (int i = 0; i < 4; i++)
  307.  if (movingParts[i][0] == x && movingParts[i][1] == y)
  308.   return i;
  309. }
  310. bool isBlockFree(int x, int y){
  311. if (y < 0 || x < 0 || x > COLS-1 || gameArray[y][x] != 0)
  312.  return false;
  313. return true;
  314. }
  315. bool isGameOver(){
  316. bool gameOver = false;
  317. for (int i = 0; i < COLS; i++){
  318.  if (gameArray[ROWS-5][i] != 0){
  319.   gameOver = true;
  320.   break;
  321.  }
  322. }
  323. return gameOver;
  324. }
  325. GLvoid fall(int value){
  326. moveDownMovingParts();
  327. glutPostRedisplay();
  328. glutTimerFunc(speed, fall, 10);
  329. }
  330. void scanRows(){
  331. bool isComplete;
  332. int nb_removed(0);
  333. for (int i = 0; i < ROWS; i++){
  334.  isComplete = true;
  335.  for (int j = 0; j < COLS; j++)
  336.   if (gameArray[i][j] == 0){
  337.    isComplete = false;
  338.    break;
  339.   }
  340.  if (isComplete){
  341.   removeRow(i);
  342.   nb_removed++;
  343.   nxtLevel += nb_removed;
  344.   i--;
  345.   if (nxtLevel >= 10){
  346.    speed -= 100;
  347.    nxtLevel -= 10;
  348.   }
  349.  }
  350. }
  351. score += 100 * nb_removed * nb_removed;
  352. }
  353. void removeRow(int indxRow){
  354. for (int i = indxRow; i < ROWS-1; i++)
  355.  for (int j = 0; j < COLS; j++)
  356.   gameArray[i][j] = gameArray[i+1][j];
  357. }
  358. int chooseNewPiece(){
  359. srand(time(NULL));
  360. nxtPiece = rand() % 7;
  361. }
  362. bool initNewPiece(){
  363. if (isGameOver())
  364.  return false;
  365. switch (nxtPiece){
  366.  case 0 :
  367.   movingParts[0][0] = 5; movingParts[0][1] = ROWS-1; movingParts[0][2] = 4;
  368.   movingParts[1][0] = 5; movingParts[1][1] = ROWS-2; movingParts[1][2] = 4;
  369.   movingParts[2][0] = 5; movingParts[2][1] = ROWS-3; movingParts[2][2] = 4;
  370.   movingParts[3][0] = 5; movingParts[3][1] = ROWS-4; movingParts[3][2] = 4;
  371.   break;
  372.  case 1 :
  373.   movingParts[0][0] = 5; movingParts[0][1] = ROWS-1; movingParts[0][2] = 2;
  374.   movingParts[1][0] = 5; movingParts[1][1] = ROWS-2; movingParts[1][2] = 2;
  375.   movingParts[2][0] = 6; movingParts[2][1] = ROWS-1; movingParts[2][2] = 2;
  376.   movingParts[3][0] = 6; movingParts[3][1] = ROWS-2; movingParts[3][2] = 2;
  377.   break;
  378.  case 2 :
  379.   movingParts[0][0] = 5; movingParts[0][1] = ROWS-1; movingParts[0][2] = 6;
  380.   movingParts[1][0] = 5; movingParts[1][1] = ROWS-2; movingParts[1][2] = 6;
  381.   movingParts[2][0] = 6; movingParts[2][1] = ROWS-2; movingParts[2][2] = 6;
  382.   movingParts[3][0] = 6; movingParts[3][1] = ROWS-3; movingParts[3][2] = 6;
  383.   break;
  384.  case 3 :
  385.   movingParts[0][0] = 6; movingParts[0][1] = ROWS-1; movingParts[0][2] = 3;
  386.   movingParts[1][0] = 6; movingParts[1][1] = ROWS-2; movingParts[1][2] = 3;
  387.   movingParts[2][0] = 5; movingParts[2][1] = ROWS-2; movingParts[2][2] = 3;
  388.   movingParts[3][0] = 5; movingParts[3][1] = ROWS-3; movingParts[3][2] = 3;
  389.   break;
  390.  case 4 :
  391.   movingParts[0][0] = 5; movingParts[0][1] = ROWS-1; movingParts[0][2] = 7;
  392.   movingParts[1][0] = 5; movingParts[1][1] = ROWS-2; movingParts[1][2] = 7;
  393.   movingParts[2][0] = 5; movingParts[2][1] = ROWS-3; movingParts[2][2] = 7;
  394.   movingParts[3][0] = 6; movingParts[3][1] = ROWS-3; movingParts[3][2] = 7;
  395.   break;
  396.  case 5 :
  397.   movingParts[0][0] = 6; movingParts[0][1] = ROWS-1; movingParts[0][2] = 5;
  398.   movingParts[1][0] = 6; movingParts[1][1] = ROWS-2; movingParts[1][2] = 5;
  399.   movingParts[2][0] = 6; movingParts[2][1] = ROWS-3; movingParts[2][2] = 5;
  400.   movingParts[3][0] = 5; movingParts[3][1] = ROWS-3; movingParts[3][2] = 5;
  401.   break;
  402.  case 6 :
  403.   movingParts[0][0] = 5; movingParts[0][1] = ROWS-1; movingParts[0][2] = 1;
  404.   movingParts[1][0] = 5; movingParts[1][1] = ROWS-2; movingParts[1][2] = 1;
  405.   movingParts[2][0] = 5; movingParts[2][1] = ROWS-3; movingParts[2][2] = 1;
  406.   movingParts[3][0] = 6; movingParts[3][1] = ROWS-2; movingParts[3][2] = 1;
  407.   break;
  408. }
  409. chooseNewPiece();
  410. return true;
  411. }
  412. void afficheStr(const string &chaine, void* font, float x, float y){
  413. glDisable(GL_TEXTURE_2D);
  414. glDisable(GL_DEPTH_TEST);
  415. glRasterPos2f(x, y);
  416. glColor3f(1.,1.,1.);
  417. for (int i=0; i < chaine.length(); i++)
  418.  glutBitmapCharacter(font, chaine[i]);
  419. }
  420. string makeStrScore(){
  421. ostringstream oss;
  422. oss << "Score : " << score;
  423. return oss.str();
  424. }
  425. void pauseGame(){
  426. }


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  Tetris

 

Sujets relatifs
tétris en director[Algo] Algorithme d'un Tetris (et programmation)
mon tetris cherche les ennuisTetris en java
[topik unik regles du jeu tetris] today : répétition des mouvements[tetris] centres de rotation des pieces
!!!!!!JE CHERCHE DES SPRITES DE TETRIS OU D'UN CLONE !!!!!!!!!Help --> Besoin d'un Tetris en C++
Plus de sujets relatifs à : Tetris


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)