示例#1
0
        public void Draw()
        {
            RectangleF rec = DrawRec;

            if (goingUp)
            {
                sprite = p_up;
            }
            else
            {
                sprite = p_down;
            }
            if (isdead)
            {
                sprite = p_dead;
            }
            if (Game.Level != 5)
            {
                Spritebatch.DrawSprite(sprite, rec, Color.White);
            }
            else
            {
                Spritebatch.DrawSprite(sprite, rec, Color.DarkOrange);
            }
        }
示例#2
0
        public void Draw()
        {
            RectangleF rec = DrawRec;

            if (jump)
            {
                sprite = walkAnimation[1];
            }
            else
            {
                sprite = walkAnimation[0];
            }
            if (isdead)
            {
                rec.Y     += rec.Height;
                rec.Height = -rec.Height;
                sprite     = dead;
            }
            if (Game.Level != 5)
            {
                Spritebatch.DrawSprite(sprite, rec, Color.White);
            }
            else
            {
                Spritebatch.DrawSprite(sprite, rec, Color.MediumPurple);
            }
        }
示例#3
0
        public static void DrawChar(char c, int pos, float x, float y)
        {
            int        charid    = Convert.ToInt32(c);
            int        xx        = (charid % 16) * 16 + 1;
            int        yx        = ((int)Math.Floor((double)(charid / 16))) * 16 + 1;
            RectangleF sourceRec = new RectangleF(xx, yx, 15, 15);

            Spritebatch.DrawSprite(charset, new RectangleF(x + pos, y, 32, 32), cd, sourceRec);
        }
示例#4
0
文件: Ghost.cs 项目: Gewf/SpongeGame
        public void Draw()
        {
            RectangleF rec = DrawRec;

            if (l)
            {
                rec.X    += rec.Width;
                rec.Width = -rec.Width;
            }
            Spritebatch.DrawSprite(sprite, rec, Color.DarkGray);
        }
示例#5
0
文件: View.cs 项目: Gewf/SpongeGame
 public void DrawHUD()
 {
     if (Game.Level != 6)
     {
         //Lives
         Spritebatch.DrawSprite(head, new RectangleF(position.X - 300, position.Y - 210, 32, 32));
         DialogBox.DrawString("x" + Lives.ToString(), position.X - 268, position.Y - 210);
         //Coins
         Spritebatch.DrawSprite(coin, new RectangleF(position.X + 180, position.Y - 210, 32, 32));
         DialogBox.DrawString("x" + Coins.ToString(), position.X + 212, position.Y - 210);
     }
     else
     {
         DialogBox.DrawString("The", position.X - 48, position.Y - 164);
         DialogBox.DrawString("End", position.X - 48, position.Y - 132);
     }
 }
示例#6
0
        public void Draw()
        {
            RectangleF rec = DrawRec;

            if (l)
            {
                rec.X    += rec.Width;
                rec.Width = -rec.Width;
            }
            if (!isHurt)
            {
                Spritebatch.DrawSprite(sprite, rec, Color.FromArgb(128, 169, 169, 169));
            }
            else
            {
                Spritebatch.DrawSprite(sprite, rec, Color.DarkGray);
            }
        }
示例#7
0
 public void Draw(Color color)
 {
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
     if (type == ObjectType.StandingCoin || type == ObjectType.Coin)
     {
         if (index < 6)
         {
             Spritebatch.DrawSprite(sprite, new RectangleF(position.X, position.Y, size.X, size.Y), color);
         }
         else
         {
             Spritebatch.DrawSprite(sprite, new RectangleF(position.X, position.Y, size.X, size.Y), Color.FromArgb(color.A, color.R - 50, color.G - 50, color.B - 50));
         }
         return;
     }
     Spritebatch.DrawSprite(sprite, new RectangleF(position.X, position.Y, size.X, size.Y), color);
 }
示例#8
0
文件: Snail.cs 项目: Gewf/SpongeGame
        public void Draw()
        {
            RectangleF rec = DrawRec;

            if (velocity.X > 0)
            {
                rec.X    += rec.Width;
                rec.Width = -rec.Width;
            }
            if (isdead)
            {
                rec.Y     += rec.Height;
                rec.Height = -rec.Height;
            }

            if (Game.Level != 5)
            {
                Spritebatch.DrawSprite(sprite, rec, Color.White);
            }
            else
            {
                Spritebatch.DrawSprite(sprite, rec, Color.DarkOrange);
            }
        }
示例#9
0
文件: Player.cs 项目: Gewf/SpongeGame
        public void Draw(Color color)
        {
            if (Game.Level == 6)
            {
                return;
            }
            RectangleF rec = DrawRec;

            if (dying)
            {
                sprite = dead;
            }
            if (!facingRight)
            {
                rec.X    += rec.Width;
                rec.Width = -rec.Width;
            }
            if (isInvincible && counter % 2 == 0)
            {
                return;
            }
            if (climbing)
            {
                if (xcounter < 6)
                {
                    rec.X    += rec.Width;
                    rec.Width = -rec.Width;
                }
                if (fireflower)
                {
                    Spritebatch.DrawSprite(firespriteClimb, rec, color);
                }
                else
                {
                    Spritebatch.DrawSprite(spriteClimb, rec, color);
                }
            }
            else if (!grounded && velocity.Y <= 0 && !dying)
            {
                if (!fireflower)
                {
                    Spritebatch.DrawSprite(spriteJump, rec, color);
                }
                else
                {
                    Spritebatch.DrawSprite(firespriteJump, rec, color);
                }
            }
            else if (!grounded && velocity.Y > 0 && !dying)
            {
                if (!fireflower)
                {
                    Spritebatch.DrawSprite(spriteFall, rec, color);
                }
                else
                {
                    Spritebatch.DrawSprite(firespriteFall, rec, color);
                }
            }
            else
            {
                Spritebatch.DrawSprite(sprite, rec, color);
            }

            //Spritebatch.DrawSprite(Game.dot, this.ColRec, Color.Red);
        }
示例#10
0
        //Render - draw stuff here
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            if (slevel == "menu")
            {
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                GL.ClearColor(Color.FromArgb(255, 10, 10, 10));
                Spritebatch.Begin(this);
                view.ApplyTransforms();
                foreach (GameObject o in ObjectHandler.objects)
                {
                    o.Draw(Color.FromArgb(255, 90, 90, 90));
                }

                for (int x = 0; x < level.Width; x++)
                {
                    for (int y = 0; y < level.Height; y++)
                    {
                        int        tileSize  = 70;
                        RectangleF sourceRec = new RectangleF(0, 0, 0, 0);

                        sourceRec = new RectangleF(level[x, y].tileX, level[x, y].tileY, tileSize, tileSize);

                        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
                        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
                        Spritebatch.DrawSprite(tileSet, new RectangleF(x * GRIDSIZE, y * GRIDSIZE, GRIDSIZE + 1, GRIDSIZE + 1), Color.FromArgb(255, 90, 90, 90), sourceRec);
                    }
                }
            }
            else
            {
                List <Enemy> afterdraw = new List <Enemy>(); //Enemies drawn after tiles - above them. (atm all except piranhas)
                Color        tilec     = Color.LightGray;
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                if (slevel.Contains("story"))
                {
                    GL.ClearColor(Color.FromArgb(255, 0, 0, 0));
                }
                else if (Level == 1)
                {
                    GL.ClearColor(Color.FromArgb(255, 10, 10, 10));
                    tilec = Color.LightGray;
                }
                else if (Level == 2)
                {
                    GL.ClearColor(Color.FromArgb(255, 0, 20, 20));
                    tilec = Color.LightGray;
                }
                else if (Level == 3 || Level == 4 || Level == 5)
                {
                    GL.ClearColor(Color.FromArgb(255, 0, 0, 16));
                    tilec = Color.Gray;
                }
                else if (Level == 6)
                {
                    GL.ClearColor(Color.FromArgb(255, 16, 16, 16));
                    tilec = Color.Gray;
                }


                Spritebatch.Begin(this);
                view.ApplyTransforms();

                if (!slevel.Contains("story"))
                {
                    foreach (GameObject o in ObjectHandler.objects)
                    {
                        o.Draw(tilec);
                    }
                }

                List <Tuple <Block, Vector2> > afterdraws = new List <Tuple <Block, Vector2> >();
                if (!slevel.Contains("story"))
                {
                    for (int x = 0; x < level.Width; x++)
                    {
                        for (int y = 0; y < level.Height; y++)
                        {
                            if (level[x, y].type == BlockType.Empty)
                            {
                                Tuple <Block, Vector2> t = new Tuple <Block, Vector2>(level[x, y], new Vector2(x, y));
                                afterdraws.Add(t);
                                continue;
                            }
                            int        tileSize  = 70;
                            RectangleF sourceRec = new RectangleF(0, 0, 0, 0);

                            sourceRec = new RectangleF(level[x, y].tileX, level[x, y].tileY, tileSize, tileSize);

                            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
                            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
                            Spritebatch.DrawSprite(tileSet, new RectangleF(x * GRIDSIZE, y * GRIDSIZE, GRIDSIZE + 1, GRIDSIZE + 1), tilec, sourceRec);
                        }
                    }
                }
                if (!slevel.Contains("story"))
                {
                    foreach (Enemy ex in enemies)
                    {
                        if (ex.enemyType == 5)
                        {
                            ex.Draw();
                        }
                        else
                        {
                            afterdraw.Add(ex);
                        }
                    }
                }
                if (!slevel.Contains("story"))
                {
                    player.Draw(tilec);
                }
                foreach (Tuple <Block, Vector2> t in afterdraws.ToArray())
                {
                    int        tileSize  = 70;
                    RectangleF sourceRec = new RectangleF(0, 0, 0, 0);

                    sourceRec = new RectangleF(t.Item1.tileX, t.Item1.tileY, tileSize, tileSize);

                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
                    Spritebatch.DrawSprite(tileSet, new RectangleF(t.Item2.X * GRIDSIZE, t.Item2.Y * GRIDSIZE, GRIDSIZE + 1, GRIDSIZE + 1), tilec, sourceRec);
                }
                foreach (Enemy ex in afterdraw)
                {
                    ex.Draw();
                }

                if (!slevel.Contains("story"))
                {
                    view.DrawHUD();
                }
                if (slevel.Contains("story"))
                {
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
                    DialogBox.DrawString(view.Position.X - 288, view.Position.Y);
                }
            }
            this.SwapBuffers();
        }