private void keyboard(object sender, PreviewKeyDownEventArgs e) { if (!camare.levelCompleted) { // Trucos if (e.KeyData == (Keys.Alt | Keys.C)) { camare.isCollision = !camare.isCollision; } else if (e.KeyData == (Keys.Alt | Keys.L)) { ligth.turnOn = !ligth.turnOn; } else if (e.KeyData == (Keys.Alt | Keys.T)) { isTransparency = !isTransparency; ligth.turnOn = true; } //-- else if (e.KeyData == Engine.Control.moveForward) { camare.moveForward(map.collisions); } else if (e.KeyData == Engine.Control.moveBack) { camare.moveBack(map.collisions); } else if (e.KeyData == Engine.Control.moveLeft) { camare.moveLeft(map.collisions); } else if (e.KeyData == Engine.Control.moveRight) { camare.moveRight(map.collisions); } else if (e.KeyData == Engine.Control.lookUp) { camare.lookUpKey(); } else if (e.KeyData == Engine.Control.lookDown) { camare.lookDownKey(); } else if (e.KeyData == Engine.Control.lookLeft) { camare.lookLeftKey(); } else if (e.KeyData == Engine.Control.lookRight) { camare.lookRightKey(); } else if (e.KeyData == Engine.Control.restart) { camare.position[0] = map.position[0]; camare.position[1] = map.position[1]; camare.position[2] = map.position[2]; camare.view[0] = map.view[0]; camare.view[1] = map.view[1]; camare.view[2] = map.view[2]; } } else if (e.KeyData == Engine.Control.go) { if (level == -2) { template = Engine.Template.levelCompleted(-2); ligth.turnOn = false; drawTemplate(); level = -1; } else if (level == -1) { template = Engine.Template.levelCompleted(-1); ligth.turnOn = false; drawTemplate(); level = 0; } else { startLevel(); } } if (camare.levelCompleted) { camare.position[0] = 0; camare.position[1] = 0; camare.position[2] = -10; camare.view[0] = 0; camare.view[1] = 0; camare.view[2] = -1; if (level >= 1 && level <= 3) { // Poner sonido Nivel Completado Engine.Sound.play("levelCompleted.wav"); //-- template = Engine.Template.levelCompleted(level); ligth.turnOn = false; drawTemplate(); } else if (level == 4) { // Poner sonido final Engine.Sound.play("end.wav"); //-- template = Engine.Template.levelCompleted(5); ligth.turnOn = false; drawTemplate(); System.Threading.Thread.Sleep(Engine.Constant.DELAY); template = Engine.Template.levelCompleted(6); ligth.turnOn = false; drawTemplate(); level = -2; } } if (e.KeyData == Engine.Control.exit) { this.Close(); } }
private void keyboard(object sender, PreviewKeyDownEventArgs e) { if (!camare.levelCompleted) { // Trucos if (e.KeyData == (Keys.Alt | Keys.C)) camare.isCollision = !camare.isCollision; else if (e.KeyData == (Keys.Alt | Keys.L)) ligth.turnOn = !ligth.turnOn; else if (e.KeyData == (Keys.Alt | Keys.T)) { isTransparency = !isTransparency; ligth.turnOn = true; } //-- else if (e.KeyData == Engine.Control.moveForward) camare.moveForward(map.collisions); else if (e.KeyData == Engine.Control.moveBack) camare.moveBack(map.collisions); else if (e.KeyData == Engine.Control.moveLeft) camare.moveLeft(map.collisions); else if (e.KeyData == Engine.Control.moveRight) camare.moveRight(map.collisions); else if (e.KeyData == Engine.Control.lookUp) camare.lookUpKey(); else if (e.KeyData == Engine.Control.lookDown) camare.lookDownKey(); else if (e.KeyData == Engine.Control.lookLeft) camare.lookLeftKey(); else if (e.KeyData == Engine.Control.lookRight) camare.lookRightKey(); else if (e.KeyData == Engine.Control.restart) { camare.position[0] = map.position[0]; camare.position[1] = map.position[1]; camare.position[2] = map.position[2]; camare.view[0] = map.view[0]; camare.view[1] = map.view[1]; camare.view[2] = map.view[2]; } } else if (e.KeyData == Engine.Control.go) { if (level == -2) { template = Engine.Template.levelCompleted(-2); ligth.turnOn = false; drawTemplate(); level = -1; } else if (level == -1) { template = Engine.Template.levelCompleted(-1); ligth.turnOn = false; drawTemplate(); level = 0; } else startLevel(); } if (camare.levelCompleted) { camare.position[0] = 0; camare.position[1] = 0; camare.position[2] = -10; camare.view[0] = 0; camare.view[1] = 0; camare.view[2] = -1; if (level >= 1 && level <= 3) { // Poner sonido Nivel Completado Engine.Sound.play("levelCompleted.wav"); //-- template = Engine.Template.levelCompleted(level); ligth.turnOn = false; drawTemplate(); } else if (level == 4) { // Poner sonido final Engine.Sound.play("end.wav"); //-- template = Engine.Template.levelCompleted(5); ligth.turnOn = false; drawTemplate(); System.Threading.Thread.Sleep(Engine.Constant.DELAY); template = Engine.Template.levelCompleted(6); ligth.turnOn = false; drawTemplate(); level = -2; } } if (e.KeyData == Engine.Control.exit) this.Close(); }
private void gl_Load(object sender, EventArgs e) { // Perspectivas GL.Viewport(0, 0, gl.Size.Width - 1, gl.Size.Height - 1); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); Glu.Perspective(90, (gl.Size.Width / gl.Size.Height), 0.1f, 10000f); GL.MatrixMode(MatrixMode.Modelview); //-- // Profundidad GL.ClearColor(Color.Black); GL.ClearDepth(1.0); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); //-- // Tipo de Material float[] mat_especular = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] mat_brillo = { 50.0f }; GL.ShadeModel(ShadingModel.Smooth); GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, mat_especular); GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, mat_brillo); GL.Enable(EnableCap.ColorMaterial); //-- // Textura GL.Enable(EnableCap.Texture2D); //-- // Camara camare = new Engine.Camera(0, 0, -10, 0, 0, -1, 4, 2.0, 0.2, 0.1, 0.5); //-- // Luz float[] white = { 1.0f, 1.0f, 1.0f, 1.0f }; ligth = new Engine.Light(); GL.Light(LightName.Light0, LightParameter.Ambient, white); GL.Light(LightName.Light0, LightParameter.Diffuse, white); GL.Light(LightName.Light0, LightParameter.Specular, white); GL.Light(LightName.Light0, LightParameter.SpotCutoff, 10); GL.Light(LightName.Light0, LightParameter.ConstantAttenuation, 2); GL.Enable(EnableCap.Light0); //-- // Trucos GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); //-- // Preconfiguracion de presentacion y nivel level = -1; template = Engine.Template.levelCompleted(-2); ligth.turnOn = false; drawTemplate(); camare.levelCompleted = true; //-- // Iniciar sonido Engine.Sound.play("init.wav"); //-- }
private void gl_Load(object sender, EventArgs e) { // Perspectivas GL.Viewport(0, 0, gl.Size.Width - 1, gl.Size.Height - 1); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); Glu.Perspective(90, (gl.Size.Width / gl.Size.Height), 0.1f, 10000f); GL.MatrixMode(MatrixMode.Modelview); //-- // Profundidad GL.ClearColor(Color.Black); GL.ClearDepth(1.0); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); //-- // Tipo de Material float[] mat_especular = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] mat_brillo = { 50.0f }; GL.ShadeModel(ShadingModel.Smooth); GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, mat_especular); GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, mat_brillo); GL.Enable(EnableCap.ColorMaterial); //-- // Textura GL.Enable(EnableCap.Texture2D); //-- // Camara camare = new Engine.Camera(0, 0, -10, 0, 0, -1, 4, 2.0, 0.2, 0.1, 0.5); //-- // Luz float[] white = { 1.0f, 1.0f, 1.0f, 1.0f }; ligth = new Engine.Light(); GL.Light(LightName.Light0, LightParameter.Ambient, white); GL.Light(LightName.Light0, LightParameter.Diffuse, white); GL.Light(LightName.Light0, LightParameter.Specular, white); GL.Light(LightName.Light0, LightParameter.SpotCutoff, 10); GL.Light(LightName.Light0, LightParameter.ConstantAttenuation, 2); GL.Enable(EnableCap.Light0); //-- // Trucos GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); //-- // Preconfiguracion de presentacion y nivel level = -1; template = Engine.Template.levelCompleted(-2); ligth.turnOn = false; drawTemplate(); camare.levelCompleted = true; //-- // Iniciar sonido Engine.Sound.play("init.wav"); //-- }