📄 koulesframebuffer.c
字号:
/***********************************************************
Copyright(C)2007,Rockchip Co., Ltd. All Rights Reserved.
File:kouleframebuffer.c
Desc:初始化framebuffer.
Note:
Author:czs
$Log: koulesframebuffer.c,v $
Revision 1.3 2008/06/19 04:42:27 Administrator
代码整理!
Revision 1.2 2008/06/06 03:15:50 XXX
更改游戏在RGB屏情况的问题
Revision 1.1.1.1 2008/03/06 13:28:24 Lingzhaojun
no message
Revision 1.3 2007/10/26 03:52:01 Chenzushang
添加CVS版本自动注释脚本
**********************************************************/
#include "koules.h"
#include "koulesapp.h"
#define HOLE_SIZE_MAX (radius*radius)
IMPORT UBYTE koules_hole_bitmap[HOLE_RADIUS * 2][HOLE_RADIUS * 2],
koules_ehole_bitmap[HOLE_RADIUS * 2][HOLE_RADIUS * 2],
koules_eye_bitmap[MAXROCKETS][EYE_RADIUS * 2][EYE_RADIUS * 2],
// mouse_bitmap [ MOUSE_RADIUS * 2][ MOUSE_RADIUS * 2],
koules_ball_bitmap[BALL_RADIUS * 2][BALL_RADIUS * 2],
koules_bball_bitmap[BBALL_RADIUS * 2][BBALL_RADIUS * 2],
koules_inspector_bitmap[INSPECTOR_RADIUS * 2][INSPECTOR_RADIUS * 2],
koules_lball_bitmap[NLETTERS][BALL_RADIUS * 2][BALL_RADIUS * 2],
koules_rocket_bitmap[MAXROCKETS][ROCKET_RADIUS * 2][ROCKET_RADIUS * 2],
koules_apple_bitmap[APPLE_RADIUS * 2][APPLE_RADIUS * 2],
koules_lunatic_bitmap[LUNATIC_RADIUS * 2][LUNATIC_RADIUS * 2];
void Koules_create_bitmap(void)
{
int x, y, r, po, radius, radius1;
UBYTE color;
// "hole" bitmaps
for (x = 0; x < HOLE_RADIUS * 2; x++)
{
for (y = 0; y < HOLE_RADIUS * 2; y++)
{
radius = HOLE_RADIUS /
2 +
(int)
(atan(fabs(x - HOLE_RADIUS + 0.5) /
fabs(y - HOLE_RADIUS + 0.5)) * HOLE_RADIUS / 2) %
(HOLE_RADIUS / 2);
if ((x - HOLE_RADIUS) * (x - HOLE_RADIUS) +
(y - HOLE_RADIUS) * (y - HOLE_RADIUS) <
radius * radius)
{
r = (x - HOLE_RADIUS) * (x - HOLE_RADIUS) +
(y - HOLE_RADIUS) * (y - HOLE_RADIUS);
r = r * 24 / HOLE_SIZE_MAX;
if (r > 23)
{
r = 23;
}
koules_hole_bitmap[x][y] = 64 + r + 1;
koules_ehole_bitmap[x][y] = 128 + r + 1;
}
else
{
koules_hole_bitmap[x][y] = koules_ehole_bitmap[x][y] = 0;
}
}
}
// "ball" bitmaps
radius = EYE_RADIUS;
for (po = 0; po < MAXROCKETS; po++)
{
color = 32 + (32 * po);
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_eye_bitmap[po][x][y] = color + r;
}
else
{
koules_eye_bitmap[po][x][y] = 0;
}
}
}
}
radius = BALL_RADIUS;
color = 64;
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_ball_bitmap[x][y] = color + r;
}
else
{
koules_ball_bitmap[x][y] = 0;
}
}
}
// radius = MOUSE_RADIUS;
// color = 96;
// for (y = 0; y < radius * 2; y++)
// { for (x = 0; x < radius * 2; x++)
// { if
// ( (x - radius) * (x - radius) + (y - radius) * (y - radius)
// < (radius - 0.5) * (radius - 0.5)
// )
// { r = (x - 3 * radius / 4)
// * (x - 3 * radius / 4)
// + (y - radius / 4)
// * (y - radius / 4);
// r = r * 32 / (1.5 * radius) / (1.5 * radius);
// if (r > 31)
// { r = 31;
// }
// // mouse_bitmap[x][y] = color + r;
// } else
// { // mouse_bitmap[x][y] = 0;
// } } }
radius = BBALL_RADIUS;
color = 128;
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_bball_bitmap[x][y] = color + r;
}
else
{
koules_bball_bitmap[x][y] = 0;
}
}
}
radius = INSPECTOR_RADIUS;
color = 160;
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_inspector_bitmap[x][y] = color + r;
}
else
{
koules_inspector_bitmap[x][y] = 0;
}
}
}
radius = BALL_RADIUS;
for (po = 0; po < MAXROCKETS; po++)
{
if (po == 0)
{
color = 128;
}
else
{
color = 160;
}
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_lball_bitmap[po][x][y] = color + r;
}
else
{
koules_lball_bitmap[po][x][y] = 0;
}
}
}
}
radius = ROCKET_RADIUS;
for (po = 0; po < MAXROCKETS; po++)
{
color = koulesrocketcolor[po];
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_rocket_bitmap[po][x][y] = color + r;
}
else
{
koules_rocket_bitmap[po][x][y] = 0;
}
}
}
}
// "apple" bitmap
radius = APPLE_RADIUS;
color = 64;
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
radius1 = radius * (abs(x - radius) / 2 + 50) / 60;
if (radius1 > radius)
{
radius1 = radius;
}
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
radius1 * radius1)
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(3 + r * 22 / (1.5 * radius1) / (1.5 * radius1));
if (r > 31)
{
r = 31;
}
koules_apple_bitmap[x][y] = color + r;
}
else
{
koules_apple_bitmap[x][y] = 0;
}
}
}
// "reversed" bitmaps
radius = LUNATIC_RADIUS;
color = 192;
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_lunatic_bitmap[x][y] = color + r;
}
else
{
koules_lunatic_bitmap[x][y] = 0;
}
}
}
radius = BALL_RADIUS;
for (po = 2; po <= 4; po++)
{
if (po == 2)
{
color = 192;
}
elif(po == 3)
{
color = 0;
}
else
{
color = 91;
}
for (y = 0; y < radius * 2; y++)
{
for (x = 0; x < radius * 2; x++)
{
if ((x - radius) * (x - radius) +
(y - radius) * (y - radius) <
(radius - 0.5) * (radius - 0.5))
{
r = (x - 3 * radius / 4) * (x - 3 * radius / 4) +
(y - radius / 4) * (y - radius / 4);
r = (int)(r * 32 / (1.5 * radius) / (1.5 * radius));
if (r > 31)
{
r = 31;
}
koules_lball_bitmap[po][x][y] = color + r;
}
else
{
koules_lball_bitmap[po][x][y] = 0;
}
}
}
}
}
//void drawbackground(void)
//{
// int x, x1, y1, c1;
//
// KoulesClearScreen();
//
// for (x = 0; x < 700; x++)
// {
// x1 = KoulesGetRand() % KOULESMAPWIDTH;
// y1 = KoulesGetRand() % KOULESMAPHEIGHT;
// c1 = KoulesGetRand() % 32 + 192;
// Koules_setpixel(x1, y1, c1);
// }
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -