⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 explosion.cs

📁 基于.net FrameWork的windows游戏-坦克大战游戏.用到了多线程,绘图,碰撞处理等技术,整个游戏的框架已经搭建起来,可以做二次开发.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;


public class Explosion
{
    Form TankGame2008;
    Image[] explFrameImage;
    int explNum = 0;
    int curX, curY;
    bool visible;
    public Explosion(Image[] explFrameImage, Form TankGame2008)
    {
        this.explFrameImage = explFrameImage;
        this.TankGame2008 = TankGame2008;
        this.visible = false;
        this.curX = 0;
        this.curY = 0;
    }

    public void setVisible(bool visible)
    {
        this.visible = visible;
    }

    public bool getVisible()
    {
        return this.visible;
    }

    /// <summary>
    /// 当前爆炸效果的帧
    /// </summary>
    /// <returns></returns>
    public int getExplNum()
    {
        return this.explNum;
    }

    /// <summary>
    /// 爆炸效果总共的帧数
    /// </summary>
    /// <returns></returns>
    public int getExplFrameNum()
    {
        return this.explFrameImage.Length;
    }

    public void updateState()
    {
        explNum += 1;
        if (explNum > explFrameImage.Length-1)
        {
            this.setVisible(false);
            explNum = 0;
        }
    }

    public void setPos(int x, int y)
    {
        this.curX = x;
        this.curY = y;
    }

    public void drawSprite(Graphics g)
    {
        
        if (this.visible == true)
        {
            g.DrawImage(explFrameImage[explNum], curX, curY, explFrameImage[explNum].Width, explFrameImage[explNum].Height);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -