public Game() : base(1280, 800, GraphicsMode.Default, "Y U PONG?!") { mousex = mousey = -1; VSync = VSyncMode.On; camera = new Camera(); camera.From = new Vector3(0, 0, -16); UseDebugCamera = false; GL.Enable(EnableCap.Texture2D); GL.ShadeModel(ShadingModel.Smooth); GL.ClearDepth(1.0f); GL.DepthFunc(DepthFunction.Lequal); GL.ColorMaterial(MaterialFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse); GL.Enable(EnableCap.ColorMaterial); GL.Enable(EnableCap.DepthTest); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); Appearance.init(); y_already_pressed = false; gamestate = new GameStateMainMenu(); //gamestate = new GameStateMatch(new CharacterNini(), new CharacterOOM(), true, false, GameStateMatch.MatchType.FREEPLAY); }
public GameStateMatch(Character char1, Character char2, bool human1, bool human2, MatchType type) { matchtype = type; won_p1 = won_p2 = 0; pause = true; GL.Enable(EnableCap.Texture2D); GL.ShadeModel(ShadingModel.Smooth); GL.ClearDepth(1.0f); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ColorMaterial(MaterialFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse); GL.Enable(EnableCap.ColorMaterial); GL.Enable(EnableCap.Blend); // GL.DepthFunc(DepthFunction.Lequal); GL.Enable(EnableCap.DepthTest); // human2 = true; Appearance.init(); lvl = new Level(); pads = new Pad[2]; pads[0] = new Pad(lvl, 0, Appearance.PongGenericAppearance); pads[1] = new Pad(lvl, 1, Appearance.PongGenericAppearance); balls = new Ball[1]; balls[0] = new Ball(); balls[0].Speed = Vector3.UnitX * 7; if (human1) { player1 = new Player(this, char1, pads[0], InputHuman.input1, char1.DefaultAppearance); } else { player1 = new Player(this, char1, pads[0], new InputAI(), char1.DefaultAppearance); } if (human2) { player2 = new Player(this, char2, pads[1], InputHuman.input2, char2.DefaultAppearance); } else { player2 = new Player(this, char2, pads[1], new InputAI(), char2.DefaultAppearance); } theEvents = new GameEventList(); theFieldlist = new FieldList(); const float hbarsize = 0.85f; player1.Healthbar = new Healthbar(new Vector3(lvl.SizeX / 2 - hbarsize / 2 * lvl.SizeX / 2, lvl.SizeY / 2 * 1.2f, 0), false, new Vector3(lvl.SizeX / 2 * hbarsize, 0.4f, 1)); player2.Healthbar = new Healthbar(new Vector3(-lvl.SizeX / 2 + hbarsize / 2 * lvl.SizeX / 2, lvl.SizeY / 2 * 1.2f, 0), true, new Vector3(lvl.SizeX / 2 * hbarsize, 0.4f, 1)); GL.Enable(EnableCap.Lighting); // Let there Be Light float R0 = pads[0].theAppearance.Color.R; float G0 = pads[0].theAppearance.Color.G; float B0 = pads[0].theAppearance.Color.B; float R1 = pads[1].theAppearance.Color.R; float G1 = pads[1].theAppearance.Color.G; float B1 = pads[1].theAppearance.Color.B; const float light_height = 12.5f; light5_ambient = new Color4(0.6f, 0.6f, 0.6f, 1); light5_diffuse = new Color4(0.6f, 0.6f, 0.6f, 1); light5_specular = new Color4(1.0f, 1.0f, 1.0f, 1); light5_pos = new Vector4(lvl.SizeX / 4, 0, light_height, 1); light5_dir = new Vector4(0, 0, -1, 0); light6_ambient = new Color4(0.6f, 0.6f, 0.6f, 1); light6_diffuse = new Color4(0.6f, 0.6f, 0.6f, 1); light6_specular = new Color4(1.0f, 1.0f, 1.0f, 1); light6_pos = new Vector4(-lvl.SizeX / 4, 0, light_height, 1); light6_dir = new Vector4(0, 0, -1, 0); SetAmbientLight(); GL.Enable(EnableCap.Light5); GL.Enable(EnableCap.Light6); ResetRound(); pause = false; }