各位老手们,小弟有几道考试题不太明白,请各位帮着解答一下。谢了,回答加分
小弟刚刚开始学习c++,很多地方都不太懂。有几道题想请各位帮着解答一下。
1.Each pixel with one byte, fulfill the pixel to the screen. Assume no clipping considered.
struct {
long data[256];
} tBlock
long *screen; /*Initialized*/
int Wscreen, Hscreen; /*Initialized*/
void DisplayBlock(int x, int y, tBlock *b) {
int i, j;
for (i=0; i<16; i++)
for (j=0; j<16; j++)
screen [x-1 + j + (y-1)*Wscreen + i*16]
= b->data [j + i*16];
这段程序是用像素来填充屏幕上的一个区域,但是很耗时间,问问有没有办法优化一下啊?
3. write a class Character, each Character object include 10 sprite which could share the same sprite instance. For example, several character could share the same arm or leg other than the other part.
4. write a class Level, which should contain several characters and some character may appear more times rather than once in the same level.
5. write a function to count the number of total sprites used in the same Level. U could use any function u like.
这3题是有关联的。我不太明白怎么创建这个结构和类,谢谢高手们!