📄 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 + -