예제 #1
0
//Initialize the player.
Player::Player() {
	Loader loader;
	this->tex = loader.loadTexture("assets/pics/player.png");
	this->setTexture(tex);

	this->setTextureRect(sf::IntRect(0, 0, 170, 222));
	this->setOrigin(this->getLocalBounds().width / 2, this->getLocalBounds().height / 2);
	this->setScale(sf::Vector2f(0.3, 0.3));
	
	this->shieldTex = loader.loadTexture("assets/pics/shield.png");
	this->shieldTex.setSmooth(true);
	this->shield.setTexture(shieldTex);
	this->shield.setScale(sf::Vector2f(1.5, 1.5));

	this->spawnPoint = sf::Vector2f(400, 500);
	this->setPosition(sf::Vector2f(spawnPoint));
	this->health = 100;
	this->damage = 10;
	this->ammoDescription = "Red Rays of Happiness";
	this->shieldCharge = 200;
	this->isShielded = false;
	this->setRotation(0);
	this->acceleration = .2f;
	this->maxVelocity = 5.f;
	this->velocity = sf::Vector2f(0, 0);
	this->alive = true;
	this->isDying = false;
	this->pointMultiplier = 1;
	this->rateOfFire = 0.2;
	this->frameCount = 0;
}
예제 #2
0
//Constructor takes in the texture path and an id for the Power-Up.
Powerups::Powerups(string path, string id) {	
	Loader loader;
	this->setRadius(20);
	this->tex = loader.loadTexture(path);
	this->tex.setSmooth(true);
	this->setTexture(&tex);
	this->id = id;
}
예제 #3
0
Water::Water(float x, float height, float z, glm::vec3 scale, Loader &loader, DisplayManager *display)
{
	this->display = display;
	modelMatrix = MyMaths::createTransformationmatrix(glm::vec3(x, height, z), 0, 0, 0,
		scale);
	this->x = x;
	this->z = z;
	this->height = height;
	this->scale = scale;
	reflectionBuffer.createFrameBuffer(1024, 1024);
	reflectionBuffer.createTextureAttachment();
	reflectionBuffer.createDepthBufferAttachment();

	refractionBuffer.createFrameBuffer(1024, 1024);
	refractionBuffer.createTextureAttachment();
	refractionBuffer.createWaterDepthTextureAttachment();
	dudvID = loader.loadTexture("./res/waterDUDV.png");
	normalMap  = loader.loadTexture("./res/matchingNormalMap.png");
}
예제 #4
0
//Constructor. Only takes in the spawn position and initializes the Marauder.
Marauder::Marauder(sf::Vector2f spawn) {
	Loader loader;
	this->tex = loader.loadTexture("assets/pics/marauder.png");
	this->setTexture(tex);
	
	this->setTextureRect(sf::IntRect(0, 0, 162, 234));
	this->setOrigin(this->getLocalBounds().width / 2, this->getLocalBounds().height / 2);
	this->setScale(sf::Vector2f(0.7, 0.7));
	this->setPosition(spawn);
	this->setRotation(0);
	this->damage = 20;
	this->score = 40;
	this->health = 120;
	this->velocity = sf::Vector2f(1.5, 1.5);
	this->frameCount = 0;
}
예제 #5
0
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{




#pragma region win_set


    WNDCLASSEX wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.lpszClassName = "WindowClass";

    RegisterClassEx(&wc);

    RECT wr = {0, 0, SW, SH};
    AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);

    hWnd = CreateWindowEx(NULL,
                          "WindowClass",
                          "DirextX",
                          WS_DLGFRAME,
                          300,
                          300,
                          wr.right - wr.left,
                          wr.bottom - wr.top,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);

    ShowWindow(hWnd, nCmdShow);

	#pragma endregion Window_Setup


	

	//spawn a console window,useful for debugging ect
	AllocConsole() ;
    AttachConsole( GetCurrentProcessId() ) ;
	freopen("CONIN$", "r", stdin); 
	freopen("CONOUT$", "w", stdout); 
	freopen("CONOUT$", "w", stderr); 

	



////////////////////////////////////////////////////

////////////////////////////////////////////////////
	/*
	Comm * NewComm = new Comm;
	
	NewComm->setup();
	
	NewComm->RECIVE();

	*/


	//setup object
	DxSetup * DX = new DxSetup;

	DX->InitD3D();
	DX->InitPipeline();
	

	Loader *load = new Loader;

	load->loadTexture("Kan.png");
	//load->InitLoad("AssetList.txt");
	load->LoadObj("cube.obj");
	load->LoadObj("spit.obj");
	load->LoadObj("box.obj");
	



	//camera obj
	Cam * CamOverView = new Cam;
	MlistTest.push_back(CamOverView);

	//set inittal Camrea postion
	cX = 0.0f;
	cY = 0.0f;
	cZ = -50.0f;

	
	MSG msg;

	devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.1f, 0.1f, 0.1f, 1.0f));
    devcon->ClearDepthStencilView(zbuffer, D3D11_CLEAR_DEPTH, 1.0f, 0);



    while(1)
    {
		  if( PeekMessage( &msg, NULL, 0, 0,PM_NOREMOVE ) )
        {
			
			//std::cout<<msg.message << std::endl; // output the current windows msg

		 if (msg.message ==  WM_QUIT)
			{}
		 	
		 if (msg.message == WM_KEYDOWN)
			{
				switch (msg.wParam)
				{



				case VK_F1:
					{
						float x = std::rand() % 20 + 1;
						float y = std::rand() % 20 + 1;


						TestObj * TOVT = new TestObj;
						TOVT->X = x;
						TOVT->Y = y;
						TOVT->Model = 0;
						MlistTest.push_back(TOVT);
					}


					break;

				case VK_F2:
					{
						float x = std::rand() % 20 + 1;
						float y = std::rand() % 20 + 1;


						TestObj * TOVT = new TestObj;
						TOVT->X = x;
						TOVT->Y = y;
						TOVT->Model = 1;
						MlistTest.push_back(TOVT);
					}
					break;


				case VK_F4:
					{
						
						
					}
				break;

				case VK_F5:
					{
					std::cout << "current Camera postion" << std::endl;
					std::cout << "----------------------" << std::endl;
					std::cout << "X =" <<cX << std::endl;
					std::cout << "Y =" <<cY << std::endl;
					std::cout << "Z =" <<cZ << std::endl;
					}
				break;

				case VK_F7:
					std::cout << "Max size is: " << MlistTest.max_size() << std::endl;
				break;



				case VK_ESCAPE:
					DX->CleanD3D();
					exit(0);
					break;

				default:
					break;
				
				}
			}

		 else 
				{
					//TranslateMessage( &msg );
					//DispatchMessage( &msg );           
				}	
		  }
	
		


		/*

		  if(NS == 1)
		  {
				TestObj * TOVT = new TestObj;
				MlistTest.push_back(TOVT);
				TOVT->X = 1.0f;
				TOVT->Y = 1.0f;
				TOVT->AltVertexInBufferTest = false;
				TOVT->InterInfoObj = obj2;
				TOVT->IsNetPlayer = true;
				MlistTest.push_back(TOVT);
		  }

		  */


		  for(int i = 0; i < MlistTest.size();i++)
		  {
			  MlistTest.at(i)->Render();
		  }

		  if(globalneedToRevertex =true)
		  {globalneedToRevertex = false;}

		  
	swapchain->Present(0, 0);	
	devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.1f, 0.5f, 0.1f, 1.0f));
	devcon->ClearDepthStencilView(zbuffer, D3D11_CLEAR_DEPTH, 1.0f, 0);


    }

    // clean up DirectX and COM

	DX->CleanD3D();
    return msg.wParam;
}