You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <easyx.h>
class Drawer
{
private:
IMAGE* images; // 每一行 为 一个动画序列
IMAGE* images_h; // 掩码图片
IMAGE foot; // 足底图片
int row; // 动画序列个数
int column; // 动画序列内部帧数
int row_t; // 当前动画序列号
int column_t; // 动画序列内部帧号
// 绘制透明图片
void PutPicture(const IMAGE* face, const IMAGE* hide, int dstX, int dstY)
{
// 利用掩码图片hide删除绘图轮廓
// 在掩码图片所清理出的黑色轮廓中覆盖图片face
}
public:
// 删除旧图像
void Clear(int old_x, int old_y)
{
int k = column_t + row_t * column;
IMAGE* face = &foot;
putimage(old_x, old_y, face);
}
// 绘制新图像
void Draw(int new_x, int new_y,const IMAGE* new_foot)
{
/* 有优化需要 */
column_t++;
if (column_t >= column)
column_t = 0;
int k = column_t + row_t * column;
IMAGE* face = images + k;
IMAGE* hide = images_h + k;
PutPicture(face, hide, new_x, new_y);
// 深拷贝
foot = *new_foot;
}
// 设置动画序列号
bool SetRowT(int r)
{
if (r < 0 || r >= row)
return false;
row_t = r;
return true;
}
// 使用一张图 初始化 drawer
void Init(int r, int c, const IMAGE* img,const IMAGE* img_h)
{
row = r;
column = c;
int h = img->getheight();
int w = img->getwidth();
int h0 = h / r;
int w0 = w / c;
delete images;
delete images_h;
images = new IMAGE[r * c];
images_h = new IMAGE[r * c];
/* 等待补充 */
}
};