SlideShare uma empresa Scribd logo
1 de 10
NewTetrisScore.cppNewTetrisScore.cpp// newTetris.cpp : Defin
es the entry point for the console application.
//
#include"stdafx.h"
#include<stdlib.h>
#include<iostream>
#include<time.h>
#include<windows.h>
#define GAME_INTERVAL 20
#define DIR_DOWN 2
#define DIR_LEFT 4
#define DIR_RIGHT 6
#define DIR_ROTATE 5
usingnamespace std;
classTetrisShape{
public:
char shapeArray[4][4];
int shapeTopLeftX =6;
int shapeTopLeftY =0;
void populateShapeArray(int shape);
void rotate();
template<size_t rows, size_t cols>
void setShape(char(&shape)[rows][cols]);
TetrisShape(int shape){ populateShapeArray(shape);};
TetrisShape(){};
};
voidTetrisShape::rotate(){
char _shapeArray[4][4];
_shapeArray[0][0]= shapeArray[0][3]; _shapeArray[1][0]= sh
apeArray[0][2]; _shapeArray[2][0]= shapeArray[0][1]; _shapeA
rray[3][0]= shapeArray[0][0];
_shapeArray[0][1]= shapeArray[1][3]; _shapeArray[1][1]= sh
apeArray[1][2]; _shapeArray[2][1]= shapeArray[1][1]; _shapeA
rray[3][1]= shapeArray[1][0];
_shapeArray[0][2]= shapeArray[2][3]; _shapeArray[1][2]= sh
apeArray[2][2]; _shapeArray[2][2]= shapeArray[2][1]; _shapeA
rray[3][2]= shapeArray[2][0];
_shapeArray[0][3]= shapeArray[3][3]; _shapeArray[1][3]= sh
apeArray[3][2]; _shapeArray[2][3]= shapeArray[3][1]; _shapeA
rray[3][3]= shapeArray[3][0];
for(int _x =0; _x <4; _x++){
for(int _y =0; _y <4; _y++){
shapeArray[_x][_y]= _shapeArray[_x][_y];
}
}
}
voidTetrisShape::populateShapeArray(int shape){
switch(shape){
case1:
shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][
0]=' '; shapeArray[3][0]=' ';
shapeArray[0][1]=' '; shapeArray[1][1]='X'; shapeArray[2]
[1]=' '; shapeArray[3][1]=' ';
shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2]
[2]=' '; shapeArray[3][2]=' ';
shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2]
[3]='X'; shapeArray[3][3]=' ';
break;
case2:
shapeArray[0][0]=' '; shapeArray[1][0]='X'; shapeArray[2]
[0]=' '; shapeArray[3][0]=' ';
shapeArray[0][1]=' '; shapeArray[1][1]='X'; shapeArray[2]
[1]=' '; shapeArray[3][1]=' ';
shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2]
[2]=' '; shapeArray[3][2]=' ';
shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2]
[3]=' '; shapeArray[3][3]=' ';
break;
case3:
shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][
0]=' '; shapeArray[3][0]=' ';
shapeArray[0][1]=' '; shapeArray[1][1]='X'; shapeArray[2]
[1]=' '; shapeArray[3][1]=' ';
shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2]
[2]='X'; shapeArray[3][2]=' ';
shapeArray[0][3]=' '; shapeArray[1][3]=' '; shapeArray[2][
3]='X'; shapeArray[3][3]=' ';
break;
case4:
shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][
0]=' '; shapeArray[3][0]=' ';
shapeArray[0][1]=' '; shapeArray[1][1]=' '; shapeArray[2][
1]='X'; shapeArray[3][1]=' ';
shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2]
[2]='X'; shapeArray[3][2]=' ';
shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2]
[3]=' '; shapeArray[3][3]=' ';
break;
case5:
shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][
0]=' '; shapeArray[3][0]=' ';
shapeArray[0][1]=' '; shapeArray[1][1]=' '; shapeArray[2][
1]='X'; shapeArray[3][1]=' ';
shapeArray[0][2]=' '; shapeArray[1][2]=' '; shapeArray[2][
2]='X'; shapeArray[3][2]=' ';
shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2]
[3]='X'; shapeArray[3][3]=' ';
break;
case6:
shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][
0]=' '; shapeArray[3][0]=' ';
shapeArray[0][1]=' '; shapeArray[1][1]=' '; shapeArray[2][
1]=' '; shapeArray[3][1]=' ';
shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2]
[2]='X'; shapeArray[3][2]=' ';
shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2]
[3]='X'; shapeArray[3][3]=' ';
break;
}
}
int score =0;
int currentShape =-
1;// this is going to represent the shape that is currently in play.
bool isDropping =false;// global that defines if a piece is current
ly falling - mainly for gameTick function.
int currentTick =0;
template<size_t rows, size_t cols>
void generateBucket(char(&bucket)[rows][cols]);// Creates a sli
ghtly pre-filled bucket.
void generateShapeStream();// Generate a stream of shapes.
void dropShape();// Draw the shape top/center.
bool moveShape(int direction);// Move the shape in the spec. dir
.
template<size_t rows, size_t cols>
bool gameTick(char(&bucket)[rows][cols],char(&perm_bucket)[
rows][cols]);// Handles what is going on in the game every seco
nd.
template<size_t rows, size_t cols>
void landShape(char(&bucket)[rows][cols]);// What to do when
the shape hits the bottom.
template<size_t rows, size_t cols>
int checkScore(char(&bucket)[rows][cols],char(&perm_bucket)[
rows][cols],int tempvar,int score);
template<size_t rows, size_t cols>
void drawBucket(char(&bucket)[rows][cols]);// Draws the curre
nt contents of the bucket.
template<size_t rows, size_t cols>
bool canEnter(int direction,char(&bucket)[rows][cols]);// Check
s if the shape can enter the space it is trying to drop into.
int getUserInput();// gets the key pressed from the user.
void setCursorTo(int x,int y);// Move the cursor to the appropria
te position
int previousX =6, previousY =0;
int shapes[256];
template<size_t rows, size_t cols>
int check_bucket(char(&bucket)[rows][cols]);
template<size_t rows, size_t cols>
void set_bucket(char(&bucket)[rows][cols],char(&perm_bucket)
[rows][cols]);
TetrisShape activeShape;
int main(){
// Two bucket arrays, one shown on the screen, the other with th
e permanent contents of the buckets (walls and any non-
moving shapes)
char bucket[12][25];
int score =0;
int tempvar =0;
char _bucket[12][25];
int shapes[256]={};
int shapeIndex =0;
bool gameOver =false;
generateBucket(bucket);
generateBucket(_bucket);
generateShapeStream();
drawBucket(bucket);
while(!gameOver){
gameOver = gameTick(bucket, _bucket);
Sleep(50);
checkScore(bucket, _bucket, tempvar, score);
cout <<"Your Score is: "<< score << endl;
currentTick++;
}
setCursorTo(25,6);
cout <<"GAME OVER";
system("pause");
}
void setCursorTo(int x,int y)
{
HANDLE handle;
COORD position;
handle =GetStdHandle(STD_OUTPUT_HANDLE);
position.X = x;
position.Y = y;
SetConsoleCursorPosition(handle, position);
}
/* generateBucket - takes a bucket array of any size and
* creates a semi-empty bucket, with a
* few random shapes in the bottom few lines. */
template<size_t rows, size_t cols>
void generateBucket(char(&bucket)[rows][cols]){
for(int w =0; w <12; w++){
for(int z =0; z <25; z++){
if(((w ==0)||(w ==11))&&(z ==0)){ bucket[w][z]='.';}
elseif(((w %12==0)||(w %12==11))&&((z >0)&&(z <24))){ buc
ket[w][z]='|';}
elseif(((w ==0)||(w ==11))&&(z ==24)){ bucket[w][z]='+';}
elseif(z ==24){ bucket[w][z]='-';}
else{ bucket[w][z]=' ';}
}
}
}
/* generateShapeStream - generates a pre-determined list of
* shapes that will fall from the sky. */
void generateShapeStream(){
// Initialize the random number generator
srand(time(NULL));
for(int i =0; i <256; i++){
shapes[i]= rand()%6+1;
}
//cout << "In generate shape..." << endl;
}
/* drawBucket - draws the actual bucket on the screen
* including the currently dropping shape. */
template<size_t rows, size_t cols>
void drawBucket(char(&bucket)[rows][cols]){
setCursorTo(0,0);
for(int w =0; w <25; w++){
for(int z =0; z <12; z++){
cout << bucket[z][w];
}
cout << endl;
}
}
/* gameTick - this function does all of the different
* processessing that happens throughout
* the game. This also returns false to
* stop the main loop once gameover has
* been reached */
template<size_t rows, size_t cols>
bool gameTick(char(&bucket)[rows][cols],char(&perm_bucket)[
rows][cols]){
drawBucket(bucket);
if(!isDropping){
currentShape++;
activeShape =TetrisShape(shapes[currentShape]);
if(!canEnter(DIR_DOWN, perm_bucket)){
returntrue;
}
else{
isDropping =true;
updateBucket(bucket,false);
}
}
else{
if(currentTick % GAME_INTERVAL ==1){
// we are on a drop interval.
if(canEnter(DIR_DOWN, perm_bucket)){
updateBucket(bucket, moveShape(DIR_DOWN));
}
else{
landShape(perm_bucket);
}
}
}
int direction = getUserInput();
if(canEnter(direction, perm_bucket)){
updateBucket(bucket, moveShape(direction));
}
if(!canEnter(DIR_DOWN, perm_bucket)){
landShape(perm_bucket);
set_bucket(bucket, perm_bucket);
}
returnfalse;
}
/* moveShape - Handles moving the shape in the bucket. */
bool moveShape(int direction){
previousX = activeShape.shapeTopLeftX;
previousY = activeShape.shapeTopLeftY;
switch(direction){
case DIR_DOWN:
activeShape.shapeTopLeftY++;
returnfalse;
break;
case DIR_RIGHT:
activeShape.shapeTopLeftX++;
returnfalse;
break;
case DIR_LEFT:
activeShape.shapeTopLeftX--;
returnfalse;
break;
case DIR_ROTATE:
activeShape.rotate();
returntrue;
break;

Mais conteúdo relacionado

Semelhante a NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx

In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfanjandavid
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)SETYA HADI
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)SETYA HADI
 
Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScriptSam Cartwright
 
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon RunMaja Kraljič
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding classJonah Marrs
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervosoLuis Vendrame
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! aleks-f
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for SpeedYung-Yu Chen
 
import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfADITIEYEWEAR
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdfapleather
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns projectAayush Mittal
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns projectAayush Mittal
 
GameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdfGameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdfaravlitraders2012
 
I need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfI need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfallurafashions98
 

Semelhante a NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx (17)

In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)
 
Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScript
 
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding class
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdf
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
GameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdfGameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdf
 
I need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfI need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdf
 

Mais de curwenmichaela

BUS310ASSIGNMENTImagine that you work for a company with an ag.docx
BUS310ASSIGNMENTImagine that you work for a company with an ag.docxBUS310ASSIGNMENTImagine that you work for a company with an ag.docx
BUS310ASSIGNMENTImagine that you work for a company with an ag.docxcurwenmichaela
 
BUS357 Copyright © 2020 Singapore University of Social Science.docx
BUS357 Copyright © 2020 Singapore University of Social Science.docxBUS357 Copyright © 2020 Singapore University of Social Science.docx
BUS357 Copyright © 2020 Singapore University of Social Science.docxcurwenmichaela
 
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docxBUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docxcurwenmichaela
 
BUS308 – Week 5 Lecture 1 A Different View Expected Ou.docx
BUS308 – Week 5 Lecture 1 A Different View Expected Ou.docxBUS308 – Week 5 Lecture 1 A Different View Expected Ou.docx
BUS308 – Week 5 Lecture 1 A Different View Expected Ou.docxcurwenmichaela
 
BUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docx
BUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docxBUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docx
BUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docxcurwenmichaela
 
BUS308 Statistics for ManagersDiscussions To participate in .docx
BUS308 Statistics for ManagersDiscussions To participate in .docxBUS308 Statistics for ManagersDiscussions To participate in .docx
BUS308 Statistics for ManagersDiscussions To participate in .docxcurwenmichaela
 
BUS308 Week 4 Lecture 1 Examining Relationships Expect.docx
BUS308 Week 4 Lecture 1 Examining Relationships Expect.docxBUS308 Week 4 Lecture 1 Examining Relationships Expect.docx
BUS308 Week 4 Lecture 1 Examining Relationships Expect.docxcurwenmichaela
 
BUS225 Group Assignment1. Service BlueprintCustomer acti.docx
BUS225 Group Assignment1. Service BlueprintCustomer acti.docxBUS225 Group Assignment1. Service BlueprintCustomer acti.docx
BUS225 Group Assignment1. Service BlueprintCustomer acti.docxcurwenmichaela
 
BUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docx
BUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docxBUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docx
BUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docxcurwenmichaela
 
BUS1431Introduction and PreferencesBUS143 Judgmen.docx
BUS1431Introduction and PreferencesBUS143 Judgmen.docxBUS1431Introduction and PreferencesBUS143 Judgmen.docx
BUS1431Introduction and PreferencesBUS143 Judgmen.docxcurwenmichaela
 
BUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docx
BUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docxBUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docx
BUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docxcurwenmichaela
 
Bus101 quiz (Business Organizations)The due time is in 1hrs1 .docx
Bus101 quiz (Business Organizations)The due time is in 1hrs1 .docxBus101 quiz (Business Organizations)The due time is in 1hrs1 .docx
Bus101 quiz (Business Organizations)The due time is in 1hrs1 .docxcurwenmichaela
 
BUS 625 Week 4 Response to Discussion 2Guided Response Your.docx
BUS 625 Week 4 Response to Discussion 2Guided Response Your.docxBUS 625 Week 4 Response to Discussion 2Guided Response Your.docx
BUS 625 Week 4 Response to Discussion 2Guided Response Your.docxcurwenmichaela
 
BUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docx
BUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docxBUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docx
BUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docxcurwenmichaela
 
Bus 626 Week 6 - Discussion Forum 1Guided Response Respon.docx
Bus 626 Week 6 - Discussion Forum 1Guided Response Respon.docxBus 626 Week 6 - Discussion Forum 1Guided Response Respon.docx
Bus 626 Week 6 - Discussion Forum 1Guided Response Respon.docxcurwenmichaela
 
BUS 499, Week 8 Corporate Governance Slide #TopicNarration.docx
BUS 499, Week 8 Corporate Governance Slide #TopicNarration.docxBUS 499, Week 8 Corporate Governance Slide #TopicNarration.docx
BUS 499, Week 8 Corporate Governance Slide #TopicNarration.docxcurwenmichaela
 
BUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docx
BUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docxBUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docx
BUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docxcurwenmichaela
 
BUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docx
BUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docxBUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docx
BUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docxcurwenmichaela
 
BUS 437 Project Procurement Management Discussion QuestionsWe.docx
BUS 437 Project Procurement Management  Discussion QuestionsWe.docxBUS 437 Project Procurement Management  Discussion QuestionsWe.docx
BUS 437 Project Procurement Management Discussion QuestionsWe.docxcurwenmichaela
 
BUS 480.01HY Case Study Assignment Instructions .docx
BUS 480.01HY Case Study Assignment Instructions     .docxBUS 480.01HY Case Study Assignment Instructions     .docx
BUS 480.01HY Case Study Assignment Instructions .docxcurwenmichaela
 

Mais de curwenmichaela (20)

BUS310ASSIGNMENTImagine that you work for a company with an ag.docx
BUS310ASSIGNMENTImagine that you work for a company with an ag.docxBUS310ASSIGNMENTImagine that you work for a company with an ag.docx
BUS310ASSIGNMENTImagine that you work for a company with an ag.docx
 
BUS357 Copyright © 2020 Singapore University of Social Science.docx
BUS357 Copyright © 2020 Singapore University of Social Science.docxBUS357 Copyright © 2020 Singapore University of Social Science.docx
BUS357 Copyright © 2020 Singapore University of Social Science.docx
 
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docxBUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
BUS308 – Week 1 Lecture 2 Describing Data Expected Out.docx
 
BUS308 – Week 5 Lecture 1 A Different View Expected Ou.docx
BUS308 – Week 5 Lecture 1 A Different View Expected Ou.docxBUS308 – Week 5 Lecture 1 A Different View Expected Ou.docx
BUS308 – Week 5 Lecture 1 A Different View Expected Ou.docx
 
BUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docx
BUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docxBUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docx
BUS308 – Week 1 Lecture 1 Statistics Expected Outcomes.docx
 
BUS308 Statistics for ManagersDiscussions To participate in .docx
BUS308 Statistics for ManagersDiscussions To participate in .docxBUS308 Statistics for ManagersDiscussions To participate in .docx
BUS308 Statistics for ManagersDiscussions To participate in .docx
 
BUS308 Week 4 Lecture 1 Examining Relationships Expect.docx
BUS308 Week 4 Lecture 1 Examining Relationships Expect.docxBUS308 Week 4 Lecture 1 Examining Relationships Expect.docx
BUS308 Week 4 Lecture 1 Examining Relationships Expect.docx
 
BUS225 Group Assignment1. Service BlueprintCustomer acti.docx
BUS225 Group Assignment1. Service BlueprintCustomer acti.docxBUS225 Group Assignment1. Service BlueprintCustomer acti.docx
BUS225 Group Assignment1. Service BlueprintCustomer acti.docx
 
BUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docx
BUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docxBUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docx
BUS301 Memo Rubric Spring 2020 - Student.docxBUS301 Writing Ru.docx
 
BUS1431Introduction and PreferencesBUS143 Judgmen.docx
BUS1431Introduction and PreferencesBUS143 Judgmen.docxBUS1431Introduction and PreferencesBUS143 Judgmen.docx
BUS1431Introduction and PreferencesBUS143 Judgmen.docx
 
BUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docx
BUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docxBUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docx
BUS210 analysis – open question codesQ7a01 Monthly OK02 Not .docx
 
Bus101 quiz (Business Organizations)The due time is in 1hrs1 .docx
Bus101 quiz (Business Organizations)The due time is in 1hrs1 .docxBus101 quiz (Business Organizations)The due time is in 1hrs1 .docx
Bus101 quiz (Business Organizations)The due time is in 1hrs1 .docx
 
BUS 625 Week 4 Response to Discussion 2Guided Response Your.docx
BUS 625 Week 4 Response to Discussion 2Guided Response Your.docxBUS 625 Week 4 Response to Discussion 2Guided Response Your.docx
BUS 625 Week 4 Response to Discussion 2Guided Response Your.docx
 
BUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docx
BUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docxBUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docx
BUS 625 Week 2 Response for Discussion 1 & 2Week 2 Discussion 1 .docx
 
Bus 626 Week 6 - Discussion Forum 1Guided Response Respon.docx
Bus 626 Week 6 - Discussion Forum 1Guided Response Respon.docxBus 626 Week 6 - Discussion Forum 1Guided Response Respon.docx
Bus 626 Week 6 - Discussion Forum 1Guided Response Respon.docx
 
BUS 499, Week 8 Corporate Governance Slide #TopicNarration.docx
BUS 499, Week 8 Corporate Governance Slide #TopicNarration.docxBUS 499, Week 8 Corporate Governance Slide #TopicNarration.docx
BUS 499, Week 8 Corporate Governance Slide #TopicNarration.docx
 
BUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docx
BUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docxBUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docx
BUS 499, Week 6 Acquisition and Restructuring StrategiesSlide #.docx
 
BUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docx
BUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docxBUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docx
BUS 499, Week 4 Business-Level Strategy, Competitive Rivalry, and.docx
 
BUS 437 Project Procurement Management Discussion QuestionsWe.docx
BUS 437 Project Procurement Management  Discussion QuestionsWe.docxBUS 437 Project Procurement Management  Discussion QuestionsWe.docx
BUS 437 Project Procurement Management Discussion QuestionsWe.docx
 
BUS 480.01HY Case Study Assignment Instructions .docx
BUS 480.01HY Case Study Assignment Instructions     .docxBUS 480.01HY Case Study Assignment Instructions     .docx
BUS 480.01HY Case Study Assignment Instructions .docx
 

Último

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx

  • 1. NewTetrisScore.cppNewTetrisScore.cpp// newTetris.cpp : Defin es the entry point for the console application. // #include"stdafx.h" #include<stdlib.h> #include<iostream> #include<time.h> #include<windows.h> #define GAME_INTERVAL 20 #define DIR_DOWN 2 #define DIR_LEFT 4 #define DIR_RIGHT 6 #define DIR_ROTATE 5 usingnamespace std; classTetrisShape{ public: char shapeArray[4][4]; int shapeTopLeftX =6; int shapeTopLeftY =0; void populateShapeArray(int shape); void rotate(); template<size_t rows, size_t cols> void setShape(char(&shape)[rows][cols]); TetrisShape(int shape){ populateShapeArray(shape);}; TetrisShape(){}; };
  • 2. voidTetrisShape::rotate(){ char _shapeArray[4][4]; _shapeArray[0][0]= shapeArray[0][3]; _shapeArray[1][0]= sh apeArray[0][2]; _shapeArray[2][0]= shapeArray[0][1]; _shapeA rray[3][0]= shapeArray[0][0]; _shapeArray[0][1]= shapeArray[1][3]; _shapeArray[1][1]= sh apeArray[1][2]; _shapeArray[2][1]= shapeArray[1][1]; _shapeA rray[3][1]= shapeArray[1][0]; _shapeArray[0][2]= shapeArray[2][3]; _shapeArray[1][2]= sh apeArray[2][2]; _shapeArray[2][2]= shapeArray[2][1]; _shapeA rray[3][2]= shapeArray[2][0]; _shapeArray[0][3]= shapeArray[3][3]; _shapeArray[1][3]= sh apeArray[3][2]; _shapeArray[2][3]= shapeArray[3][1]; _shapeA rray[3][3]= shapeArray[3][0]; for(int _x =0; _x <4; _x++){ for(int _y =0; _y <4; _y++){ shapeArray[_x][_y]= _shapeArray[_x][_y]; } } } voidTetrisShape::populateShapeArray(int shape){ switch(shape){ case1: shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][ 0]=' '; shapeArray[3][0]=' '; shapeArray[0][1]=' '; shapeArray[1][1]='X'; shapeArray[2] [1]=' '; shapeArray[3][1]=' '; shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2] [2]=' '; shapeArray[3][2]=' '; shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2] [3]='X'; shapeArray[3][3]=' '; break;
  • 3. case2: shapeArray[0][0]=' '; shapeArray[1][0]='X'; shapeArray[2] [0]=' '; shapeArray[3][0]=' '; shapeArray[0][1]=' '; shapeArray[1][1]='X'; shapeArray[2] [1]=' '; shapeArray[3][1]=' '; shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2] [2]=' '; shapeArray[3][2]=' '; shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2] [3]=' '; shapeArray[3][3]=' '; break; case3: shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][ 0]=' '; shapeArray[3][0]=' '; shapeArray[0][1]=' '; shapeArray[1][1]='X'; shapeArray[2] [1]=' '; shapeArray[3][1]=' '; shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2] [2]='X'; shapeArray[3][2]=' '; shapeArray[0][3]=' '; shapeArray[1][3]=' '; shapeArray[2][ 3]='X'; shapeArray[3][3]=' '; break; case4: shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][ 0]=' '; shapeArray[3][0]=' '; shapeArray[0][1]=' '; shapeArray[1][1]=' '; shapeArray[2][ 1]='X'; shapeArray[3][1]=' '; shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2] [2]='X'; shapeArray[3][2]=' '; shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2] [3]=' '; shapeArray[3][3]=' '; break; case5: shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][ 0]=' '; shapeArray[3][0]=' '; shapeArray[0][1]=' '; shapeArray[1][1]=' '; shapeArray[2][ 1]='X'; shapeArray[3][1]=' '; shapeArray[0][2]=' '; shapeArray[1][2]=' '; shapeArray[2][
  • 4. 2]='X'; shapeArray[3][2]=' '; shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2] [3]='X'; shapeArray[3][3]=' '; break; case6: shapeArray[0][0]=' '; shapeArray[1][0]=' '; shapeArray[2][ 0]=' '; shapeArray[3][0]=' '; shapeArray[0][1]=' '; shapeArray[1][1]=' '; shapeArray[2][ 1]=' '; shapeArray[3][1]=' '; shapeArray[0][2]=' '; shapeArray[1][2]='X'; shapeArray[2] [2]='X'; shapeArray[3][2]=' '; shapeArray[0][3]=' '; shapeArray[1][3]='X'; shapeArray[2] [3]='X'; shapeArray[3][3]=' '; break; } } int score =0; int currentShape =- 1;// this is going to represent the shape that is currently in play. bool isDropping =false;// global that defines if a piece is current ly falling - mainly for gameTick function. int currentTick =0; template<size_t rows, size_t cols> void generateBucket(char(&bucket)[rows][cols]);// Creates a sli ghtly pre-filled bucket. void generateShapeStream();// Generate a stream of shapes. void dropShape();// Draw the shape top/center. bool moveShape(int direction);// Move the shape in the spec. dir . template<size_t rows, size_t cols> bool gameTick(char(&bucket)[rows][cols],char(&perm_bucket)[ rows][cols]);// Handles what is going on in the game every seco nd. template<size_t rows, size_t cols> void landShape(char(&bucket)[rows][cols]);// What to do when
  • 5. the shape hits the bottom. template<size_t rows, size_t cols> int checkScore(char(&bucket)[rows][cols],char(&perm_bucket)[ rows][cols],int tempvar,int score); template<size_t rows, size_t cols> void drawBucket(char(&bucket)[rows][cols]);// Draws the curre nt contents of the bucket. template<size_t rows, size_t cols> bool canEnter(int direction,char(&bucket)[rows][cols]);// Check s if the shape can enter the space it is trying to drop into. int getUserInput();// gets the key pressed from the user. void setCursorTo(int x,int y);// Move the cursor to the appropria te position int previousX =6, previousY =0; int shapes[256]; template<size_t rows, size_t cols> int check_bucket(char(&bucket)[rows][cols]); template<size_t rows, size_t cols> void set_bucket(char(&bucket)[rows][cols],char(&perm_bucket) [rows][cols]); TetrisShape activeShape; int main(){ // Two bucket arrays, one shown on the screen, the other with th e permanent contents of the buckets (walls and any non- moving shapes) char bucket[12][25]; int score =0; int tempvar =0; char _bucket[12][25]; int shapes[256]={}; int shapeIndex =0; bool gameOver =false;
  • 6. generateBucket(bucket); generateBucket(_bucket); generateShapeStream(); drawBucket(bucket); while(!gameOver){ gameOver = gameTick(bucket, _bucket); Sleep(50); checkScore(bucket, _bucket, tempvar, score); cout <<"Your Score is: "<< score << endl; currentTick++; } setCursorTo(25,6); cout <<"GAME OVER"; system("pause"); } void setCursorTo(int x,int y) { HANDLE handle; COORD position; handle =GetStdHandle(STD_OUTPUT_HANDLE); position.X = x; position.Y = y; SetConsoleCursorPosition(handle, position); } /* generateBucket - takes a bucket array of any size and * creates a semi-empty bucket, with a * few random shapes in the bottom few lines. */ template<size_t rows, size_t cols>
  • 7. void generateBucket(char(&bucket)[rows][cols]){ for(int w =0; w <12; w++){ for(int z =0; z <25; z++){ if(((w ==0)||(w ==11))&&(z ==0)){ bucket[w][z]='.';} elseif(((w %12==0)||(w %12==11))&&((z >0)&&(z <24))){ buc ket[w][z]='|';} elseif(((w ==0)||(w ==11))&&(z ==24)){ bucket[w][z]='+';} elseif(z ==24){ bucket[w][z]='-';} else{ bucket[w][z]=' ';} } } } /* generateShapeStream - generates a pre-determined list of * shapes that will fall from the sky. */ void generateShapeStream(){ // Initialize the random number generator srand(time(NULL)); for(int i =0; i <256; i++){ shapes[i]= rand()%6+1; } //cout << "In generate shape..." << endl; } /* drawBucket - draws the actual bucket on the screen * including the currently dropping shape. */ template<size_t rows, size_t cols> void drawBucket(char(&bucket)[rows][cols]){ setCursorTo(0,0); for(int w =0; w <25; w++){ for(int z =0; z <12; z++){ cout << bucket[z][w]; } cout << endl; }
  • 8. } /* gameTick - this function does all of the different * processessing that happens throughout * the game. This also returns false to * stop the main loop once gameover has * been reached */ template<size_t rows, size_t cols> bool gameTick(char(&bucket)[rows][cols],char(&perm_bucket)[ rows][cols]){ drawBucket(bucket); if(!isDropping){ currentShape++; activeShape =TetrisShape(shapes[currentShape]); if(!canEnter(DIR_DOWN, perm_bucket)){ returntrue; } else{ isDropping =true; updateBucket(bucket,false); } } else{ if(currentTick % GAME_INTERVAL ==1){ // we are on a drop interval. if(canEnter(DIR_DOWN, perm_bucket)){ updateBucket(bucket, moveShape(DIR_DOWN)); } else{ landShape(perm_bucket); }
  • 9. } } int direction = getUserInput(); if(canEnter(direction, perm_bucket)){ updateBucket(bucket, moveShape(direction)); } if(!canEnter(DIR_DOWN, perm_bucket)){ landShape(perm_bucket); set_bucket(bucket, perm_bucket); } returnfalse; } /* moveShape - Handles moving the shape in the bucket. */ bool moveShape(int direction){ previousX = activeShape.shapeTopLeftX; previousY = activeShape.shapeTopLeftY; switch(direction){ case DIR_DOWN: activeShape.shapeTopLeftY++; returnfalse; break; case DIR_RIGHT: activeShape.shapeTopLeftX++; returnfalse; break; case DIR_LEFT: activeShape.shapeTopLeftX--; returnfalse; break; case DIR_ROTATE: