Beispiel #1
0
 public override void Draw(GameTime time, SpriteBatch batch)
 {
     batch.Draw (texMap, OpenTK.Vector2.Zero, Color4.White);
     batch.Draw (texOverlay, OpenTK.Vector2.Zero, new Color4 (1, 1, 1, overlayAlpha));
     batch.Draw (texMenu, OpenTK.Vector2.Zero, new Color4 (1, 1, 1, menuAlpha));
     base.Draw (time, batch);
 }
Beispiel #2
0
 public override void Draw(GameTime time, SpriteBatch batch)
 {
     var tint = new Color4 (1 - (blueTint * 3f), 1f - (blueTint * 2f), 1f - blueTint, 1);
     batch.Draw (texMap, new Vector2 (backgroundLeft, 0), tint);
     if (backgroundLeft < 640)
         batch.Draw (texMap, new Vector2 (backgroundLeft + texMap.Width, 0), tint);
     bird.Draw (time, batch);
     generator.Draw (time, batch);
     base.Draw (time, batch);
 }
Beispiel #3
0
 public void Draw(GameTime time, SpriteBatch batch)
 {
     tubes.ForEach (instance => {
         if (instance.IsInView ()) {
             for (var i = 0; i < instance.Tubes.Length; i++) {
                 batch.Draw (instance.Tubes [i].Texture, instance.Tubes [i].Position, Color4.White);
             }
         }
     });
 }
Beispiel #4
0
 public void Draw(SpriteBatch batch, Vector2 position)
 {
     for (int y = 0; y < Height; y++)
         for (int x = 0; x < Width; x++) {
             var tile = Layers[x + y * Width];
             if (tile.TileId != -1) {
                 var xPos = x * Sheet.TileWidth * Scale;
                 var yPos = y * Sheet.TileHeight * Scale;
                 batch.Draw (Sheet.Texture, Sheet[tile.TileId], position + new Vector2 (xPos, yPos), Color4.White, scale: Scale, rotation: tile.Rotation);
             }
         }
 }
Beispiel #5
0
        protected override void Initialize()
        {
            var version = Assembly.GetEntryAssembly ().GetName ().Version;
            batch = new SpriteBatch (this);
            tex = Content.Load<Texture2D> ("nginz.png", TextureConfiguration.Nearest);

            testSheet = new SpriteSheet2D (Content.Load<Texture2D> ("classical_ruin_tiles_1.png", TextureConfiguration.Nearest), 23, 16);
            testMap = new TileMap (new Vector2 (128, 256), 32, 32, new Vector2(32, 32), 2);
            testMap.AddLayer ("testLayer", testSheet);

            /*testMap.SetTile ("testLayer", 0, 1, 0);
            testMap.SetTile ("testLayer", 1, 1, 1);
            testMap.SetTile ("testLayer", 2, 1, 2);
            testMap.SetTile ("testLayer", 3, 1, 3);*/

            stage = new Stage (this);
            var mascot = new MascotActor ();
            stage.AddActor (mascot);
            stage.AddAction (mascot);
            stage.TileMap = testMap;

            base.Initialize ();
        }
Beispiel #6
0
 public void Draw(GameTime time, SpriteBatch batch)
 {
     animator.Draw (time, batch);
 }
Beispiel #7
0
 public override void Draw(GameTime time, SpriteBatch batch)
 {
     Font.DrawString (batch, Text, cachedFontPosition, ColorWithTransparency);
     base.Draw (time, batch);
 }
Beispiel #8
0
 /// <summary>
 /// Draw.
 /// </summary>
 /// <param name="time">Time.</param>
 /// <param name="batch">Batch.</param>
 public void Draw(GameTime time, SpriteBatch batch)
 {
     // Draw the tile
     batch.Draw (
         texture: Sheet.Texture,
         sourceRect: Sheet [StartTile + Index],
         position: Position,
         origin: new Vector2 (Sheet [StartTile + Index].Width / 2f, Sheet [StartTile + Index].Height / 2f),
         color: Tint,
         scale: Scale,
         rotation: RotationX
     );
 }
Beispiel #9
0
 public void Draw(GameTime time, SpriteBatch batch)
 {
     batch.Draw (MascotTexture, Position, Color4.White, 1, rotation: MathHelper.DegreesToRadians (90));
 }
Beispiel #10
0
 public override void Draw(GameTime time, SpriteBatch batch)
 {
     if (UseTexture && BackgroundTexture != null)
         batch.Draw (BackgroundTexture, BackgroundTexture.Bounds, Bounds, new Color4 (1, 1, 1, Transparency));
     base.Draw (time, batch);
 }
Beispiel #11
0
 public void Draw(GameTime time, SpriteBatch batch)
 {
     Drawings.ForEach (x => x.Draw (time, batch));
     Actors.ForEach (x => x.Draw (time, batch));
 }
Beispiel #12
0
 public virtual void Draw(GameTime time, SpriteBatch batch)
 {
     for (var i = 0; i < Controls.Count; i++)
         Controls [i].Draw (time, batch);
 }
Beispiel #13
0
        /// <summary>
        /// Enter the gameloop.
        /// </summary>
        void EnterGameloop()
        {
            // Create graphics context
            this.Log ("Creating graphics context");
            context = new GraphicsContext (
                mode: graphicsMode,
                window: window.WindowInfo,
                major: 4,
                minor: 0,
                flags: GraphicsContextFlags.ForwardCompatible
            );

            // Make the created context the current context
            context.MakeCurrent (window.WindowInfo);

            // Throw if context is not available
            GraphicsContext.Assert ();

            // Set vsync mode
            SetupVsync ();

            // Load OpenGL entry points
            this.Log ("Loading OpenGL entry points");
            context.LoadAll ();

            // Initialize the sprite batch
            SpriteBatch = new SpriteBatch (this);

            // Bind the UI
            UI.Bind (this);

            // Initialize the game
            this.Log ("Initializing game");
            PreInitialize ();
            Initialize ();

            // Set target framerate
            // Use 60hz if framerate is not set
            var framerate = Configuration.TargetFramerate > 0 ? Configuration.TargetFramerate : 60;

            // Prepare timing variables
            PrepareTiming (framerate);

            // Present the window to the user
            window.Visible = true;

            // Wait till the window is visible
            while (!windowVisible && !window.Focused && !window.Visible) { }

            // Enter the actual game loop
            while (!exit) {

                // Set updating to true
                updating = true;

                // Invoke waiting actions
                for (var i = 0; i < ContextActions.Count; i++) {
                    Action action;
                    if (ContextActions.TryDequeue (out action)) {
                        try {
                            action ();
                        } catch (Exception e) {
                            this.Throw (e.Message);
                        }
                    }
                }

                // Set the paused variable to true
                // if the game should be paused and continue
                if (pause) {
                    paused = true;
                    continue;
                }

                // Set the paused variable to false
                paused = false;

                // Break out of the loop if the context is not available.
                if (context.IsDisposed) {
                    this.Log ("Context not available");
                    this.Log ("Leaving gameloop");
                    break;
                }

                // Update current time
                currentTime = DateTime.UtcNow;

                // Update
                InternalUpdate (currentTime);

                // Draw
                Draw (gameTime);

                // Set updating to false
                updating = false;
            }
        }
Beispiel #14
0
 public override void Draw(GameTime time, SpriteBatch batch)
 {
     if (Background != null)
         batch.Draw (Background, source, dest, Color4.White);
     base.Draw (time, batch);
 }
Beispiel #15
0
 /// <summary>
 /// Draw a string.
 /// </summary>
 /// <param name="spriteBatch">Sprite batch.</param>
 /// <param name="text">Text.</param>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="color">Color.</param>
 public void DrawString(SpriteBatch spriteBatch, string text, int x, int y, Color4 color)
 {
     if (text == "") //Skip empty strings
         return;
     var iter = new CodepointIterator (text);
     float penX = x, penY = y;
     while (iter.Iterate ()) {
         uint c = iter.Codepoint;
         if (c == (uint) '\n') {
             penY += lineHeight;
             penX = x;
             continue;
         }
         var glyph = GetGlyph (c);
         if (glyph.Render) {
             spriteBatch.Draw (
                 glyph.Texture,
                 glyph.Rectangle,
                 new Rectangle (
                     (int) penX + glyph.XOffset,
                     (int) penY + (LineHeight - glyph.YOffset),
                     glyph.Rectangle.Width,
                     glyph.Rectangle.Height
                 ),
                 color
             );
             penX += glyph.HorizontalAdvance;
             penY += glyph.AdvanceY;
         } else {
             penX += glyph.AdvanceX;
             penY += glyph.AdvanceY;
         }
         if (iter.Index < iter.Count - 1) {
             var g2 = GetGlyph (iter.PeekNext ());
             FT.FT_Vector vec;
             FT.FT_Get_Kerning (facePtr, glyph.CharIndex, g2.CharIndex, 2, out vec);
             var krn = FTMath.From26Dot6 (vec.x);
             penX += krn;
         }
     }
 }
Beispiel #16
0
 /// <summary>
 /// Draw a string.
 /// </summary>
 /// <param name="spriteBatch">Sprite batch.</param>
 /// <param name="text">Text.</param>
 /// <param name="position">Position.</param>
 /// <param name="color">Color.</param>
 public void DrawString(SpriteBatch spriteBatch, string text, Vector2 position, Color4 color)
 {
     DrawString (spriteBatch, text, (int) position.X, (int) position.Y, color);
 }