// firewnd.cpp : implementation file
//
#include "stdafx.h"
#include "fire.h"
#include "firewnd.h"
#include <math.h> // for HSI conversion
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
static RGBQUAD rgbStd256[] =
{
{ 0, 0, 0, 0 }, { 0, 0,128, 0 }, { 0,128, 0, 0 }, { 0,128,128, 0 },
{ 128, 0, 0, 0 }, { 128, 0,128, 0 }, { 128,128, 0, 0 }, { 192,192,192, 0 },
{ 192,220,192, 0 }, { 240,202,166, 0 }, { 238,238,238, 0 }, { 221,221,221, 0 },
{ 204,204,204, 0 }, { 187,187,187, 0 }, { 170,170,170, 0 }, { 153,153,153, 0 },
{ 136,136,136, 0 }, { 119,119,119, 0 }, { 102,102,102, 0 }, { 85, 85, 85, 0 },
{ 68, 68, 68, 0 }, { 51, 51, 51, 0 }, { 34, 34, 34, 0 }, { 17, 17, 17, 0 },
{ 204,255,255, 0 }, { 153,255,255, 0 }, { 102,255,255, 0 }, { 51,255,255, 0 },
{ 255,204,255, 0 }, { 204,204,255, 0 }, { 153,204,255, 0 }, { 102,204,255, 0 },
{ 51,204,255, 0 }, { 0,204,255, 0 }, { 255,153,255, 0 }, { 204,153,255, 0 },
{ 153,153,255, 0 }, { 102,153,255, 0 }, { 51,153,255, 0 }, { 0,153,255, 0 },
{ 255,102,255, 0 }, { 204,102,255, 0 }, { 153,102,255, 0 }, { 102,102,255, 0 },
{ 51,102,255, 0 }, { 0,102,255, 0 }, { 255, 51,255, 0 }, { 204, 51,255, 0 },
{ 153, 51,255, 0 }, { 102, 51,255, 0 }, { 51, 51,255, 0 }, { 0, 51,255, 0 },
{ 204, 0,255, 0 }, { 153, 0,255, 0 }, { 102, 0,255, 0 }, { 51, 0,255, 0 },
{ 255,255,204, 0 }, { 204,255,204, 0 }, { 153,255,204, 0 }, { 102,255,204, 0 },
{ 51,255,204, 0 }, { 0,255,204, 0 }, { 255,204,204, 0 }, { 153,204,204, 0 },
{ 102,204,204, 0 }, { 51,204,204, 0 }, { 0,204,204, 0 }, { 255,153,204, 0 },
{ 204,153,204, 0 }, { 153,153,204, 0 }, { 102,153,204, 0 }, { 51,153,204, 0 },
{ 0,153,204, 0 }, { 255,102,204, 0 }, { 204,102,204, 0 }, { 153,102,204, 0 },
{ 102,102,204, 0 }, { 51,102,204, 0 }, { 0,102,204, 0 }, { 255, 51,204, 0 },
{ 204, 51,204, 0 }, { 153, 51,204, 0 }, { 102, 51,204, 0 }, { 51, 51,204, 0 },
{ 0, 51,204, 0 }, { 255, 0,204, 0 }, { 204, 0,204, 0 }, { 153, 0,204, 0 },
{ 102, 0,204, 0 }, { 51, 0,204, 0 }, { 255,255,153, 0 }, { 204,255,153, 0 },
{ 153,255,153, 0 }, { 102,255,153, 0 }, { 51,255,153, 0 }, { 0,255,153, 0 },
{ 255,204,153, 0 }, { 204,204,153, 0 }, { 153,204,153, 0 }, { 102,204,153, 0 },
{ 51,204,153, 0 }, { 0,204,153, 0 }, { 255,153,153, 0 }, { 204,153,153, 0 },
{ 102,153,153, 0 }, { 51,153,153, 0 }, { 0,153,153, 0 }, { 255,102,153, 0 },
{ 204,102,153, 0 }, { 153,102,153, 0 }, { 102,102,153, 0 }, { 51,102,153, 0 },
{ 0,102,153, 0 }, { 255, 51,153, 0 }, { 204, 51,153, 0 }, { 153, 51,153, 0 },
{ 102, 51,153, 0 }, { 51, 51,153, 0 }, { 0, 51,153, 0 }, { 255, 0,153, 0 },
{ 204, 0,153, 0 }, { 153, 0,153, 0 }, { 102, 0,153, 0 }, { 51, 0,153, 0 },
{ 255,255,102, 0 }, { 204,255,102, 0 }, { 153,255,102, 0 }, { 102,255,102, 0 },
{ 51,255,102, 0 }, { 0,255,102, 0 }, { 255,204,102, 0 }, { 204,204,102, 0 },
{ 153,204,102, 0 }, { 102,204,102, 0 }, { 51,204,102, 0 }, { 0,204,102, 0 },
{ 255,153,102, 0 }, { 204,153,102, 0 }, { 153,153,102, 0 }, { 102,153,102, 0 },
{ 51,153,102, 0 }, { 0,153,102, 0 }, { 255,102,102, 0 }, { 204,102,102, 0 },
{ 153,102,102, 0 }, { 51,102,102, 0 }, { 0,102,102, 0 }, { 255, 51,102, 0 },
{ 204, 51,102, 0 }, { 153, 51,102, 0 }, { 102, 51,102, 0 }, { 51, 51,102, 0 },
{ 0, 51,102, 0 }, { 255, 0,102, 0 }, { 204, 0,102, 0 }, { 153, 0,102, 0 },
{ 102, 0,102, 0 }, { 51, 0,102, 0 }, { 255,255, 51, 0 }, { 204,255, 51, 0 },
{ 153,255, 51, 0 }, { 102,255, 51, 0 }, { 51,255, 51, 0 }, { 0,255, 51, 0 },
{ 255,204, 51, 0 }, { 204,204, 51, 0 }, { 153,204, 51, 0 }, { 102,204, 51, 0 },
{ 51,204, 51, 0 }, { 0,204, 51, 0 }, { 255,153, 51, 0 }, { 204,153, 51, 0 },
{ 153,153, 51, 0 }, { 102,153, 51, 0 }, { 51,153, 51, 0 }, { 0,153, 51, 0 },
{ 255,102, 51, 0 }, { 204,102, 51, 0 }, { 153,102, 51, 0 }, { 102,102, 51, 0 },
{ 51,102, 51, 0 }, { 0,102, 51, 0 }, { 255, 51, 51, 0 }, { 204, 51, 51, 0 },
{ 153, 51, 51, 0 }, { 102, 51, 51, 0 }, { 0, 51, 51, 0 }, { 255, 0, 51, 0 },
{ 204, 0, 51, 0 }, { 153, 0, 51, 0 }, { 102, 0, 51, 0 }, { 51, 0, 51, 0 },
{ 204,255, 0, 0 }, { 153,255, 0, 0 }, { 102,255, 0, 0 }, { 51,255, 0, 0 },
{ 255,204, 0, 0 }, { 204,204, 0, 0 }, { 153,204, 0, 0 }, { 102,204, 0, 0 },
{ 51,204, 0, 0 }, { 255,153, 0, 0 }, { 204,153, 0, 0 }, { 153,153, 0, 0 },
{ 102,153, 0, 0 }, { 0, 0,238, 0 }, { 0, 0,221, 0 }, { 0, 0,204, 0 },
{ 0, 0,187, 0 }, { 0, 0,170, 0 }, { 0, 0,153, 0 }, { 0, 0,136, 0 },
{ 0, 0,119, 0 }, { 0, 0,102, 0 }, { 0, 0, 85, 0 }, { 0, 0, 68, 0 },
{ 0, 0, 51, 0 }, { 0, 0, 34, 0 }, { 0, 0, 17, 0 }, { 0,238, 0, 0 },
{ 0,221, 0, 0 }, { 0,204, 0, 0 }, { 0,187, 0, 0 }, { 0,170, 0, 0 },
{ 0,153, 0, 0 }, { 0,136, 0, 0 }, { 0,119, 0, 0 }, { 0,102, 0, 0 },
{ 0, 85, 0, 0 }, { 0, 68, 0, 0 }, { 0, 51, 0, 0 }, { 0, 34, 0, 0 },
{ 0, 17, 0, 0 }, { 238, 0, 0, 0 }, { 221, 0, 0, 0 }, { 204, 0, 0, 0 },
{ 187, 0, 0, 0 }, { 170, 0, 0, 0 }, { 153, 0, 0, 0 }, { 136, 0, 0, 0 },
{ 119, 0, 0, 0 }, { 102, 0, 0, 0 }, { 85, 0, 0, 0 }, { 68, 0, 0, 0 },
{ 51, 0, 0, 0 }, { 34, 0, 0, 0 }, { 240,251,255, 0 }, { 164,160,160, 0 },
{ 128,128,128, 0 }, { 0, 0,255, 0 }, { 0,255, 0, 0 }, { 0,255,255, 0 },
{ 255, 0, 0, 0 }, { 255, 0,255, 0 }, { 255,255, 0, 0 }, { 255,255,255, 0 }
};
/////////////////////////////////////////////////////////////////////////////
// CFireWnd
// Initialize the seed for random number generation. For a more random
// flame this could be initialized by a call to ::rand(). Declaring it
// this way causes the same flame to be drawn each time the application
// is executed.
unsigned long CFireWnd::m_RandSeed = 0x38549391;
CFireWnd::CFireWnd()
{
m_nDecay = 5;
m_nFlammability = 385;
m_nMaxHeat = 223;
m_nSpreadRate = 20;
m_nSmoothness = 1;
m_nDistribution = 1;
m_nChaos = 50;
m_nSize = 0;
m_MaxBurn = 0;
m_Fire = NULL;
m_pMemDC = NULL;
m_pWinDC = NULL;
m_pOldPalette = NULL;
m_pOldBitmap = NULL;
}
CFireWnd::~CFireWnd()
{
}
BEGIN_MESSAGE_MAP(CFireWnd, CStatic)
//{{AFX_MSG_MAP(CFireWnd)
ON_WM_PAINT()
ON_WM_DESTROY()
ON_WM_PALETTECHANGED()
ON_WM_QUERYNEWPALETTE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFireWnd Operations
void CFireWnd::InitFire(int nColor)
{
CreatePalette(nColor);
CreateBitmap();
{
CWnd* pActiveWnd = CWnd::GetActiveWindow();
if (pActiveWnd != NULL)
pActiveWnd->SendMessage(WM_QUERYNEWPALETTE);
}
}
CPalette* CFireWnd::GetPalette()
{
if (m_Palette.m_hObject != NULL)
return &m_Palette;
else
return NULL;
}
void CFireWnd::CreatePalette(int nColor)
{
UINT i;
if (m_Palette.m_hObject != NULL)
m_Palette.DeleteObject();
memcpy( m_rgbPalette, rgbStd256, sizeof(RGBQUAD) * 256 );
int r,g,b;
switch(nColor)
{
case blue:
b = 256+256+255;
g = 256+255;
r = 255;
break;
case green:
g = 256+256+255;
r = 256+255;
b = 255;
break;
case red:
default:
r = 256+256+255;
g = 256+255;
b = 255;
break;
}
for(i = 239; i > 15; i--)
{
m_rgbPalette[i].rgbRed = (r > 255) ? 255 : r;
m_rgbPalette[i].rgbGreen = (g > 255) ? 255 : g;
m_rgbPalette[i].rgbBlue = (b > 255) ? 255 : b;
r = (r > 3) ? (r - 4) : 0;
g = (g > 3) ? (g - 4) : 0;
b = (b > 3) ? (b - 4) : 0;
}
LPLOGPALETTE lpLogPal;
lpLogPal = (LPLOGPALETTE) new BYTE[sizeof(LOGPALETTE) + ((255) * sizeof(PALETTEENTRY))];
lpLogPal->palVersion = 0x0300;
lpLogPal->palNumEntries = 256;
for (i = 0; i < 256; i++)
{
lpLogPal->palPalEntry[i].peRed = m_rgbPalette[i].rgbRed;
lpLogPal->palPalEntry[i].peGreen = m_rgbPalette[i].rgbGreen;
lpLogPal->palPalEntry[i].peBlue = m
没有合适的资源?快使用搜索试试~ 我知道了~
TCB.rar_C++课程设计
共22个文件
h:5个
cpp:4个
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 196 浏览量
2022-09-21
03:55:12
上传
评论
收藏 105KB RAR 举报
温馨提示
这是Visual C++课程设计案例精编(第一版)的源码!我觉得很好,跟大家分享下!
资源推荐
资源详情
资源评论
收起资源包目录
TCB.rar (22个子文件)
www.pudn.com.txt 218B
调色板
FIREWND.H 3KB
FIRE.PLG 1KB
FIRE.EXE 116KB
FIRE.H 909B
FIRE.NCB 73KB
RES
FIRE.ICO 1KB
FIRE.RC2 396B
STDAFX.CPP 97B
FIRE.DSW 531B
STDAFX.H 201B
FIRE.OPT 49KB
Fire.aps 21KB
FIREDLG.CPP 11KB
FIRE.DSP 6KB
FIRE.MAK 9KB
FIRE.CPP 2KB
FIRE.CLW 2KB
RESOURCE.H 1KB
Debug
FIREWND.CPP 14KB
FIREDLG.H 2KB
FIRE.RC 5KB
共 22 条
- 1
资源评论
APei
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功