?? screen.cpp
字號:
#include "stdafx.h"
#include "screen.h"
screen::screen(int x,int y,int width,int height,int scalewidth,int scaleheight,HWND hwnd,HDC memdc,int backcolor)
{
m_hwnd=hwnd;
m_memdc=memdc;
m_draw=new draw(hwnd,memdc);
m_left=x;
m_top=y;
m_width=width;
m_height=height;
m_scalewidth=scalewidth;
m_scaleheight=scaleheight;
m_unitwidth=width/scalewidth;
m_unitheight=height/scaleheight;
m_backcolor=backcolor;
m_draw->drawrectangle(x,y,x+width,y+height,backcolor,backcolor);
}
screen::~screen()
{
delete m_draw;
}
void screen::clear()
{
m_draw->drawrectangle(m_left,m_top,m_left+m_width,m_top+m_height,m_backcolor,m_backcolor);
}
void screen::refresh(const map & themap,int top,int bottom)
{
int i,k;
for(i=0;i<bottom-top+1;i++)
{
for(k=0;k<themap.width();k++)
{
if(themap.mapinfo(k,bottom-i)==MAP_SOLID)
{
drawdiamondoperate(k,bottom-i,FREEZE_COLOR);
}
else
{
drawdiamondoperate(k,bottom-i,m_backcolor);
}
}
}
}
int screen::drawdiamond(const diamond &thediamond)
{
int i,x,y,color;
color=thediamond.diamondcolor();
for(i=0;i<thediamond.subdiamondval();i++)
{
thediamond.diamondinfo(i,x,y);
drawdiamondoperate(x,y,color);
}
return 0;
}
int screen::drawfreezediamond(const diamond &thediamond)
{
int i,x,y,color;
color=FREEZE_COLOR;
for(i=0;i<thediamond.subdiamondval();i++)
{
thediamond.diamondinfo(i,x,y);
drawdiamondoperate(x,y,color);
}
return 0;
}
int screen::cleardiamond(const diamond &thediamond)
{
int i,x,y,color;
color=m_backcolor;
for(i=0;i<thediamond.subdiamondval();i++)
{
thediamond.diamondinfo(i,x,y);
drawdiamondoperate(x,y,color);
}
return 0;
}
void screen::drawdiamondoperate(int x,int y,int color)
{
x=m_left+x*m_unitwidth;
y=m_top+y*m_unitheight;
m_draw->drawrectangle(x,y,x+m_unitwidth,y+m_unitwidth,m_backcolor,color);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -