Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 09-30-09   #1 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 318

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default tetris

im remaking tetris
but i have a problem i can't figure out so im hoping somebody here will spot whats wrong.
Code:
#include <iostream>
#include <cstdlib>
#include <ctime> 
#include <windows.h>
#include <fstream>

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0 )
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1 )

#define VK_LEFT			0x25 // left arrow key  
#define VK_UP			0x26 // up arrow key  
#define VK_RIGHT		0x27 // right arrow key  
#define VK_DOWN			0x28 // down arrow key 
using namespace std;
class tetris
{
public:
void draw_engine(int map[30][25]);
void objects(int numb,int x[4],int y[4],int map[30][25]);
};
void tetris::draw_engine(int map[30][25])
{
	system("CLS");
	for(int i = 0;i <= 29;i++)
	{
		for(int x = 0; x <= 24;x++){
		if(map[i][x] == 2)
			cout << (char)219;
		else if(map[i][x] == 1)
			cout << (char)178;
		else 
			cout << " ";
		}
		cout << "\n";
	}
}
void tetris::objects(int numb,int x[4],int y[4],int map[30][25])
{
	switch(numb)
	{
	case 1:
		x[0] = 1;
		x[1] = 1;
		x[2] = 2;
		x[3] = 2;                    //square
		y[0] = 12;
		y[1] = 13;
		y[2] = 12;
		y[3] = 13;
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;
			map[x[2]][y[2]]=1;    //printing it
			map[x[3]][y[3]]=1;
		if(KEYDOWN(VK_DOWN))
		{
			while(map[x[2]+1][y[2]]==0 && map[x[3]+1][y[3]]==0)  
			{  //until its on top of other objects or the bottom 
			map[x[0]][y[0]]=0;  // since we dont want to leave a trail
			map[x[1]][y[1]]=0;
			x[0] = (x[0]+1);     //pushing the box down by 1
			x[1] = (x[1]+1);
			x[2] = (x[2]+1);
			x[3] = (x[3]+1);
				map[x[0]][y[0]]=1;
				map[x[1]][y[1]]=1;     //printing it
				map[x[2]][y[2]]=1;
				map[x[3]][y[3]]=1;
			}
		}
	}
}
int main()
{
ShowWindow( GetConsoleWindow() , SW_MAXIMIZE);
int map[30][25] = { {  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
				{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 } };
	int x[4];
	int y[4];
while(1>0){
	tetris lol;
	lol.objects(1,x,y,map);
	lol.draw_engine(map);
	}
system("pause");
	return 0;
for some reason it starts printing at the bottom and goes upward leaving a trail
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Old 10-05-09   #2 (permalink)
PC Gamer
 
Join Date: Oct 2008
Location: Arizona
Posts: 27

Rep: 3 Lumas Unknown
Unique Rep: 3
Hardware Reviews: 2
Trader Rating: 0
Default

Is this the entire code (if your not comfortable posting PM it)?
Lumas is offline   Reply With Quote
Old 10-06-09   #3 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 318

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

its all i have currently since i accidentally deleted this project. i found the problem and fixed it, im just lazy to rewrite it again. ill post a finished version or more questions here.
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Old 10-10-09   #4 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 318

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

Code:
#include <iostream>
#include <cstdlib>
#include <ctime> 
#include <windows.h>
#include <fstream>

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0 )
#define VK_LEFT			0x25 // left arrow key  
#define VK_UP			0x26 // up arrow key  
#define VK_RIGHT		0x27 // right arrow key  
#define VK_DOWN			0x28 // down arrow key 

using namespace std;

class tetris
{
	int x[4];
	int y[4];
public:
	void draw_engine(int map[30][26]);
	void objects(int numb,int map[30][26]);
};
void tetris::draw_engine(int map[30][26])
{
	system("CLS");  
	for(int i = 0;i <= 29;i++) // 30 horizontal lines
	{
		for(int x = 0; x <= 25;x++)   // 26 characters per line 
		{  
			if(map[i][x] == 2)
				cout << (char)219;      //█
			else if(map[i][x] == 1)  
				cout << (char)178;      //▓
			else if(map[i][x] == 3)
				cout << (char)178;
			else 
				cout << " ";        
		}
		cout << "\n";
	}
}
void tetris::objects(int numb,int map[30][26])
{
	switch(numb)
	{
	case 1:
		x[0] = 1;
		x[1] = 1;
		x[2] = 2;
		x[3] = 2;          //     ▓▓           
		y[0] = 12;         //     ▓▓
		y[1] = 13;
		y[2] = 12;
		y[3] = 13;
		map[x[0]][y[0]]=1;
		map[x[1]][y[1]]=1;
		map[x[2]][y[2]]=1;          
		map[x[3]][y[3]]=1;
		tetris::draw_engine(map);
		while(map[x[2]+1][y[2]]==0 && map[x[3]+1][y[3]]==0)         //checking if we're not on the bottom yet
		{
			if(KEYDOWN(VK_DOWN))
			{
				map[x[0]][y[0]]=0;
				map[x[1]][y[1]]=0;
				x[0] = (x[0]+1);   
				x[1] = (x[1]+1);
				x[2] = (x[2]+1);
				x[3] = (x[3]+1);
				map[x[0]][y[0]]=1;
				map[x[1]][y[1]]=1;  
				map[x[2]][y[2]]=1;
				map[x[3]][y[3]]=1;
				tetris::draw_engine(map);
			}
			if(KEYDOWN(VK_LEFT))
			{
				if(map[x[0]][y[2]-1]==0 && map[x[2]][y[2]-1]==0)  
				{ 
					map[x[1]][y[1]]=0;
					map[x[2]][y[3]]=0;
					y[0] = (y[0]-1);   
					y[1] = (y[1]-1);
					y[2] = (y[2]-1);
					y[3] = (y[3]-1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
				}
			}
			if(KEYDOWN(VK_RIGHT))
			{
				if(map[x[0]][y[3]+1]==0 && map[x[2]][y[3]+1]==0)
				{ 
					map[x[1]][y[0]]=0;
					map[x[2]][y[2]]=0;
					y[0] = (y[0]+1);   
					y[1] = (y[1]+1);
					y[2] = (y[2]+1);
					y[3] = (y[3]+1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
				}
			}
			else   // scrolling down
			{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					x[0] = (x[0]+1);   
					x[1] = (x[1]+1);
					x[2] = (x[2]+1);
					x[3] = (x[3]+1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
			}
		} // end of while
	break;
	case 2:
			x[0] = 1;
			x[1] = 1;
			x[2] = 1;
			x[3] = 1;                   
			y[0] = 12;         //     ▓▓▓▓
			y[1] = 13;
			y[2] = 14;
			y[3] = 15;
			map[x[0]][y[0]]=3;
			map[x[1]][y[1]]=3;
			map[x[2]][y[2]]=3;   
			map[x[3]][y[3]]=3;
			tetris::draw_engine(map);
			while(map[x[0]+1][y[0]]!=1 && map[x[1]+1][y[1]]!=1 && map[x[2]+1][y[2]]!=1 && map[x[3]+1][y[3]]!=1 && map[x[0]+1][y[0]]!=2 && map[x[1]+1][y[1]]!=2 && map[x[2]+1][y[2]]!=2 && map[x[3]+1][y[3]]!=2) 
			{
				if(KEYDOWN(VK_DOWN))
				{
					if(x[0]==x[1] && x[1]==x[2] && x[2]==x[3])
					{
						map[x[0]][y[0]]=0;
						map[x[0]][y[1]]=0;
						map[x[0]][y[2]]=0;
						map[x[0]][y[3]]=0;
						x[0] = (x[0]+1);   
						x[1] = (x[1]+1);
						x[2] = (x[2]+1);
						x[3] = (x[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
					else
					{
						map[x[3]][y[3]]=0;
						x[0] = (x[0]+1);   
						x[1] = (x[1]+1);
						x[2] = (x[2]+1);
						x[3] = (x[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[0]-1]!=1 && map[x[1]][y[1]-1]!=1 && map[x[2]][y[2]-1]!=1 && map[x[3]][y[3]-1]!=1 && map[x[0]][y[0]-1]!=2 && map[x[1]][y[1]-1]!=2 && map[x[2]][y[2]-1]!=2 && map[x[3]][y[3]-1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0] = (y[0]-1);   
						y[1] = (y[1]-1);
						y[2] = (y[2]-1);
						y[3] = (y[3]-1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[0]+1]!=1 && map[x[1]][y[1]+1]!=1 && map[x[2]][y[2]+1]!=1 && map[x[3]][y[3]+1]!=1 && map[x[0]][y[0]+1]!=2 && map[x[1]][y[1]+1]!=2 && map[x[2]][y[2]+1]!=2 && map[x[3]][y[3]+1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0] = (y[0]+1);   
						y[1] = (y[1]+1);
						y[2] = (y[2]+1);
						y[3] = (y[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				if(KEYDOWN(VK_UP))
				{
					if(x[0]==x[1] && x[1]==x[2] && x[2]==x[3])
					{																		
						if(map[x[0]+1][y[0]]==0 && map[x[1]+1][y[1]]==0 && map[x[1]-1][y[1]]==0 && map[x[1]-2][y[1]]==0 && map[x[2]-1][y[2]]==0 && map[x[2]-2][y[2]]==0 && map[x[3]-1][y[3]]==0)
						{
							map[x[0]][y[0]] = 0;
							map[x[2]][y[2]] = 0;
							map[x[3]][y[3]] = 0;
							y[0] = y[1];
							y[2] = y[1];
							y[3] = y[1];
							x[3] = x[1]-2;
							x[2]--;
							x[0]++;
							map[x[0]][y[0]]=3;
							map[x[1]][y[1]]=3;  
							map[x[2]][y[2]]=3;
							map[x[3]][y[3]]=3;
							tetris::draw_engine(map);
						}
					}
					else
					{
						if(map[x[0]][y[0]-1]==0 && map[x[1]][y[1]-1]==0 && map[x[1]][y[1]+1]==0 && map[x[1]][y[1]+2]==0 && map[x[2]][y[2]+1]==0 && map[x[2]][y[2]+2]==0 && map[x[3]][y[3]+1]==0)
						{
							map[x[3]][y[3]] = 0;
							map[x[2]][y[2]] = 0;
							map[x[0]][y[0]] = 0;
							y[0]--;
							y[2]++;
							y[3] = y[1]+2;
							x[3] = x[1];
							x[2] = x[1];
							x[0] = x[1];
							map[x[0]][y[0]]=3;
							map[x[1]][y[1]]=3;  
							map[x[2]][y[2]]=3;
							map[x[3]][y[3]]=3;
							tetris::draw_engine(map);
						}
					}
				}
				else
				{
					if(x[0]==x[1] && x[1]==x[2] && x[2]==x[3])
					{
						map[x[0]][y[0]]=0;
						map[x[0]][y[1]]=0;
						map[x[0]][y[2]]=0;
						map[x[0]][y[3]]=0;
						x[0] = (x[0]+1);   
						x[1] = (x[1]+1);
						x[2] = (x[2]+1);
						x[3] = (x[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
					else
					{
						map[x[3]][y[3]]=0;
						x[0] = (x[0]+1);   
						x[1] = (x[1]+1);
						x[2] = (x[2]+1);
						x[3] = (x[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
			}  // end of while
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;    //changing back to 1 for collision detection
			map[x[2]][y[2]]=1;
			map[x[3]][y[3]]=1;
	break;
	case 3:		
			x[0] = 1;
			x[1] = 1;
			x[2] = 1;
			x[3] = 2;                   
			y[0] = 12;                   //    ▓▓▓
			y[1] = 13;					 //		 ▓
			y[2] = 14;
			y[3] = 14;
			map[x[0]][y[0]]=3;
			map[x[1]][y[1]]=3;
			map[x[2]][y[2]]=3;   
			map[x[3]][y[3]]=3;
			tetris::draw_engine(map);
			while(map[x[0]+1][y[0]]!=1 && map[x[1]+1][y[1]]!=1 && map[x[2]+1][y[2]]!=1 && map[x[3]+1][y[3]]!=1 && map[x[0]+1][y[0]]!=2 && map[x[1]+1][y[1]]!=2 && map[x[2]+1][y[2]]!=2 && map[x[3]+1][y[3]]!=2) 
			{
				if(KEYDOWN(VK_DOWN))
				{
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						x[0]++;   
						x[1]++;
						x[2]++;
						x[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
				}
				if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[0]-1]!=1 && map[x[1]][y[1]-1]!=1 && map[x[2]][y[2]-1]!=1 && map[x[3]][y[3]-1]!=1 && map[x[0]][y[0]-1]!=2 && map[x[1]][y[1]-1]!=2 && map[x[2]][y[2]-1]!=2 && map[x[3]][y[3]-1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]--;   
						y[1]--;
						y[2]--;
						y[3]--;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[0]+1]!=1 && map[x[1]][y[1]+1]!=1 && map[x[2]][y[2]+1]!=1 && map[x[3]][y[3]+1]!=1 && map[x[0]][y[0]+1]!=2 && map[x[1]][y[1]+1]!=2 && map[x[2]][y[2]+1]!=2 && map[x[3]][y[3]+1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]++;   
						y[1]++;
						y[2]++;
						y[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				if(KEYDOWN(VK_UP))
				{
					if(x[2] == x[3])
					{			
						if(x[0] > x[2])
						{
							if(map[x[1]][y[1]+1]==0 && map[x[0]][y[0]+1]==0 && map[x[0]][y[0]-1]==0 && map[x[1]][y[1]-1]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								x[3] = x[3]+2;
								x[2]++;
								y[2]++;
								x[0]--;
								y[0]--;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}			
						else if(x[0] < x[2])
						{
							if(map[x[0]][y[0]+1]==0 && map[x[0]][y[0]-1]==0 && map[x[1]][y[1]+1]==0 && map[x[1]][y[1]-1]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								x[3]--;
								y[2]--;
								x[1]++;
								y[0]++;
								x[0] = x[0]+2;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
					}
					else if(y[2] == y[3])
					{
						if(y[2] < y[0])
						{
							if(map[x[0]-1][y[0]]==0 && map[x[0]+1][y[0]]==0 && map[x[1]-1][y[1]]==0 && map[x[1]+1][y[1]]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[3] = y[3]+2;
								y[2]++;
								x[2]--;
								y[0]--;
								x[0]++;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
						else if(y[2] > y[0])
						{
							if(map[x[1]-1][y[1]]==0 && map[x[1]+1][y[1]]==0 && map[x[0]-1][y[0]]==0 && map[x[0]+1][y[0]]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[3]--;
								x[2]++;
								y[1]++;
								y[0]=y[0]+2;
								x[0]--;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
					}
				}
				else
				{
					if(x[0]==x[1] && x[1]==x[2] && x[2]==x[3])
					{
						map[x[0]][y[0]]=0;
						map[x[0]][y[1]]=0;
						map[x[0]][y[2]]=0;
						map[x[0]][y[3]]=0;
						x[0]++;   
						x[1]++;
						x[2]++;
						x[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
					else
					{
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						x[0]++;   
						x[1]++;
						x[2]++;
						x[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
			} // end of while
		map[x[0]][y[0]]=1;
		map[x[1]][y[1]]=1;  
		map[x[2]][y[2]]=1;
		map[x[3]][y[3]]=1;
	break;
	}
}
int main()
{
ShowWindow( GetConsoleWindow() , SW_MAXIMIZE);  // maximizing the window
int map[30][26] =  {{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
					{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }};
	tetris lol;
	int a;
	while(1>0)
	{
		srand((unsigned)time(0));
		a = rand()%3+1;
		lol.objects(a,map);
	}
	system("pause");
	return 0;
}
not finished yet but i have a problem.

Code:
 
	case 1:
		x[0] = 1;
		x[1] = 1;
		x[2] = 2;
		x[3] = 2;          //     ▓▓           
		y[0] = 12;         //     ▓▓
		y[1] = 13;
		y[2] = 12;
		y[3] = 13;
		map[x[0]][y[0]]=1;
		map[x[1]][y[1]]=1;
		map[x[2]][y[2]]=1;          
		map[x[3]][y[3]]=1;
		tetris::draw_engine(map);
		while(map[x[2]+1][y[2]]==0 && map[x[3]+1][y[3]]==0)         //checking if we're not on the bottom yet
		{
			if(KEYDOWN(VK_DOWN))
			{
				map[x[0]][y[0]]=0;
				map[x[1]][y[1]]=0;
				x[0] = (x[0]+1);   
				x[1] = (x[1]+1);
				x[2] = (x[2]+1);
				x[3] = (x[3]+1);
				map[x[0]][y[0]]=1;
				map[x[1]][y[1]]=1;  
				map[x[2]][y[2]]=1;
				map[x[3]][y[3]]=1;
				tetris::draw_engine(map);
			}
			if(KEYDOWN(VK_LEFT))
			{
				if(map[x[0]][y[2]-1]==0 && map[x[2]][y[2]-1]==0)  
				{ 
					map[x[1]][y[1]]=0;
					map[x[2]][y[3]]=0;
					y[0] = (y[0]-1);   
					y[1] = (y[1]-1);
					y[2] = (y[2]-1);
					y[3] = (y[3]-1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
				}
			}
			if(KEYDOWN(VK_RIGHT))
			{
				if(map[x[0]][y[3]+1]==0 && map[x[2]][y[3]+1]==0)
				{ 
					map[x[1]][y[0]]=0;
					map[x[2]][y[2]]=0;
					y[0] = (y[0]+1);   
					y[1] = (y[1]+1);
					y[2] = (y[2]+1);
					y[3] = (y[3]+1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
				}
			}
			else   // scrolling down
			{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					x[0] = (x[0]+1);   
					x[1] = (x[1]+1);
					x[2] = (x[2]+1);
					x[3] = (x[3]+1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
			}
		} // end of while
	break;
Code:
while(map[x[2]+1][y[2]]==0 && map[x[3]+1][y[3]]==0)
shouldn't let the object go over the walls or other objects but when using the down key it sometimes slips through the walls but not other objects. how is that possible?
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Old 4 Weeks Ago   #5 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 318

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

1193 lines of horrible code >.<
Code:
#include <iostream>
#include <cstdlib>
#include <ctime> 
#include <windows.h>
#include <fstream>

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0 )
#define VK_LEFT			0x25 // left arrow key  
#define VK_UP			0x26 // up arrow key  
#define VK_RIGHT		0x27 // right arrow key  
#define VK_DOWN			0x28 // down arrow key 
#define VK_RETURN		0x0D // enter key
#define VK_SPACE		0x20 // spacebar 
#define VK_ESCAPE		0x1B // escape key
#define VK_CONTROL 	    0x11 // ctrl
#define VK_Z			0x5A // z key

using namespace std;

class tetris
{
	int x[4];
	int y[4];
	int score,counter,speed;
public:
	void draw_engine(int map[30][26]);
	int objects(int numb,int map[30][26]);
	int menu(void); //777
	int editor(void);
	void restack(int map[30][26],int x);
};
void tetris::restack(int map[30][26],int x)
{
	for(int a = x;a>0;a--)
	{
		if(a>1){
			for(int x = 0;x<26;x++)
				map[a][x] = map[a-1][x];
		}
	}
	score++;
}
void tetris::draw_engine(int map[30][26])
{
	Sleep(speed);
	system("CLS");  
	for(int i = 0;i <= 29;i++) // 30 horizontal lines
	{
		for(int x = 0; x <= 25;x++)   // 26 characters per line 
		{  
			if(map[i][x] == 2)
				cout << (char)219;      //█
			else if(map[i][x] == 1)  
				cout << (char)178;      //▓
			else if(map[i][x] == 3)
				cout << (char)178;
			else if(map[i][x] == 5)     //╬
				cout << (char)206;
			else 
				cout << " ";        
		}
		if(i == 15)
			cout << " score: "<< score << endl;
		else
			cout << "\n";
	}
}
int tetris::editor(void)
{
	int prev_x=0;
	int prev_y=0;
	int editor_map[30][26] =  {{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }};
	int x=15,y=13;
	editor_map[x][y]=1;
	while(1>0)
	{
		tetris::draw_engine(editor_map);
		if(KEYDOWN(VK_ESCAPE))
		{
			return 1;
		}
		else if(KEYDOWN(VK_UP))
		{
			if(editor_map[x][y]!=5)
				editor_map[x][y]=0;
			if(editor_map[x][y]!=1&&editor_map[x][y]!=2)
			{
				x--;
				if(editor_map[x][y]!=5)
					editor_map[x][y]=1;
			}
		}
		else if(KEYDOWN(VK_DOWN))
		{
			if(editor_map[x][y]!=5)
				editor_map[x][y]=0;
			if(editor_map[x][y]!=1&&editor_map[x][y]!=2)
			{
				x++;
				if(editor_map[x][y]!=5)
					editor_map[x][y]=1;
			}
		}
		else if(KEYDOWN(VK_RIGHT))
		{
			if(editor_map[x][y]!=5)
				editor_map[x][y]=0;
			if(editor_map[x][y]!=1&&editor_map[x][y]!=2)
			{
				y++;
				if(editor_map[x][y]!=5)
					editor_map[x][y]=1;
			}
		}
		else if(KEYDOWN(VK_LEFT))
		{
			if(editor_map[x][y]!=5)
				editor_map[x][y]=0;
			if(editor_map[x][y]!=1&&editor_map[x][y]!=2)
			{
				y--;
				if(editor_map[x][y]!=5)
					editor_map[x][y]=1;
			}
		}
		else if(KEYDOWN(VK_SPACE))
		{
			editor_map[x][y]=5;
			prev_x=x;
			prev_y=y;
		}
		else if(KEYDOWN(VK_CONTROL)&&KEYDOWN(VK_Z))
		{
			editor_map[prev_x][prev_y]=0;
		}
		else if(KEYDOWN(VK_RETURN))
		{
			for(int g=0;g<29;g++)
			{
				for(int h=0;h<25;h++)
				{
					if(editor_map[g][h]==0)
						editor_map[g][h]=1;
					else if(editor_map[g][h]==5)
						editor_map[g][h]=0;
				}
				tetris::draw_engine(editor_map);
			}
		}

	}
	return 0;
}
int tetris::menu(void)
{
	speed = 100;
	score = 0;
	int menumap[30][26] =  {{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }};
	srand((unsigned)time(0));
	int j=0,k=0,l=1;
	Sleep(1000);
	while(1>0)
	{
		j = rand()%29;
		k = rand()%25;
		if(menumap[j][k]!=2&&menumap[j][k]!=1)
			menumap[j][k] = 1;
		tetris::draw_engine(menumap);
		if(l==1)
		{
			cout << endl;
			cout << (char)178 << "PLAY" << (char)178 << endl;
			cout << "ABOUT" << endl;
			cout << "EDITOR" << endl;
			cout << "SETTINGS" << endl;
			cout << "EXIT" << endl;
		}
		else if(l==2)
		{
			cout << endl;
			cout << "PLAY" << endl;
			cout << (char)178 << "ABOUT" << (char)178 << endl;
			cout << "EDITOR" << endl;
			cout << "SETTINGS" << endl;
			cout << "EXIT" << endl;
		}
		else if(l==3)
		{
			cout << endl;
			cout << "PLAY" << endl;
			cout << "ABOUT" << endl;
			cout << (char)178 << "EDITOR" << (char)178 << endl;
			cout << "SETTINGS" << endl;
			cout << "EXIT" << endl;
		}
		else if(l==4)
		{
			cout << endl;
			cout << "PLAY" << endl;
			cout << "ABOUT" << endl;
			cout << "EDITOR" << endl;
			cout << (char)178 << "SETTINGS" << (char)178 << endl;
			cout << "EXIT" << endl;
		}
		else if(l==5)
		{
			cout << endl;
			cout << "PLAY" << endl;
			cout << "ABOUT" << endl;
			cout << "EDITOR" << endl;
			cout << "SETTINGS" << endl;
			cout << (char)178 << "EXIT" << (char)178 << endl;
		}
		if(KEYDOWN(VK_DOWN))
		{
			if(l<5)
				l++;
		}
		else if(KEYDOWN(VK_UP))
		{
			if(l>1)
				l--;
		}
		else if(KEYDOWN(VK_RETURN))
		{
			if(l==1)//play
				return 0;
			else if(l==2)//about
			{
				system("CLS");
				cout << "01101001001000000110100001101111011100000110010100100000011110010110111101110101001000000110010001101001011001000110111000100111011101000010000001101001011011100111000001110101011101000010000001110100011010000110100101110011001000000110001001111001001000000110100001100001011011100110010000100000010111100101111000100000001011110010111101101110011001010111011101100010011010010110010100110001001110010011000100110001001000000100000000100000011011110110001101101110" << endl;
				system("pause");
			}
			else if(l==3)//editor
			{
				tetris::editor();
			}
			else if(l==4)//settings
			{
				int exec=1;
				while(exec!=0)
				{
					system("CLS");  
					cout << "speed of the game: " << speed << " ms" << endl;
					if(KEYDOWN(VK_DOWN))
					{
						if(speed>1)
							speed--;
					}
					else if(KEYDOWN(VK_UP))
					{
						if(speed<10000)
							speed++;
					}
					else if(KEYDOWN(VK_RETURN))
						exec=0;
				}
			}
			else if(l==5)//exit
			{
				return 1;
			}
		}
	}
	return 1;
}
int tetris::objects(int numb,int map[30][26])
{
	switch(numb)
	{
	case 1:
		if(map[1][12]==0 && map[1][13]==0 && map[2][12]==0 && map[2][13]==0)
		{
			x[0] = 1;
			x[1] = 1;
			x[2] = 2;
			x[3] = 2;          //     ▓▓           
			y[0] = 12;         //     ▓▓
			y[1] = 13;
			y[2] = 12;
			y[3] = 13;
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;
			map[x[2]][y[2]]=1;          
			map[x[3]][y[3]]=1;
			tetris::draw_engine(map);
			while(map[x[2]+1][y[2]]==0 && map[x[3]+1][y[3]]==0)         //checking if we're not on the bottom yet
			{
				if(KEYDOWN(VK_DOWN))
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					x[0] = (x[0]+1);   
					x[1] = (x[1]+1);
					x[2] = (x[2]+1);
					x[3] = (x[3]+1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
				}
				else if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[2]-1]==0 && map[x[2]][y[2]-1]==0)  
					{ 
						map[x[1]][y[1]]=0;
						map[x[2]][y[3]]=0;
						y[0] = (y[0]-1);   
						y[1] = (y[1]-1);
						y[2] = (y[2]-1);
						y[3] = (y[3]-1);
						map[x[0]][y[0]]=1;
						map[x[1]][y[1]]=1;  
						map[x[2]][y[2]]=1;
						map[x[3]][y[3]]=1;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[3]+1]==0 && map[x[2]][y[3]+1]==0)
					{ 
						map[x[1]][y[0]]=0;
						map[x[2]][y[2]]=0;
						y[0] = (y[0]+1);   
						y[1] = (y[1]+1);
						y[2] = (y[2]+1);
						y[3] = (y[3]+1);
						map[x[0]][y[0]]=1;
						map[x[1]][y[1]]=1;  
						map[x[2]][y[2]]=1;
						map[x[3]][y[3]]=1;
						tetris::draw_engine(map);
					}
				}
				else  // scrolling down
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					x[0] = (x[0]+1);   
					x[1] = (x[1]+1);
					x[2] = (x[2]+1);
					x[3] = (x[3]+1);
					map[x[0]][y[0]]=1;
					map[x[1]][y[1]]=1;  
					map[x[2]][y[2]]=1;
					map[x[3]][y[3]]=1;
					tetris::draw_engine(map);
				}
			} // end of while
		}
		else return score;
		counter=0;
		for(int h=0;h<4;h++)
		{
			for(int g=0;g<26;g++)
			{
				if(map[x[h]][g]==1||map[x[h]][g]==2)
					counter++;
			}
			if(counter == 26)
				tetris::restack(map,x[h]);
			counter = 0;
		}
		break;
	case 2:
		if(map[1][12]==0 && map[1][13]==0 && map[1][14]==0 && map[1][15]==0)
		{
			x[0] = 1;
			x[1] = 1;
			x[2] = 1;
			x[3] = 1;                   
			y[0] = 12;         //     ▓▓▓▓
			y[1] = 13;
			y[2] = 14;
			y[3] = 15;
			map[x[0]][y[0]]=3;
			map[x[1]][y[1]]=3;
			map[x[2]][y[2]]=3;   
			map[x[3]][y[3]]=3;
			tetris::draw_engine(map);
			while(map[x[0]+1][y[0]]!=1 && map[x[1]+1][y[1]]!=1 && map[x[2]+1][y[2]]!=1 && map[x[3]+1][y[3]]!=1 && map[x[0]+1][y[0]]!=2 && map[x[1]+1][y[1]]!=2 && map[x[2]+1][y[2]]!=2 && map[x[3]+1][y[3]]!=2) 
			{
				if(KEYDOWN(VK_DOWN))
				{
					if(x[0]==x[1] && x[1]==x[2] && x[2]==x[3])
					{
						map[x[0]][y[0]]=0;
						map[x[0]][y[1]]=0;
						map[x[0]][y[2]]=0;
						map[x[0]][y[3]]=0;
						x[0] = (x[0]+1);   
						x[1] = (x[1]+1);
						x[2] = (x[2]+1);
						x[3] = (x[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
					else
					{
						map[x[3]][y[3]]=0;
						x[0] = (x[0]+1);   
						x[1] = (x[1]+1);
						x[2] = (x[2]+1);
						x[3] = (x[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[0]-1]!=1 && map[x[1]][y[1]-1]!=1 && map[x[2]][y[2]-1]!=1 && map[x[3]][y[3]-1]!=1 && map[x[0]][y[0]-1]!=2 && map[x[1]][y[1]-1]!=2 && map[x[2]][y[2]-1]!=2 && map[x[3]][y[3]-1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0] = (y[0]-1);   
						y[1] = (y[1]-1);
						y[2] = (y[2]-1);
						y[3] = (y[3]-1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[0]+1]!=1 && map[x[1]][y[1]+1]!=1 && map[x[2]][y[2]+1]!=1 && map[x[3]][y[3]+1]!=1 && map[x[0]][y[0]+1]!=2 && map[x[1]][y[1]+1]!=2 && map[x[2]][y[2]+1]!=2 && map[x[3]][y[3]+1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0] = (y[0]+1);   
						y[1] = (y[1]+1);
						y[2] = (y[2]+1);
						y[3] = (y[3]+1);
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_UP))
				{
					if(x[0]==x[1] && x[1]==x[2] && x[2]==x[3])
					{																		
						if(map[x[0]+1][y[0]]==0 && map[x[1]+1][y[1]]==0 && map[x[1]-1][y[1]]==0 && map[x[1]-2][y[1]]==0 && map[x[2]-1][y[2]]==0 && map[x[2]-2][y[2]]==0 && map[x[3]-1][y[3]]==0)
						{
							map[x[0]][y[0]] = 0;
							map[x[2]][y[2]] = 0;
							map[x[3]][y[3]] = 0;
							y[0] = y[1];
							y[2] = y[1];
							y[3] = y[1];
							x[3] = x[1]-2;
							x[2]--;
							x[0]++;
							map[x[0]][y[0]]=3;
							map[x[1]][y[1]]=3;  
							map[x[2]][y[2]]=3;
							map[x[3]][y[3]]=3;
							tetris::draw_engine(map);
						}
					}
					else
					{
						if(map[x[0]][y[0]-1]==0 && map[x[1]][y[1]-1]==0 && map[x[1]][y[1]+1]==0 && map[x[1]][y[1]+2]==0 && map[x[2]][y[2]+1]==0 && map[x[2]][y[2]+2]==0 && map[x[3]][y[3]+1]==0)
						{
							map[x[3]][y[3]] = 0;
							map[x[2]][y[2]] = 0;
							map[x[0]][y[0]] = 0;
							y[0]--;
							y[2]++;
							y[3] = y[1]+2;
							x[3] = x[1];
							x[2] = x[1];
							x[0] = x[1];
							map[x[0]][y[0]]=3;
							map[x[1]][y[1]]=3;  
							map[x[2]][y[2]]=3;
							map[x[3]][y[3]]=3;
							tetris::draw_engine(map);
						}
					}
				}
				else
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
			}  // end of while
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;    //changing back to 1 for collision detection
			map[x[2]][y[2]]=1;
			map[x[3]][y[3]]=1;
		}
		else return score;
		counter=0;
		for(int h=0;h<4;h++)
		{
			for(int g=0;g<26;g++)
			{
				if(map[x[h]][g]==1||map[x[h]][g]==2)
					counter++;
			}
			if(counter == 26)
				tetris::restack(map,x[h]);
			counter = 0;
		}
		break;
	case 3:
		if(map[1][12]==0 && map[1][13]==0 && map[1][14]==0 && map[2][14]==0)
		{
			x[0] = 1;
			x[1] = 1;
			x[2] = 1;
			x[3] = 2;                   
			y[0] = 12;                   //    ▓▓▓
			y[1] = 13;					 //		 ▓
			y[2] = 14;
			y[3] = 14;
			map[x[0]][y[0]]=3;
			map[x[1]][y[1]]=3;
			map[x[2]][y[2]]=3;   
			map[x[3]][y[3]]=3;
			tetris::draw_engine(map);
			while(map[x[0]+1][y[0]]!=1 && map[x[1]+1][y[1]]!=1 && map[x[2]+1][y[2]]!=1 && map[x[3]+1][y[3]]!=1 && map[x[0]+1][y[0]]!=2 && map[x[1]+1][y[1]]!=2 && map[x[2]+1][y[2]]!=2 && map[x[3]+1][y[3]]!=2) 
			{
				if(KEYDOWN(VK_DOWN))
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
				else if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[0]-1]!=1 && map[x[1]][y[1]-1]!=1 && map[x[2]][y[2]-1]!=1 && map[x[3]][y[3]-1]!=1 && map[x[0]][y[0]-1]!=2 && map[x[1]][y[1]-1]!=2 && map[x[2]][y[2]-1]!=2 && map[x[3]][y[3]-1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]--;   
						y[1]--;
						y[2]--;
						y[3]--;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[0]+1]!=1 && map[x[1]][y[1]+1]!=1 && map[x[2]][y[2]+1]!=1 && map[x[3]][y[3]+1]!=1 && map[x[0]][y[0]+1]!=2 && map[x[1]][y[1]+1]!=2 && map[x[2]][y[2]+1]!=2 && map[x[3]][y[3]+1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]++;   
						y[1]++;
						y[2]++;
						y[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_UP))
				{
					if(x[2] == x[3])
					{			
						if(x[0] > x[2])
						{
							if(map[x[1]][y[1]+1]==0 && map[x[0]][y[0]+1]==0 && map[x[0]][y[0]-1]==0 && map[x[1]][y[1]-1]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								x[3] = x[3]+2;
								x[2]++;
								y[2]++;
								x[0]--;
								y[0]--;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}			
						else if(x[0] < x[2])
						{
							if(map[x[0]][y[0]+1]==0 && map[x[0]][y[0]-1]==0 && map[x[1]][y[1]+1]==0 && map[x[1]][y[1]-1]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								x[3]--;
								y[2]--;
								x[1]++;
								y[0]++;
								x[0] = x[0]+2;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
					}
					else if(y[2] == y[3])
					{
						if(y[2] < y[0])
						{
							if(map[x[0]-1][y[0]]==0 && map[x[0]+1][y[0]]==0 && map[x[1]-1][y[1]]==0 && map[x[1]+1][y[1]]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[3] = y[3]+2;
								y[2]++;
								x[2]--;
								y[0]--;
								x[0]++;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
						else if(y[2] > y[0])
						{
							if(map[x[1]-1][y[1]]==0 && map[x[1]+1][y[1]]==0 && map[x[0]-1][y[0]]==0 && map[x[0]+1][y[0]]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[3]--;
								x[2]++;
								y[1]++;
								y[0]=y[0]+2;
								x[0]--;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
					}
				}
				else
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
			} // end of while
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;  
			map[x[2]][y[2]]=1;
			map[x[3]][y[3]]=1;
		}
		else return score;
		counter=0;
		for(int h=0;h<4;h++)
		{
			for(int g=0;g<26;g++)
			{
				if(map[x[h]][g]==1||map[x[h]][g]==2)
					counter++;
			}
			if(counter == 26)
				tetris::restack(map,x[h]);
			counter = 0;
		}
		break;
	case 4:		
		if(map[1][12]==0 && map[1][13]==0 && map[2][13]==0 && map[2][14]==0)
		{
			x[0] = 1;
			x[1] = 1;
			x[2] = 2;
			x[3] = 2;                   
			y[0] = 12;                   //    ▓▓
			y[1] = 13;					 //		▓▓
			y[2] = 13;
			y[3] = 14;
			map[x[0]][y[0]]=3;
			map[x[1]][y[1]]=3;
			map[x[2]][y[2]]=3;   
			map[x[3]][y[3]]=3;
			tetris::draw_engine(map);
			while(map[x[0]+1][y[0]]!=1 && map[x[1]+1][y[1]]!=1 && map[x[2]+1][y[2]]!=1 && map[x[3]+1][y[3]]!=1 && map[x[0]+1][y[0]]!=2 && map[x[1]+1][y[1]]!=2 && map[x[2]+1][y[2]]!=2 && map[x[3]+1][y[3]]!=2) 
			{
				if(KEYDOWN(VK_DOWN))
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
				else if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[0]-1]!=1 && map[x[1]][y[1]-1]!=1 && map[x[2]][y[2]-1]!=1 && map[x[3]][y[3]-1]!=1 && map[x[0]][y[0]-1]!=2 && map[x[1]][y[1]-1]!=2 && map[x[2]][y[2]-1]!=2 && map[x[3]][y[3]-1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]--;   
						y[1]--;
						y[2]--;
						y[3]--;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[0]+1]!=1 && map[x[1]][y[1]+1]!=1 && map[x[2]][y[2]+1]!=1 && map[x[3]][y[3]+1]!=1 && map[x[0]][y[0]+1]!=2 && map[x[1]][y[1]+1]!=2 && map[x[2]][y[2]+1]!=2 && map[x[3]][y[3]+1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]++;   
						y[1]++;
						y[2]++;
						y[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_UP))
				{
					if(y[1] == y[2])
					{			
						if(map[x[1]][y[1]+1]==0 && map[x[2]+1][y[2]]==0 && map[x[3]+1][y[3]]==0)
						{
							map[x[0]][y[0]] = 0;
							map[x[1]][y[1]] = 0;
							map[x[2]][y[2]] = 0;
							map[x[3]][y[3]] = 0;
							y[3]--;
							x[3]++;
							y[1]++;
							x[1]++;
							y[0] = y[0]+2;
							map[x[0]][y[0]]=3;
							map[x[1]][y[1]]=3;  
							map[x[2]][y[2]]=3;
							map[x[3]][y[3]]=3;
							tetris::draw_engine(map);
						}
					}
					else if(x[1] == x[2])
					{
						if(map[x[0]][y[0]-2]==0 && map[x[0]][y[0]-1]==0 && map[x[3]][y[3]+1]==0)
						{
							map[x[0]][y[0]] = 0;
							map[x[1]][y[1]] = 0;
							map[x[2]][y[2]] = 0;
							map[x[3]][y[3]] = 0;
							y[0] = y[0]-2;
							x[1]--;
							y[1]--;
							y[3]++;
							x[3]--;
							map[x[0]][y[0]]=3;
							map[x[1]][y[1]]=3;  
							map[x[2]][y[2]]=3;
							map[x[3]][y[3]]=3;
							tetris::draw_engine(map);
						}
					}
				}
				else
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
			} // end of while
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;  
			map[x[2]][y[2]]=1;
			map[x[3]][y[3]]=1;
		}
		else return score;
		counter=0;
		for(int h=0;h<4;h++)
		{
			for(int g=0;g<26;g++)
			{
				if(map[x[h]][g]==1||map[x[h]][g]==2)
					counter++;
			}
			if(counter == 26)
				tetris::restack(map,x[h]);
			counter = 0;
		}
		break;
	case 5:		
		if(map[1][12]==0 && map[1][13]==0 && map[1][14]==0 && map[2][13]==0)
		{
			x[0] = 1;
			x[1] = 1;
			x[2] = 1;
			x[3] = 2;                   
			y[0] = 12;                   //    ▓▓▓
			y[1] = 13;					 //		▓
			y[2] = 14;
			y[3] = 13;
			map[x[0]][y[0]]=3;
			map[x[1]][y[1]]=3;
			map[x[2]][y[2]]=3;   
			map[x[3]][y[3]]=3;
			tetris::draw_engine(map);
			while(map[x[0]+1][y[0]]!=1 && map[x[1]+1][y[1]]!=1 && map[x[2]+1][y[2]]!=1 && map[x[3]+1][y[3]]!=1 && map[x[0]+1][y[0]]!=2 && map[x[1]+1][y[1]]!=2 && map[x[2]+1][y[2]]!=2 && map[x[3]+1][y[3]]!=2) 
			{
				if(KEYDOWN(VK_DOWN))
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
				else if(KEYDOWN(VK_LEFT))
				{
					if(map[x[0]][y[0]-1]!=1 && map[x[1]][y[1]-1]!=1 && map[x[2]][y[2]-1]!=1 && map[x[3]][y[3]-1]!=1 && map[x[0]][y[0]-1]!=2 && map[x[1]][y[1]-1]!=2 && map[x[2]][y[2]-1]!=2 && map[x[3]][y[3]-1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]--;   
						y[1]--;
						y[2]--;
						y[3]--;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_RIGHT))
				{
					if(map[x[0]][y[0]+1]!=1 && map[x[1]][y[1]+1]!=1 && map[x[2]][y[2]+1]!=1 && map[x[3]][y[3]+1]!=1 && map[x[0]][y[0]+1]!=2 && map[x[1]][y[1]+1]!=2 && map[x[2]][y[2]+1]!=2 && map[x[3]][y[3]+1]!=2)  
					{ 
						map[x[0]][y[0]]=0;
						map[x[1]][y[1]]=0;
						map[x[2]][y[2]]=0;
						map[x[3]][y[3]]=0;
						y[0]++;   
						y[1]++;
						y[2]++;
						y[3]++;
						map[x[0]][y[0]]=3;
						map[x[1]][y[1]]=3;  
						map[x[2]][y[2]]=3;
						map[x[3]][y[3]]=3;
						tetris::draw_engine(map);
					}
				}
				else if(KEYDOWN(VK_UP))
				{
					if(y[1] == y[3])
					{			
						if(y[0]<y[2])
						{
							if(map[x[2]+1][y[2]]==0 && map[x[3]][y[3]+1]==0 && map[x[0]-1][y[0]]==0 && map[x[1]-1][y[1]]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[3]--;
								x[3]--;
								x[2]++;
								y[2]--;
								y[0]++;
								x[0]--;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
						else
						{
							if(map[x[3]][y[3]+1]==0 && map[x[3]][y[3]-1]==0 && map[x[1]+1][y[1]]==0 && map[x[0]+1][y[0]]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								x[0]++;
								y[0]--;
								y[2]++;
								x[2]--;
								y[3]++;
								x[3]++;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
					}
					else if(x[1] == x[3])
					{
						if(x[2]<x[0])
						{
							if(map[x[2]][y[2]+1]==0 && map[x[3]+1][y[3]]==0 && map[x[0]][y[0]-1]==0 && map[x[1]][y[1]-1]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[0]--;
								x[0]--;
								x[3]++;
								y[3]--;
								y[2]++;
								x[2]++;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
						else
						{
							if(map[x[0]][y[0]+1]==0 && map[x[1]][y[1]+1]==0 && map[x[2]][y[2]-1]==0 && map[x[0]][y[0]-1]==0)
							{
								map[x[0]][y[0]] = 0;
								map[x[1]][y[1]] = 0;
								map[x[2]][y[2]] = 0;
								map[x[3]][y[3]] = 0;
								y[0]++;
								x[0]++;
								y[3]++;
								x[3]--;
								y[2]--;
								x[2]--;
								map[x[0]][y[0]]=3;
								map[x[1]][y[1]]=3;  
								map[x[2]][y[2]]=3;
								map[x[3]][y[3]]=3;
								tetris::draw_engine(map);
							}
						}
					}
				}
				else
				{
					map[x[0]][y[0]]=0;
					map[x[1]][y[1]]=0;
					map[x[2]][y[2]]=0;
					map[x[3]][y[3]]=0;
					x[0]++;   
					x[1]++;
					x[2]++;
					x[3]++;
					map[x[0]][y[0]]=3;
					map[x[1]][y[1]]=3;  
					map[x[2]][y[2]]=3;
					map[x[3]][y[3]]=3;
					tetris::draw_engine(map);
				}
			} // end of while
			map[x[0]][y[0]]=1;
			map[x[1]][y[1]]=1;  
			map[x[2]][y[2]]=1;
			map[x[3]][y[3]]=1;
		}
		else return score;
		counter=0;
		for(int h=0;h<4;h++)
		{
			for(int g=0;g<26;g++)
			{
				if(map[x[h]][g]==1||map[x[h]][g]==2)
					counter++;
			}
			if(counter == 26)
				tetris::restack(map,x[h]);
			counter = 0;
		}
		break;
	}
	return -1;
}
int main()
{
	ShowWindow( GetConsoleWindow() , SW_MAXIMIZE);  // maximizing the window
	int map[30][26] =  {{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
	{  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }};
	tetris lol;
	int a,h,g,b=1;
	srand((unsigned)time(0));
	h = lol.menu();
	if(h == 1)
		return 0;
	while(b>0)
	{
		a = rand()%5+1;
		g = lol.objects(a,map);
		if(g!=-1)
			b=0;
	}
	cout << "game over. score: " << g << endl;
	system("pause");
	return 0;
}
feel free to point out anything wrong, if you have the patience to read it.
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Old 4 Weeks Ago   #6 (permalink)
Case Modder
 
Spotswood's Avatar
 
Join Date: Jul 2008
Location: New Hampshire, USA
Posts: 236

Rep: 46 Spotswood is acknowledged by some
Unique Rep: 39
Trader Rating: 0
Default

I agree with you, the code is unreadable. Its unreadable because of the deeply nested loops, bad variable names, "magic" numbers, duplicate chunks of code that are repeated over and over again, "God" methods, etc. Now that it works, it should be fairly easy to refactor a chunk of code, retest and refactor some more code and repeat until you can't refactor it anymore.
__________________
Rich
Custom Wooden Case Builder
Overclock.net Mod of the Month
Spotswood is online now   Reply With Quote
Old 4 Weeks Ago   #7 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 318

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

im planing on changing the whole structure of the code.
Right now its hard to make an exit for the program because of function calls inside functions also the fact that theres no point in having a class since i only create 1 object with it.
Also i hate the way object are handled now. I would like to create 2 separate functions: one to deal with keyboard input and the other to create objects on the map. that way the objects could be totally customizable.
Im pretty sure i could turn this into a 500 line code or less.
Any tips before i start?
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Old 3 Weeks Ago   #8 (permalink)
Case Modder
 
Spotswood's Avatar
 
Join Date: Jul 2008
Location: New Hampshire, USA
Posts: 236

Rep: 46 Spotswood is acknowledged by some
Unique Rep: 39
Trader Rating: 0
Default

Quote:
Originally Posted by newbie1911 View Post
im planing on changing the whole structure of the code.
Right now its hard to make an exit for the program because of function calls inside functions also the fact that theres no point in having a class since i only create 1 object with it.
Also i hate the way object are handled now. I would like to create 2 separate functions: one to deal with keyboard input and the other to create objects on the map. that way the objects could be totally customizable.
Im pretty sure i could turn this into a 500 line code or less.
Any tips before i start?
Object Oriented Programming/Design helps us humans to break down complex software systems into small, manageable chunks that we can understand. The number of times a class will be used/instantiated (or even re-used) should never be a factor in the design of a system. For me, I would estimate that 90% of the classes/interfaces I have designed over the years have only every been used once.

The objects that I can glean from your code are: keyboard, map, draw engine, blocks, menu, score card and possibly a "collision detector."
__________________
Rich
Custom Wooden Case Builder
Overclock.net Mod of the Month
Spotswood is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 02:31 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.12030 seconds with 8 queries