/// <summary> /// Initializes a new instance of the <see cref="nginz.MouseBuffer"/> class. /// </summary> public MouseBuffer(NativeWindow window, Game game = null, bool shouldCenterMouse = false, bool mouseVisible = true) { // Set the window this.window = window; this.game = game; // Initialize wheel and delta values Wheel = 0.0f; DeltaX = 0.0f; DeltaY = 0.0f; DeltaZ = 0.0f; // Initialize mouse coordinates X = window.Width / 2f; Y = window.Height / 2f; // Initialize mouse state State = Mouse.GetState (); // Initialize mouse client rectangle MouseClientRect = new Rectangle (State.X, State.Y, 1, 1); // Set mouse centered state ShouldCenterMouse = shouldCenterMouse; // Set mouse visible state CursorVisible = mouseVisible; // Center the mouse CenterMouse (); }
public MenuScene() : base("mainmenu") { // Get the game game = UIController.Instance.Game; // Load textures texMenu = game.Content.Load<Texture2D> ("flappymascot_menu_background.png"); texMap = game.Content.Load<Texture2D> ("flappymascot_map_new.png"); texOverlay = game.Content.Load<Texture2D> ("flappymascot_overlay.png"); // Create the layout CreateLayout (); // Subscribe to events btnStart.Click += (sender, e) => fadeOut = true; btnExit.Click += (sender, e) => game.Exit (); // Reset the layout ResetLayout (false); // Add the controls to the UI controller Controls.Add (btnStart); Controls.Add (btnExit); }
public Bird(Game game, TubeGenerator generator) { this.game = game; this.generator = generator; var sheetTex = game.Content.Load<Texture2D> ("flappymascot_char.png", TextureConfiguration.Nearest); sheet = new SpriteSheet2D (sheetTex, 4, 1); animator = new Animator (sheet, 4); animator.DurationInMilliseconds = 500; animator.Position.X = game.Resolution.Width * 0.25f; ypos = (game.Resolution.Height / 2) + (sheet [0].Height / 2); }
public TubeGenerator(Game game) { this.game = game; rng = new Random (); tubes = new List<TubeInstance> (); tube_top_large = game.Content.Load<Texture2D> ("flappymascot_tube_large_top.png"); tube_bottom_large = game.Content.Load<Texture2D> ("flappymascot_tube_large_bottom.png"); tube_top_normal = game.Content.Load<Texture2D> ("flappymascot_tube_normal_top.png"); tube_bottom_normal = game.Content.Load<Texture2D> ("flappymascot_tube_normal_bottom.png"); tube_top_small = game.Content.Load<Texture2D> ("flappymascot_tube_small_top.png"); tube_bottom_small = game.Content.Load<Texture2D> ("flappymascot_tube_small_bottom.png"); lastIndex = -1; AddTube (); }
public GameScene() : base("maingame") { game = UIController.Instance.Game; generator = new TubeGenerator (game); bird = new Bird (game, generator); lblScore = new Label (150, 20, "Roboto Regular") { X = 25, Y = game.Resolution.Height - 45, FontSize = 18f, Text = "Score: 0" }; backgroundLeft = 0f; blueTint = 0f; texMap = game.Content.Load<Texture2D> ("flappymascot_map_new.png"); Controls.Add (lblScore); }
public Stage(Game game) { this.game = game; }
/// <summary> /// Initializes the game internally. /// </summary> void InternalInitialize() { // Initialize graphics mode to default graphicsMode = GraphicsMode.Default; // Start with default window flags var flags = GameWindowFlags.Default; // Set Fullscreen flag if requested if (Configuration.Fullscreen && !flags.HasFlag (GameWindowFlags.Fullscreen)) flags |= GameWindowFlags.Fullscreen; // Set FixedWindow flag if requested if (Configuration.FixedWindow && !flags.HasFlag (GameWindowFlags.FixedWindow)) flags |= GameWindowFlags.FixedWindow; // Create window this.Log ("Creating native window"); window = new NativeWindow ( width: Configuration.Width, height: Configuration.Height, title: Configuration.WindowTitle, options: flags, mode: GraphicsMode.Default, device: DisplayDevice.Default ); // Update the resolution UpdateResolution (); // Register events window.KeyDown += Keyboard.RegisterKeyDown; window.KeyUp += Keyboard.RegisterKeyUp; window.KeyPress += delegate { }; // Initialize startTime and lastTime startTime = DateTime.UtcNow; lastTime = startTime; // Initialize the mouse buffer Mouse = new MouseBuffer (window, this); // Start the sound manager SoundManager = new SoundManager(); // Initialize the context manager Content = new ContentManager (AppDomain.CurrentDomain.BaseDirectory); Content.ContentRoot = this.Configuration.ContentRoot; ContentManager = Content; RegisterProviders (); Instance = this; }
/// <summary> /// Initializes a new instance of the <see cref="nginz.SpriteBatch"/> class. /// </summary> /// <param name = "game">The game.</param> /// <param name="shader">Shader.</param> public SpriteBatch(Game game, ShaderProgram shader = null) { // Set the game Game = game; // Compile predefined shaders if no shader program is given if (shader == null) { var vertShader = new VertexShader (vert_source); var fragShader = new FragmentShader (frag_source); Program = new ShaderProgram (vertShader, fragShader); Program.Link (); } else Program = shader; // Create the optimal buffer settings var settings = new GLBufferSettings { AttribSize = 0, Hint = BufferUsageHint.DynamicDraw, Normalized = false, Offset = 0, Target = BufferTarget.ArrayBuffer, Type = VertexAttribPointerType.Float }; // Create temp variables for indices int indPtr = 0; var tempIndices = new uint[MAX_INDICES]; // Fill temporary indices for (uint i = 0; i < MAX_VERTICES; i += 4) { // Triangle 1 tempIndices [indPtr++] = i; tempIndices [indPtr++] = i + 1; tempIndices [indPtr++] = i + 2; // Triangle 2 tempIndices [indPtr++] = i + 1; tempIndices [indPtr++] = i + 3; tempIndices [indPtr++] = i + 2; } // Set camera InternalCamera = new Camera (60f, game.Resolution, 0, 16, type: ProjectionType.Orthographic); // Set current texture CurrentTexture = Texture2D.Dot; // Generate array buffer object abo = GL.GenVertexArray (); // Create vertex buffer object vbo = new GLBufferDynamic<Vertex2D> (settings, Vertex2D.Size, MAX_VERTICES); // Create index buffer object ibo = new GLBuffer<uint> (GLBufferSettings.DynamicIndices, tempIndices); // Initialize vertices Vertices = new Vertex2D[MAX_VERTICES]; framebuffer = new Framebuffer (FramebufferTarget.Framebuffer, Game.Resolution.Width, game.Resolution.Height) .AttachTexture (FboAttachment.DiffuseAttachment, DrawBuffersEnum.ColorAttachment0, PixelInternalFormat.Rgb, PixelFormat.Rgb, PixelType.UnsignedByte, InterpolationMode.Linear); }