Zvjezdan23 -13 Junior Poster

Hi everyone! =) Since my teacher can't help me out or doesn't respond when his hours say he's in his online office, I need some help. I am coding Tetris; and I have to say I'm doing a decent job so far. I just need help with constant movement. =/ I have made some test code that I am currently working on and using in my project. Can anyone help me out please??? =/ I really need the help.

#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <conio.h>
#include <windows.h>
#include <stdio.h>

#define PAGE_UP     73
#define HOME        71
#define END         79
#define PAGE_DOWN   81
#define UP_ARROW    72
#define LEFT_ARROW  75
#define DOWN_ARROW  80
#define RIGHT_ARROW 77
#define F1          59
#define F2          60
#define F3          61
#define F4          62
#define F5          63
#define F6          64
#define F7          65
#define F8          66
#define F9          67
#define F10         68

using namespace std;

int gotoxy(int x, int y) // used to make window
{  
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD point;
   	point.X = x-1;
	point.Y = y-1;     
   	SetConsoleCursorPosition(hConsole, point);
   	return SetConsoleCursorPosition(hConsole, point);
}

void object()
{
	cout << "7" << endl;
}

int main()
{
	system("mode 80,50");

	char ch_, key, key_, ch;
	char up, down, left, right;


	a: cout << "Press up arrow key: ";
	ch_ = getch();

	if (kbhit())
	{
		ch_ = getch();

		if (ch_ == UP_ARROW)
		{
			ch_ = UP_ARROW;
			up = ch_;
			cout << up << endl;
		}

		else if (ch_ != UP_ARROW)
		{
			cout << "Not the up arrow key" << endl;
			system("pause");
			system("cls");
			goto a;
		}
	}

	b: cout << "Press down arrow key: ";
	key = getch();

	if (kbhit())
	{
		key = getch();

		if (key == DOWN_ARROW)
		{
			key = DOWN_ARROW;
			down = key;
			cout << down << endl;
		}

		else if (key != DOWN_ARROW)
		{
			cout << "Not the down arrow key" << endl;
			system("pause");
			system("cls");
			goto b;
		}
	}

	c: cout << "Press left arrow key: ";
	key_ = getch();

	if (kbhit())
	{
		key_ = getch();

		if (key_ == LEFT_ARROW)
		{
			key_ = LEFT_ARROW;
			left = key_;
			cout << left << endl;
		}

		else if (key_ != LEFT_ARROW)
		{
			cout << "Not the left arrow key" << endl;
			system("pause");
			system("cls");
			goto c;
		}
	}

	d: cout << "Press right arrow key: ";
	ch_ = getch();

	if (kbhit())
	{
		ch_ = getch();

		if (ch_ == RIGHT_ARROW)
		{
			ch_ = RIGHT_ARROW;
			right = ch_;
			cout << right << endl;
		}

		else if (ch_ != RIGHT_ARROW)
		{
			cout << "Not the right arrow key" << endl;
			system("pause");
			system("cls");
			goto d;
		}
	}

	system("cls");

	int object_x = 15;
	int object_y = 20;

	gotoxy(object_x,object_y);
	object();

	int x = 1;
	int y = 1;

	char movement;

	do
	{
		gotoxy(3,30);
	cout << "Enter movement key: ";
	movement = getch();
	gotoxy(3,29);
	cout << "                                      " << endl;

	if(kbhit())
	{
		movement = getch();

		if(movement == up)
		{
			int go_up = (object_y - y);
			object_y = go_up;

			gotoxy(object_x,object_y);
			object();

			if (object_y == 1)
			{
				goto bottom;
			}

			else
			gotoxy(3,29);
			cout << "You moved north" << endl;
		}

		else if (movement == down)
		{
			int go_down = (object_y + y);
			object_y = go_down;

			gotoxy(object_x, object_y);
			object();

			if (object_y == 48)
			{
				goto bottom;
			}

			else

			gotoxy(3,29);
			cout << "You went down" << endl;
		}

		else if (movement == left)
		{
			int go_left = (object_x - x);
			object_x = go_left;

			gotoxy(object_x,object_y);
			object();

			if (object_x == 2)
			{
				goto bottom;
			}

			else 
			gotoxy(3,29);
			cout << "You went left" << endl;
		}

		else if (movement == right)
		{
			int go_right = (object_x + x);
			object_x = go_right;

			gotoxy(object_x,object_y);
			object();

			if (object_x == 77)
			{
				goto bottom;
			}

			else

			gotoxy(3,29);
			cout << "You went right" << endl;
		}
	}
}while (object_x != 77 || object_x != 2 || object_y != 48 || object_y != 1);

	bottom: gotoxy(3,37);
	system("pause");
	return 0;
}