SlideShare a Scribd company logo
GLUTetris
An OpenGL clone of the popular game Tetris
Prof. Marco Schaerf
Dipartimento di Informatica e Sistemistica
Giovanni Murru
Master in AI and Robotics
Computer Graphics Course
The Tetris Game
 Created in 1984 by Alexey Pajitnov, a computer engineer, with the help
of Dmitry Pavlovsky and Vadim Gerasimov
 Goal of the game is to manipulate the tetrominoes moving sideways or
rotating them by 90 degrees, with the intention of creating one up to
four horizontal lines of blocks without gaps.
 When such lines are created they disappear.
 When four lines are contemporary created, a Tetris score is done.
 The tetrominoes became part of the wall when they fall in the wall or in
the down edge of the game board.
 When the wall reaches the top of the game field, the game is over.
The Tetromino
 Tetromino is composed by 4 blocks in different
configurations.
 They are identified with letters.
 Left to right: I,J,L,O,S,T,Z
Binary Identification
 Tetrominoes are identified with binary matrices.
 28 4-by-4 binary matrices
 7 types of tetrominoes * 4 possible orientations
 Element of the matrix is:
 1 if occupied by one block,
 0 otherwise
 E.g.
The Collision Problem (1/2)
 The wall is a binary matrix of 20-by-10 elements with
the same notation used to represent tetrominoes
 A collision between the tetromino and the wall is
detected using an algorithm that checks the presence of
conflict in the same cell.
 i.e. a 1 value is present in the wall matrix at the relative
positions of the element occupied by a 1 in the tetromino
matrix.
 First-Act-Then-Confirm-Or-Refuse approach
 Virtual Movement -> Check -> Restore or Commit
The Collision Problem (2/2)
 An algorithm that checks if the tetromino is going
outside the game board limits or if it is in contact with
the wall with respect to the down movement.
 Two different behaviors when the Tetromino hits the
wall:
 CASE 1: Tetromino hits the wall during down movement, then
act making the tetromino part of the wall.
 CASE 2: Tetromino hits the wall during the left, right, or
rotation movement, then act denying the movement.
Level, Scores, and Lines
 The level number and the game speed are concurrently
increased each 10 cleared lines.
 The score has been assigned according to the Nintendo
scoring system, which gives a reward proportional to:
 Actual level
 Number of Lines contemporary deleted
Level Points for
1 Line
Points for
2 Lines
Points for
3 Lines
Points for
Tetris
N 40*N 100*N 300*N 1200*N
OpenGL Layer
 GLUT toolkit has been used.
 3d environment, although tetrominoes are constrained to
move in a vertical plane.
 Light
 Textures
 Anti-aliasing
 Blending
 Hierarchical objects
The Lights
 Light as a sum of different contributes:
 Ambient
 Diffuse and Specular Reflection
 Emission
 3 lights:
 LIGHT0: soft ambient light
 LIGHT1: left spotlight
 LIGHT2: right spotlight
 All the lights have a white neutral color.
 Blending and Anti-Aliasing are activated
Textures
 The textures are mapped in the tetrominoes and a spherical
sky.
 Tetrominoes are composed by four cubes, and the same
texture is applied to each side of the cube.
 Textures in the cube are applied so that the resulting output
is a mix between the original color of the cube and the
texture.
 GL_LINEAR used for both minification and magnification,
MIPMAP is disabled
 The sky is a flipped image applied to the surface of a sphere.
Hierarchy (1/3)
 The hierarchy is used in the animation that occurs when the
player makes a Tetris score, namely when he simultaneously
deletes 4 lines.
 Animation that makes the game board, including tetrominoes
and wall rotate of 180 degrees wrt the up axis, while the next
tetromino is rotating wrt the horizontal axis and the current
tetromino is translating with the rest of the wall but faster,
outside the field of view.
 The animation consist in a gameboard rotating while
tetrominoes and wall are fading because of the translation
movement.
Hierarchy (2/3)
Application
Game
Game Field
Wall
Current
Tetromino
Next
Tetromino
Sky
Hierarchy (3/3)
glPushMatrix();
//rotates the entire scene
glRotatef(angle_of_scene_rot, 0, 1, 0);
//draws the game field
this->dobj->drawCampo();
glPushMatrix();
//translates the wall an the tetrominoes to obtain a fade effect
glTranslatef(0, 0, effetto_scomparsa);
//draws the wall
this->dobj->drawWall(this->w);
glPushMatrix();
//translate the current tetromino so that it fades faster
glTranslatef(effetto_scomparsa_tetromino,0,0);
if(!this->game_over)
this->dobj->drawTetromino(this->t);
glPopMatrix();
glPushMatrix();
//rotates the next tetromino
glRotatef(effetto_rot_next_tetro, 1, 0, 0);
this->dobj->drawNextTetromino(this->next_t);
glPopMatrix();
glPopMatrix();
glPopMatrix();
Sounds
 Use of OpenAL library, a 3D cross platform audio API.
 Three themes songs:
 Original Nintendo Themes
 Sound when Game is Over
 Sound goes in pause when the game is put in pause.
 Sound is stopped when M is pressed
The End…

More Related Content

Viewers also liked

Passive Optical Networks: The MAC protocols
Passive Optical Networks: The MAC protocolsPassive Optical Networks: The MAC protocols
Passive Optical Networks: The MAC protocols
Giovanni Murru
 
Task Constrained Motion Planning for Snake Robot
Task Constrained Motion Planning for Snake RobotTask Constrained Motion Planning for Snake Robot
Task Constrained Motion Planning for Snake Robot
Giovanni Murru
 
About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...
About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...
About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...
Giovanni Murru
 
Structure and Motion - 3D Reconstruction of Cameras and Structure
Structure and Motion - 3D Reconstruction of Cameras and StructureStructure and Motion - 3D Reconstruction of Cameras and Structure
Structure and Motion - 3D Reconstruction of Cameras and Structure
Giovanni Murru
 
Construct 2: Exporting & Publishing to Web, Win8 and WP8
Construct 2: Exporting & Publishing to Web, Win8 and WP8Construct 2: Exporting & Publishing to Web, Win8 and WP8
Construct 2: Exporting & Publishing to Web, Win8 and WP8
Shahed Chowdhuri
 
โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์Tanapong Chaisri
 
Estudioclima1
Estudioclima1Estudioclima1
Estudioclima1
Alex Pinzon
 
histeresis
histeresishisteresis
histeresis
Topo Topeins
 
ใบงานที่10
ใบงานที่10 ใบงานที่10
ใบงานที่10 Tanapong Chaisri
 
Performance agency
Performance agencyPerformance agency
Performance agency
CubeLine Agency
 
3 musical instrument
3 musical instrument3 musical instrument
3 musical instrument
Jhastine Cristy Mahinay
 
Redes semanticas
Redes semanticasRedes semanticas
Redes semanticas
Andy Joao Lmb
 
ใบงานที่11
ใบงานที่11 ใบงานที่11
ใบงานที่11 Tanapong Chaisri
 
Анализ рекламных кампаний для E-commerce. Точки роста, повышение эффективности
Анализ рекламных кампаний для E-commerce. Точки роста, повышение эффективностиАнализ рекламных кампаний для E-commerce. Точки роста, повышение эффективности
Анализ рекламных кампаний для E-commerce. Точки роста, повышение эффективности
CubeLine Agency
 
Диспетчер тегов Google. Меньше затрат, больше контроля.
Диспетчер тегов Google. Меньше затрат, больше контроля.Диспетчер тегов Google. Меньше затрат, больше контроля.
Диспетчер тегов Google. Меньше затрат, больше контроля.
CubeLine Agency
 
Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"
Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"
Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"
CubeLine Agency
 

Viewers also liked (16)

Passive Optical Networks: The MAC protocols
Passive Optical Networks: The MAC protocolsPassive Optical Networks: The MAC protocols
Passive Optical Networks: The MAC protocols
 
Task Constrained Motion Planning for Snake Robot
Task Constrained Motion Planning for Snake RobotTask Constrained Motion Planning for Snake Robot
Task Constrained Motion Planning for Snake Robot
 
About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...
About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...
About the paper: Graph Connectivity Measures for Unsupervised Word Sense Disa...
 
Structure and Motion - 3D Reconstruction of Cameras and Structure
Structure and Motion - 3D Reconstruction of Cameras and StructureStructure and Motion - 3D Reconstruction of Cameras and Structure
Structure and Motion - 3D Reconstruction of Cameras and Structure
 
Construct 2: Exporting & Publishing to Web, Win8 and WP8
Construct 2: Exporting & Publishing to Web, Win8 and WP8Construct 2: Exporting & Publishing to Web, Win8 and WP8
Construct 2: Exporting & Publishing to Web, Win8 and WP8
 
โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์
 
Estudioclima1
Estudioclima1Estudioclima1
Estudioclima1
 
histeresis
histeresishisteresis
histeresis
 
ใบงานที่10
ใบงานที่10 ใบงานที่10
ใบงานที่10
 
Performance agency
Performance agencyPerformance agency
Performance agency
 
3 musical instrument
3 musical instrument3 musical instrument
3 musical instrument
 
Redes semanticas
Redes semanticasRedes semanticas
Redes semanticas
 
ใบงานที่11
ใบงานที่11 ใบงานที่11
ใบงานที่11
 
Анализ рекламных кампаний для E-commerce. Точки роста, повышение эффективности
Анализ рекламных кампаний для E-commerce. Точки роста, повышение эффективностиАнализ рекламных кампаний для E-commerce. Точки роста, повышение эффективности
Анализ рекламных кампаний для E-commerce. Точки роста, повышение эффективности
 
Диспетчер тегов Google. Меньше затрат, больше контроля.
Диспетчер тегов Google. Меньше затрат, больше контроля.Диспетчер тегов Google. Меньше затрат, больше контроля.
Диспетчер тегов Google. Меньше затрат, больше контроля.
 
Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"
Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"
Анатолий Соболев. Веб-аналитика. "Анализируй ЭТО"
 

Recently uploaded

CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 

Recently uploaded (20)

CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 

GLUTetris

  • 1. GLUTetris An OpenGL clone of the popular game Tetris Prof. Marco Schaerf Dipartimento di Informatica e Sistemistica Giovanni Murru Master in AI and Robotics Computer Graphics Course
  • 2. The Tetris Game  Created in 1984 by Alexey Pajitnov, a computer engineer, with the help of Dmitry Pavlovsky and Vadim Gerasimov  Goal of the game is to manipulate the tetrominoes moving sideways or rotating them by 90 degrees, with the intention of creating one up to four horizontal lines of blocks without gaps.  When such lines are created they disappear.  When four lines are contemporary created, a Tetris score is done.  The tetrominoes became part of the wall when they fall in the wall or in the down edge of the game board.  When the wall reaches the top of the game field, the game is over.
  • 3. The Tetromino  Tetromino is composed by 4 blocks in different configurations.  They are identified with letters.  Left to right: I,J,L,O,S,T,Z
  • 4. Binary Identification  Tetrominoes are identified with binary matrices.  28 4-by-4 binary matrices  7 types of tetrominoes * 4 possible orientations  Element of the matrix is:  1 if occupied by one block,  0 otherwise  E.g.
  • 5. The Collision Problem (1/2)  The wall is a binary matrix of 20-by-10 elements with the same notation used to represent tetrominoes  A collision between the tetromino and the wall is detected using an algorithm that checks the presence of conflict in the same cell.  i.e. a 1 value is present in the wall matrix at the relative positions of the element occupied by a 1 in the tetromino matrix.  First-Act-Then-Confirm-Or-Refuse approach  Virtual Movement -> Check -> Restore or Commit
  • 6. The Collision Problem (2/2)  An algorithm that checks if the tetromino is going outside the game board limits or if it is in contact with the wall with respect to the down movement.  Two different behaviors when the Tetromino hits the wall:  CASE 1: Tetromino hits the wall during down movement, then act making the tetromino part of the wall.  CASE 2: Tetromino hits the wall during the left, right, or rotation movement, then act denying the movement.
  • 7. Level, Scores, and Lines  The level number and the game speed are concurrently increased each 10 cleared lines.  The score has been assigned according to the Nintendo scoring system, which gives a reward proportional to:  Actual level  Number of Lines contemporary deleted Level Points for 1 Line Points for 2 Lines Points for 3 Lines Points for Tetris N 40*N 100*N 300*N 1200*N
  • 8. OpenGL Layer  GLUT toolkit has been used.  3d environment, although tetrominoes are constrained to move in a vertical plane.  Light  Textures  Anti-aliasing  Blending  Hierarchical objects
  • 9. The Lights  Light as a sum of different contributes:  Ambient  Diffuse and Specular Reflection  Emission  3 lights:  LIGHT0: soft ambient light  LIGHT1: left spotlight  LIGHT2: right spotlight  All the lights have a white neutral color.  Blending and Anti-Aliasing are activated
  • 10. Textures  The textures are mapped in the tetrominoes and a spherical sky.  Tetrominoes are composed by four cubes, and the same texture is applied to each side of the cube.  Textures in the cube are applied so that the resulting output is a mix between the original color of the cube and the texture.  GL_LINEAR used for both minification and magnification, MIPMAP is disabled  The sky is a flipped image applied to the surface of a sphere.
  • 11. Hierarchy (1/3)  The hierarchy is used in the animation that occurs when the player makes a Tetris score, namely when he simultaneously deletes 4 lines.  Animation that makes the game board, including tetrominoes and wall rotate of 180 degrees wrt the up axis, while the next tetromino is rotating wrt the horizontal axis and the current tetromino is translating with the rest of the wall but faster, outside the field of view.  The animation consist in a gameboard rotating while tetrominoes and wall are fading because of the translation movement.
  • 13. Hierarchy (3/3) glPushMatrix(); //rotates the entire scene glRotatef(angle_of_scene_rot, 0, 1, 0); //draws the game field this->dobj->drawCampo(); glPushMatrix(); //translates the wall an the tetrominoes to obtain a fade effect glTranslatef(0, 0, effetto_scomparsa); //draws the wall this->dobj->drawWall(this->w); glPushMatrix(); //translate the current tetromino so that it fades faster glTranslatef(effetto_scomparsa_tetromino,0,0); if(!this->game_over) this->dobj->drawTetromino(this->t); glPopMatrix(); glPushMatrix(); //rotates the next tetromino glRotatef(effetto_rot_next_tetro, 1, 0, 0); this->dobj->drawNextTetromino(this->next_t); glPopMatrix(); glPopMatrix(); glPopMatrix();
  • 14. Sounds  Use of OpenAL library, a 3D cross platform audio API.  Three themes songs:  Original Nintendo Themes  Sound when Game is Over  Sound goes in pause when the game is put in pause.  Sound is stopped when M is pressed