Example #1
0
void GameLoop::OnKeyDown(const SDL_Keycode ac_sdlSym, const Uint16 ac_uiMod, const SDL_Scancode ac_sdlScancode)
{
	switch (ac_sdlSym)
	{
	case SDLK_ESCAPE: m_bRunning = false; break; // End the loop

	//This will move circle object right //made be me Brock Barlow
	case SDLK_h:
		pos.X += 5; 
		pos2.X += 5; 
		break;
	
	//This will move circle object left //made be me Brock Barlow
	case SDLK_f:
		pos.X -= 5; 
		pos2.X -= 5; 
		break;
	
	//This will move circle object up //made be me Brock Barlow
	case SDLK_t:
		pos.Y -= 5; 
		pos2.Y -= 5; 
		break;
	
	//This will move circle object down //made be me Brock Barlow
	case SDLK_b:
		pos.Y += 5; 
		pos2.Y += 5; 
		break;
	
	//This will make circle object bigger //made be me Brock Barlow
	case SDLK_y:
		scale.X += 5; 
		break;
	
	//This will make circle object smaller //made be me Brock Barlow
	case SDLK_r:
		scale.X -= 5; 
		break;
	
	//This will increase the scale of circle object //made be me Brock Barlow
	case SDLK_n:
		scale.Y += 5; 
		break;
	
	//This will decrease the scale of circle object //made be me Brock Barlow
	case SDLK_v:
		scale.Y -= 5; 
		break;
	
	//This will make a circle appear inside of circle object //made by me Brock Barlow
	case SDLK_g: 
		appear = true; 
		if (appear = true) //This smaller circle will only appear if this key is pressed down //made by me Brock Barlow
		{
			col2.Alpha = 255; 
		}
		break; 
	
	//This will display vector 2D math //made be me Brock Barlow
	case SDLK_1:
		cout << "2D vector A and B:" << endl; //info //made by me (Brock Barlow)
		A.x = 5, A.y = 4; //A = (5,4) //made by me (Brock Barlow)
		B.x = -2, B.y = 5; //B = (-2,5) //made by me (Brock Barlow)
		A.print2(); //print test //made by me (Brock Barlow)
		B.print2(); //print test //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "2D vector addition:" << endl; //info //made by me (Brock Barlow)
		C = A + B; //C will equal ((A.x + B.x)(A.y + B.y)) //made by me (Brock Barlow)
		C.print2(); //print C add value //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "2D vector subtraction:" << endl; //info //made by me (Brock Barlow)
		C = A - B; //C will equal ((A.x - B.x)(A.y - B.y)) //made by me (Brock Barlow)
		C.print2(); //print C sub value //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "2D vector magnitude:" << endl; //info //made by me (Brock Barlow)
		cout << "Magnitude of A is: " << A.mag2() << endl; //info and prints out magnitude of vector A //made by me (Brock Barlow)
		cout << "Magnitude of B is: " << B.mag2() << endl; //info and prints out magnitude of vector B //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "2D vector normalise:" << endl; //info //made by me (Brock Barlow)
		cout << "Normalise vector A is: " << A.nor2X() << " " << A.nor2Y() << endl; //info and prints out normalise x and y of vector A //made by me (Brock Barlow)
		cout << "Normalise vector B is: " << B.nor2X() << " " << B.nor2Y() << endl; //info and prints out normalise x and y of vector B //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "2D vector dot product:" << endl; //info //made by me (Brock Barlow)
		C = A * B; //C will equal ((A.x * B.x)(A.y * B.y))  //made by me (Brock Barlow)
		C.dot2(); //This will print out the dot product of C //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		break;
	
	//This will display vector 3D math //made be me Brock Barlow
	case SDLK_2:
		cout << "3D vector D and E:" << endl; //info //made by me (Brock Barlow)
		D.x = -7, D.y = 9, D.z = 2; //D = (-7,9,2) //made by me (Brock Barlow)
		E.x = 3, E.y = 14, E.z = -3; //E = (3,14,-3) //made by me (Brock Barlow)
		D.print3(); //print test //made by me (Brock Barlow)
		E.print3(); //print test //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "3D vector addition:" << endl; //info //made by me (Brock Barlow)
		F = D + E; //F will equal ((D.x + E.x)(D.y + E.y)(D.z + E.z)) //made by me (Brock Barlow)
		F.print3(); //print F add value //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "3D vector subtraction:" << endl; //info //made by me (Brock Barlow)
		F = D - E; //F will equal ((D.x - E.x)(D.y - E.y)(D.z - E.z)) //made by me (Brock Barlow)
		F.print3(); //print F sub value //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "3D vector magnitude:" << endl; //info //made by me (Brock Barlow)
		cout << "Magnitude of D is: " << D.mag3() << endl; //info and prints out magnitude of vector D //made by me (Brock Barlow)
		cout << "Magnitude of E is: " << E.mag3() << endl; //info and prints out magnitude of vector E //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "3D vector normalise:" << endl; //info //made by me (Brock Barlow)
		cout << "Normalise vector D is: " << D.nor3X() << " " << D.nor3Y() << " " << D.nor3Z() << endl; //info and prints out normalise x, y and z of vector D //made by me (Brock Barlow)
		cout << "Normalise vector E is: " << E.nor3X() << " " << E.nor3Y() << " " << E.nor3Z() << endl; //info and prints out normalise x, y and z of vector E //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "3D vector dot product:" << endl; //info //made by me (Brock Barlow)
		F = D * E; //F will equal ((D.x * E.x)(D.y * E.y)(D.z * E.z)) //made by me (Brock Barlow)
		F.dot3(); //This will print out the dot product of F //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		cout << "3D vector cross product:" << endl; //info //made by me (Brock Barlow)
		F = D / E; //F will equal cross product of vectors D and E //made by me (Brock Barlow)
		F.print3(); //print F cross product value //made by me (Brock Barlow)
		cout << endl; //new line //made by me (Brock Barlow)
		break;
	
	//This will display the square of x and y //made be me Brock Barlow
	case SDLK_3: 
		cout << "X squared:" << endl; 
		cout << pX << endl; 
		cout << pX2 << endl; 
		cout << pX3 << endl; 
		cout << pX4 << endl; 
		cout << endl; 
		cout << "Y squared:" << endl; 
		cout << pY << endl; 
		cout << pY2 << endl; 
		cout << pY3 << endl; 
		cout << pY4 << endl; 
		cout << endl;
		break;

	default:
		printf("%s\n",SDL_GetKeyName(ac_sdlSym)); break;
	}

	switch (ac_sdlSym)
	{
	//On key press, player one and two will have movement //made by me Brock Barlow
	case SDLK_s:
		movePODN = true;
		break;
	case SDLK_w:
		movePOUP = true;
		break;
	case SDLK_k:
		movePTDN = true;
		break;
	case SDLK_i:
		movePTUP = true;
		break;
	}
}