예제 #1
0
파일: main_file.cpp 프로젝트: kkapitan/Maze
void DrawMaze()
{
	if (cur_layer){
		M.PreviousLayer();
		DrawWalls(cur_layer - 1);
		DrawFloor(cur_layer - 1);
		M.NextLayer();
	}
	if (cur_layer < layers - 1){
		M.NextLayer();
		DrawWalls(cur_layer + 1);
		DrawCeiling(cur_layer + 1);
		M.PreviousLayer();
	}
	DrawLayer(cur_layer);

	
}
예제 #2
0
int main()
{
	int parent_x, parent_y;
START:
	head = (psnakeHead)malloc(sizeof(snakeHead));
	head -> length = 0;
	head -> row = 14;
	head -> col = 14;
	head -> pbody = NULL;
	head -> headdirection = RIGHT;
	InitSnake(head);

    initscr();  
    raw();                  /* close row buffer */
    cbreak();               /* put termial to CBREAK mode */  
    noecho();  
    curs_set(FALSE);            /* set cursor invisible */  
    keypad(stdscr,TRUE);    /* recognise user's function key,F1,F2,...
							   display some message about title and wall */  
    signal(SIGALRM, StartAlarm);  
	getmaxyx(stdscr, parent_y, parent_x);
	WINDOW *welwin = newwin(29, parent_x, 0, 0);
	WINDOW *lelwin = newwin(7, parent_x, 30, 0);
	if (!welwin || !lelwin) {
		Die("Unable to allocate window memory\n");
	}
	Welcome(welwin, 29, parent_x);
	int speed = Choice(lelwin);
    Set_ticker(speed);  
	DrawWalls();
    StartAlarm();
    foodpos = DisplayFood(head);
    while(!isfailed && chinput !='q') {
        chinput = getch();
		ControlSnake(chinput, head);
    }
    if(isfailed) {
		ClearScr(LEFT_EDGE+1, RIGHT_EDGE-1, TOP_ROW+1, BUT_ROW-1);		//mark
		free(head -> pbody);
		free(head);
		head = NULL;
    }
    if(isrestart) {
        isfailed = 0;
        isrestart = 0;      // clear the flag
        goto START;    		// go to the START statement
    }
	endwin();
	return 0;
}
예제 #3
0
void RenderWorld()
{
    // This function will draw our entire scene except for the light.
    // We could speed up our application by not using quadrics and using
    // display lists, but just to make things simple I chose to not add extras.

    // Draw our walls and move them back into the screen by 15
    glPushMatrix();
    glTranslatef(0, 0, -15);
    DrawWalls();
    glPopMatrix();

    // Color the tube green
    glColor4f(0.0f, 1.0f, 0.1f, 1.0);

    // Create a new quadric and render it normally
    GLUquadricObj *pObj = gluNewQuadric();
    gluQuadricDrawStyle(pObj, GLU_FILL);

    // Create an empty tube that spins around
    glPushMatrix();
    static float rotY = 0;
    glTranslatef(-2, 0, -10);
    glRotatef(rotY++, 0, 1, 0);
    gluCylinder(pObj, 0.5f, 0.5f, 2.0f, 25, 25);
    glPopMatrix();

    // Color the sphere yellow
    glColor4f(1.0f, 1.0f, 0.1f, 1.0);

    // Create the sphere and move it back and to the right of the tube
    glPushMatrix();
    glTranslatef(2, 0, -10);
    gluSphere(pObj, 0.5f, 25, 25);
    glPopMatrix();

    // Free the quadric object
    gluDeleteQuadric(pObj);
}
예제 #4
0
파일: Vessel.cpp 프로젝트: NickPowers43/SW
	void Vessel::DrawWorld()
	{
		if (myPlayer)
		{
			camera.position = myPlayer->pos;

			glm::mat4 viewMat(1.0f);
			camera.GenerateView(viewMat);

			glUseProgram(floorProgram.program);
			glActiveTexture(GL_TEXTURE0);
			glBindTexture(GL_TEXTURE_2D, floorProgram.texture);
			glUniformMatrix4fv(floorProgram.viewMat, 1, false, glm::value_ptr(viewMat));
			glUniform1i(floorProgram.textureLoc, 0);

			DrawFloor();

			glUseProgram(coloredVertexProgram.program);
			glm::vec4 color(0.5f, 0.5f, 0.5f, 1.0f);
			glUniform4fv(coloredVertexProgram.color, 1, glm::value_ptr(color));
			glUniformMatrix4fv(coloredVertexProgram.viewMat, 1, false, glm::value_ptr(viewMat));

			DrawWalls();

			glDisable(GL_CULL_FACE);
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			glUseProgram(shadowProgram.program);
			glUniform2fv(shadowProgram.playerPos, 1, glm::value_ptr(camera.position));
			glUniformMatrix4fv(shadowProgram.viewMat, 1, false, glm::value_ptr(viewMat));

			DrawShadows();

			glEnable(GL_CULL_FACE);
			glDisable(GL_BLEND);
		}
	}
예제 #5
0
파일: main_file.cpp 프로젝트: kkapitan/Maze
void DrawLayer(int layer)
{
	DrawCeiling(layer);
	DrawFloor(layer);
	DrawWalls(layer);
}
예제 #6
0
파일: Main.cpp 프로젝트: Odinra/DirectX
bool Display(float timeDelta)
{
	if( Device )
	{
		if(::GetAsyncKeyState('P') & 0x8000f)
			pause = true;
		if(::GetAsyncKeyState('W') & 0x8000f)
			TheCamera.walk(1.0 * DTime);
		if(::GetAsyncKeyState('S') & 0x8000f)
			TheCamera.walk(-1.0 * DTime);
		if(::GetAsyncKeyState('A') & 0x8000f)
			TheCamera.strafe(-1.0 * DTime);
		if(::GetAsyncKeyState('D') & 0x8000f)
			TheCamera.strafe(1.0 * DTime);
		if(::GetAsyncKeyState('F') & 0x8000f)
			TheCamera.fly(-1.0 * DTime);
		if(::GetAsyncKeyState('R') & 0x8000f)
			TheCamera.fly(1.0 * DTime);
		if(::GetAsyncKeyState(VK_UP) & 0x8000f)
			TheCamera.pitch(-.250 * DTime);
		if(::GetAsyncKeyState(VK_DOWN) & 0x8000f)
			TheCamera.pitch(.250 * DTime);
		if(::GetAsyncKeyState(VK_LEFT) & 0x8000f)
			TheCamera.yaw(-.250 * DTime);
		if(::GetAsyncKeyState(VK_RIGHT) & 0x8000f)
			TheCamera.yaw(.250 * DTime);
		if(::GetAsyncKeyState(VK_HOME) & 0x8000f)
			TheCamera.roll(.250 * DTime);
		if(::GetAsyncKeyState(VK_END) & 0x8000f)
			TheCamera.roll(-.250 * DTime);
		if(TheCamera._up.y < 0)
			TheCamera._up.y *= -1;

		Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
		Device->BeginScene();
		DrawWalls();
		D3DXMATRIX i, tripler, grow;
		D3DXMatrixIdentity(&i);
		Device->SetTransform(D3DTS_WORLD, &i);
		
		//1
		D3DXMatrixTranslation(&tripler, TigerPos.x, TigerPos.y, TigerPos.z);
		D3DXMatrixScaling(&grow, 5/sizeModifier, 5/sizeModifier, 5/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Tiger.Draw(Stone);
		//2	
		D3DXMatrixTranslation(&tripler, CastlePos.x, CastlePos.y, CastlePos.z);
		D3DXMatrixScaling(&grow, 2.5/sizeModifier, 1/sizeModifier, 2.5/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Castle.Draw(Stone);
		//3		
		D3DXMatrixTranslation(&tripler, GrenadePos.x, GrenadePos.y, GrenadePos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Grenade.Draw(Stone);
		//4
		D3DXMatrixTranslation(&tripler, ManorPos.x, ManorPos.y, ManorPos.z);
		D3DXMatrixScaling(&grow, 5000/sizeModifier, 5000/sizeModifier, 50);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Manor.Draw(Stone);
		//5		
		D3DXMatrixTranslation(&tripler, MonsterPos.x, MonsterPos.y, MonsterPos.z);
		D3DXMatrixScaling(&grow, 1/sizeModifier, 1/sizeModifier, 1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Monster.Draw(Stone);
		//6		
		D3DXMatrixTranslation(&tripler, RavengerSirenPos.x, RavengerSirenPos.y, RavengerSirenPos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		RavengerSiren.Draw(Stone);
		//7		
		D3DXMatrixTranslation(&tripler, SectoidPos.x, SectoidPos.y, SectoidPos.z);
		D3DXMatrixScaling(&grow, 3/sizeModifier, 3/sizeModifier, 3/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Sectoid.Draw(Stone);
		//8		
		D3DXMatrixTranslation(&tripler, SlendermanPos.x, SlendermanPos.y, SlendermanPos.z);
		D3DXMatrixScaling(&grow, .05/sizeModifier, .05/sizeModifier, .05/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Slenderman.Draw(Stone);
		//9		
		D3DXMatrixTranslation(&tripler, SoccerPos.x, SoccerPos.y, SoccerPos.z);
		D3DXMatrixScaling(&grow, .05/sizeModifier, .05/sizeModifier, .05/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Soccer.Draw(Stone);
		//10		
		D3DXMatrixTranslation(&tripler, TurretPos.x, TurretPos.y, TurretPos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Turret.Draw(Stone);
		//11		
		D3DXMatrixTranslation(&tripler, UltramanPos.x, UltramanPos.y, UltramanPos.z);
		D3DXMatrixScaling(&grow, .01/sizeModifier, .01/sizeModifier, .01/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ultraman.Draw(Stone);
		//12		
		D3DXMatrixTranslation(&tripler, ZombiePos.x, ZombiePos.y, ZombiePos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Zombie.Draw(Stone);

		if(!shrunk && p.z > 10)
		{
			shrunk = true;
			sound.AudioPlay(Voice);
			::MessageBoxA(0, "OH NO! you appear to be Shrinking\nStart Running to try and reach the manor", "Oh No!", MB_OK);
			DTime *= 5;
		}
		else if(shrunk)
		{
			
			if(sizeModifier >1)
			{
				sizeModifier-=.005;
			}
			else if(message)
			{
				message = false;
				::MessageBoxA(0, "It's too late, however you seem to be at the entrance to a castle and there appears to be some createures on the inside.\nMaybe you should try to approach one of them, Be Careful Though: they could be Evil", "Too Late", MB_OK);
			}
		}
		static bool approach = false;
		if(!approach)
			if(p.z > 125)
			{
				::MessageBoxA(0, "The creatures seem to be frozen and have had all their color drained...\nThey look like they were once the things that only exis in nightmares\nWhat kind of Powerfull Monster could have done this?\nMaybe you shouldn't have ignored those warnings.", "", MB_OK);
				approach = true;
			}
			static bool bang = false;
		if(p.z > 0)
		{
			if(!bang)
			{
				bang = true;
				sound.AudioPlay(Bang);
			}
			Device->SetStreamSource(0, VBufferGround, 0, sizeof(Vertex));
			Device->SetFVF(FVF_VERTEX);
			Device->SetTexture(0, DoNot);
			Device->SetTransform(D3DTS_WORLD, &i);
			Device->DrawPrimitive(D3DPT_TRIANGLELIST, 36, 2);
			Device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
		}

		
		D3DXMATRIX V, T;
		TheCamera.getViewMatrix(&V);
		Device->SetTransform(D3DTS_VIEW, &V);
		TheCamera.getPosition(&p);
		if (p.y != 8.5)
			p.y = 8.5;
		TheCamera.setPosition(&p);
		TheCamera.getLook(&t);
		Device->EndScene();
		Device->Present(0, 0, 0, 0);
	}
	return true;
}