新增飞机大战游戏
This commit is contained in:
parent
56506db572
commit
34a9f6d374
732
User/APP_Plane/APP_Plane.c
Normal file
732
User/APP_Plane/APP_Plane.c
Normal file
@ -0,0 +1,732 @@
|
||||
//飞机大战游戏
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#include "sys.h"
|
||||
#include "systick.h"
|
||||
|
||||
#include "key.h"
|
||||
#include "led.h"
|
||||
#include "lcd.h"
|
||||
|
||||
#include "GameEngine.h"
|
||||
|
||||
#include "fxlib.h"
|
||||
|
||||
#include "APP_Plane_Bitmap.h"
|
||||
|
||||
#include "APP_Plane.h"
|
||||
|
||||
/**************************************** 私有定义 ****************************************/
|
||||
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
|
||||
#define STATUS_BAR_WIDTH 8
|
||||
|
||||
#define SMALL_PLANE_MAX 32
|
||||
#define MEDIUM_PLANE_MAX 16
|
||||
#define LARGE_PLANE_MAX 2
|
||||
|
||||
#define BULLET_MAX 16
|
||||
|
||||
#define PLANE_TYPE_SMALL 0
|
||||
#define PLANE_TYPE_MEDIUM 1
|
||||
#define PLANE_TYPE_LARGE 2
|
||||
|
||||
#define PLANE_STATUS_NONEXISTENT (-14)
|
||||
#define PLANE_STATUS_EXPLODING_2 (-13)
|
||||
#define PLANE_STATUS_EXPLODING_1 (-6)
|
||||
#define PLANE_STATUS_ALIVE 1
|
||||
|
||||
#define SP_HEALTH_VAL 2
|
||||
#define MP_HEALTH_VAL 6
|
||||
#define LP_HEALTH_VAL 10
|
||||
|
||||
#define BULLET_STATUS_NONEXISTENT 0
|
||||
#define BULLET_STATUS_FLYING 1
|
||||
|
||||
#define DIRECTION_UP 0
|
||||
#define DIRECTION_DOWN 1
|
||||
#define DIRECTION_LEFT 2
|
||||
#define DIRECTION_RIGHT 3
|
||||
|
||||
#define SP_GRAPHIC_WIDTH 7
|
||||
#define SP_GRAPHIC_HEIGHT 7
|
||||
|
||||
#define MP_GRAPHIC_WIDTH 12
|
||||
#define MP_GRAPHIC_HEIGHT 9
|
||||
|
||||
#define LP_GRAPHIC_WIDTH 33
|
||||
#define LP_GRAPHIC_HEIGHT 22
|
||||
|
||||
#define RP_GRAPHIC_WIDTH 13
|
||||
#define RP_GRAPHIC_HEIGHT 13
|
||||
|
||||
#define BULLET_GRAPHIC_WIDTH 5
|
||||
#define BULLET_GRAPHIC_HEIGHT 3
|
||||
|
||||
#define SP_COLLISION_POS_X 1
|
||||
#define SP_COLLISION_POS_Y 1
|
||||
#define SP_COLLISION_WIDTH 5
|
||||
#define SP_COLLISION_HEIGHT 5
|
||||
|
||||
#define MP_COLLISION_POS_X 1
|
||||
#define MP_COLLISION_POS_Y 1
|
||||
#define MP_COLLISION_WIDTH 10
|
||||
#define MP_COLLISION_HEIGHT 7
|
||||
|
||||
#define LP_COLLISION_POS_X 2
|
||||
#define LP_COLLISION_POS_Y 2
|
||||
#define LP_COLLISION_WIDTH 27
|
||||
#define LP_COLLISION_HEIGHT 18
|
||||
|
||||
#define RP_COLLISION_POS_X 2
|
||||
#define RP_COLLISION_POS_Y 2
|
||||
#define RP_COLLISION_WIDTH 8
|
||||
#define RP_COLLISION_HEIGHT 9
|
||||
|
||||
#define BULLET_COLLISION_POS_X (-1)
|
||||
#define BULLET_COLLISION_POS_Y 0
|
||||
#define BULLET_COLLISION_WIDTH 5
|
||||
#define BULLET_COLLISION_HEIGHT 5
|
||||
|
||||
#define COLLISION_ROLE_PLANE 0
|
||||
#define NO_COLLISION_ROLE_PLANE 1
|
||||
|
||||
#define Random() rand()
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int status;
|
||||
} Object;
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
/**************************************** 全局变量 ****************************************/
|
||||
|
||||
Object Small_Plane[SMALL_PLANE_MAX];
|
||||
Object Medium_Plane[MEDIUM_PLANE_MAX];
|
||||
Object Large_Plane[LARGE_PLANE_MAX];
|
||||
Object Bullet[BULLET_MAX];
|
||||
Object Role_Plane;
|
||||
|
||||
int SP_Generate_Interval_Max, SP_Generate_Interval_Min, MP_Generate_Interval_Max, MP_Generate_Interval_Min, LP_Generate_Interval_Max, LP_Generate_Interval_Min, Bullet_Generate_Interval;
|
||||
int SP_Move_Interval, MP_Move_Interval, LP_Move_Interval, Bullet_Move_Interval;
|
||||
int Get_Key_Interval, Turbo_Interval;
|
||||
int SP_Destroyed, MP_Destroyed, LP_Destroyed, Score;
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
/**************************************** 私有函数 ****************************************/
|
||||
|
||||
void Menu(void);
|
||||
void Game(void);
|
||||
void Move_Plane(int type);
|
||||
void New_Plane(int type);
|
||||
void Move_Role_Plane(int direction);
|
||||
void Move_Bullet(void);
|
||||
void New_Bullet(void);
|
||||
void Init(void);
|
||||
void Draw_All(void);
|
||||
void Game_Over(void);
|
||||
int Collision_Detection(void);
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 启动飞机大战游戏
|
||||
*/
|
||||
void APP_Plane_Launcher(void)
|
||||
{
|
||||
Game();
|
||||
}
|
||||
|
||||
void Game()
|
||||
{
|
||||
srand(SysTick->VAL);
|
||||
|
||||
int sp_generate_interval, mp_generate_interval, lp_generate_interval;
|
||||
int sp_move_timer = 0, mp_move_timer = 0, lp_move_timer = 0, bullet_move_timer = 0;
|
||||
int sp_generate_timer = 0, mp_generate_timer = 0, lp_generate_timer = 0, bullet_generate_timer = 0;
|
||||
int get_key_timer = 0, turbo_timer = 0;
|
||||
|
||||
Init();
|
||||
|
||||
sp_generate_interval = Random() % (SP_Generate_Interval_Max - SP_Generate_Interval_Min) + SP_Generate_Interval_Min;
|
||||
mp_generate_interval = Random() % (MP_Generate_Interval_Max - MP_Generate_Interval_Min) + MP_Generate_Interval_Min;
|
||||
lp_generate_interval = Random() % (LP_Generate_Interval_Max - LP_Generate_Interval_Min) + LP_Generate_Interval_Min;
|
||||
|
||||
while (1)
|
||||
{
|
||||
sp_move_timer++;
|
||||
mp_move_timer++;
|
||||
lp_move_timer++;
|
||||
bullet_move_timer++;
|
||||
|
||||
sp_generate_timer++;
|
||||
mp_generate_timer++;
|
||||
lp_generate_timer++;
|
||||
bullet_generate_timer++;
|
||||
|
||||
get_key_timer++;
|
||||
turbo_timer++;
|
||||
|
||||
if (sp_move_timer >= SP_Move_Interval)
|
||||
{
|
||||
Move_Plane(PLANE_TYPE_SMALL);
|
||||
sp_move_timer = 0;
|
||||
}
|
||||
|
||||
if (sp_generate_timer >= sp_generate_interval)
|
||||
{
|
||||
New_Plane(PLANE_TYPE_SMALL);
|
||||
sp_generate_timer = 0;
|
||||
sp_generate_interval = Random() % (SP_Generate_Interval_Max - SP_Generate_Interval_Min) + SP_Generate_Interval_Min;
|
||||
}
|
||||
|
||||
if (mp_move_timer >= MP_Move_Interval)
|
||||
{
|
||||
Move_Plane(PLANE_TYPE_MEDIUM);
|
||||
mp_move_timer = 0;
|
||||
}
|
||||
|
||||
if (mp_generate_timer >= mp_generate_interval)
|
||||
{
|
||||
New_Plane(PLANE_TYPE_MEDIUM);
|
||||
mp_generate_timer = 0;
|
||||
mp_generate_interval = Random() % (MP_Generate_Interval_Max - MP_Generate_Interval_Min) + MP_Generate_Interval_Min;
|
||||
}
|
||||
|
||||
if (lp_move_timer >= LP_Move_Interval)
|
||||
{
|
||||
Move_Plane(PLANE_TYPE_LARGE);
|
||||
lp_move_timer = 0;
|
||||
}
|
||||
|
||||
if (lp_generate_timer >= lp_generate_interval)
|
||||
{
|
||||
New_Plane(PLANE_TYPE_LARGE);
|
||||
lp_generate_timer = 0;
|
||||
lp_generate_interval = Random() % (LP_Generate_Interval_Max - LP_Generate_Interval_Min) + LP_Generate_Interval_Min;
|
||||
}
|
||||
|
||||
if (bullet_move_timer >= Bullet_Move_Interval)
|
||||
{
|
||||
Move_Bullet();
|
||||
bullet_move_timer = 0;
|
||||
}
|
||||
|
||||
if (bullet_generate_timer >= Bullet_Generate_Interval)
|
||||
{
|
||||
New_Bullet();
|
||||
bullet_generate_timer = 0;
|
||||
Score++;
|
||||
}
|
||||
|
||||
if (get_key_timer >= Get_Key_Interval)
|
||||
{
|
||||
get_key_timer = 0;
|
||||
switch (KEY_GetKey())
|
||||
{
|
||||
case JOY_U_DOWN:
|
||||
Move_Role_Plane(DIRECTION_UP);
|
||||
break;
|
||||
case JOY_D_DOWN:
|
||||
Move_Role_Plane(DIRECTION_DOWN);
|
||||
break;
|
||||
case JOY_L_DOWN:
|
||||
Move_Role_Plane(DIRECTION_LEFT);
|
||||
break;
|
||||
case JOY_R_DOWN:
|
||||
Move_Role_Plane(DIRECTION_RIGHT);
|
||||
}
|
||||
|
||||
// if (key_down(K_EXIT))
|
||||
// {
|
||||
// Game_Over();
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
if (turbo_timer >= Turbo_Interval)
|
||||
{
|
||||
if (SP_Generate_Interval_Max > 100)
|
||||
SP_Generate_Interval_Max -= 50;
|
||||
if (SP_Generate_Interval_Min > 50)
|
||||
SP_Generate_Interval_Min -= 25;
|
||||
if (SP_Move_Interval > 10)
|
||||
SP_Move_Interval--;
|
||||
|
||||
if (MP_Generate_Interval_Max > 200)
|
||||
MP_Generate_Interval_Max -= 100;
|
||||
if (MP_Generate_Interval_Min > 100)
|
||||
MP_Generate_Interval_Min -= 50;
|
||||
if (MP_Move_Interval > 15)
|
||||
MP_Move_Interval -= 2;
|
||||
|
||||
if (LP_Generate_Interval_Max > 2000)
|
||||
LP_Generate_Interval_Max -= 2000;
|
||||
if (LP_Generate_Interval_Min > 1000)
|
||||
LP_Generate_Interval_Min -= 1000;
|
||||
if (LP_Move_Interval > 30)
|
||||
LP_Move_Interval -= 3;
|
||||
|
||||
if (Turbo_Interval > 1000)
|
||||
Turbo_Interval -= 1000;
|
||||
turbo_timer = 0;
|
||||
}
|
||||
|
||||
if (Collision_Dection() == COLLISION_ROLE_PLANE)
|
||||
{
|
||||
Game_Over();
|
||||
return;
|
||||
}
|
||||
|
||||
ML_clear_vram();
|
||||
Draw_All();
|
||||
ML_display_vram();
|
||||
}
|
||||
}
|
||||
|
||||
void Move_Role_Plane(int direction)
|
||||
{
|
||||
if (direction == DIRECTION_UP && Role_Plane.y > 0)
|
||||
Role_Plane.y--;
|
||||
if (direction == DIRECTION_DOWN && Role_Plane.y + RP_GRAPHIC_HEIGHT < SCREEN_HEIGHT)
|
||||
Role_Plane.y++;
|
||||
if (direction == DIRECTION_LEFT && Role_Plane.x > 0)
|
||||
Role_Plane.x--;
|
||||
if (direction == DIRECTION_RIGHT && Role_Plane.x + RP_GRAPHIC_WIDTH < SCREEN_WIDTH - STATUS_BAR_WIDTH)
|
||||
Role_Plane.x++;
|
||||
}
|
||||
|
||||
void New_Bullet()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BULLET_MAX; i++)
|
||||
{
|
||||
if (Bullet[i].status == BULLET_STATUS_NONEXISTENT)
|
||||
{
|
||||
Bullet[i].status = BULLET_STATUS_FLYING;
|
||||
Bullet[i].x = Role_Plane.x + RP_GRAPHIC_WIDTH;
|
||||
Bullet[i].y = Role_Plane.y + (RP_GRAPHIC_HEIGHT >> 1) - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void New_Plane(int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (type == PLANE_TYPE_SMALL)
|
||||
{
|
||||
for (i = 0; i < SMALL_PLANE_MAX; i++)
|
||||
{
|
||||
if (Small_Plane[i].status == PLANE_STATUS_NONEXISTENT)
|
||||
{
|
||||
Small_Plane[i].status = SP_HEALTH_VAL;
|
||||
Small_Plane[i].x = SCREEN_WIDTH - STATUS_BAR_WIDTH;
|
||||
Small_Plane[i].y = Random() % (SCREEN_HEIGHT - SP_GRAPHIC_HEIGHT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == PLANE_TYPE_MEDIUM)
|
||||
{
|
||||
for (i = 0; i < MEDIUM_PLANE_MAX; i++)
|
||||
{
|
||||
if (Medium_Plane[i].status == PLANE_STATUS_NONEXISTENT)
|
||||
{
|
||||
Medium_Plane[i].status = MP_HEALTH_VAL;
|
||||
Medium_Plane[i].x = SCREEN_WIDTH - STATUS_BAR_WIDTH;
|
||||
Medium_Plane[i].y = Random() % (SCREEN_HEIGHT - MP_GRAPHIC_HEIGHT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == PLANE_TYPE_LARGE)
|
||||
{
|
||||
for (i = 0; i < LARGE_PLANE_MAX; i++)
|
||||
{
|
||||
if (Large_Plane[i].status == PLANE_STATUS_NONEXISTENT)
|
||||
{
|
||||
Large_Plane[i].status = LP_HEALTH_VAL;
|
||||
Large_Plane[i].x = SCREEN_WIDTH - STATUS_BAR_WIDTH;
|
||||
Large_Plane[i].y = Random() % (SCREEN_HEIGHT - LP_GRAPHIC_HEIGHT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Move_Plane(int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (type == PLANE_TYPE_SMALL)
|
||||
{
|
||||
for (i = 0; i < SMALL_PLANE_MAX; i++)
|
||||
{
|
||||
if (Small_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
Small_Plane[i].x--;
|
||||
if (Small_Plane[i].x < -SP_GRAPHIC_WIDTH)
|
||||
Small_Plane[i].status = PLANE_STATUS_NONEXISTENT;
|
||||
}
|
||||
else if (Small_Plane[i].status >= PLANE_STATUS_EXPLODING_1)
|
||||
{
|
||||
Small_Plane[i].status--;
|
||||
}
|
||||
else if (Small_Plane[i].status >= PLANE_STATUS_EXPLODING_2)
|
||||
{
|
||||
Small_Plane[i].status--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == PLANE_TYPE_MEDIUM)
|
||||
{
|
||||
for (i = 0; i < MEDIUM_PLANE_MAX; i++)
|
||||
{
|
||||
if (Medium_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
Medium_Plane[i].x--;
|
||||
if (Medium_Plane[i].x < -MP_GRAPHIC_WIDTH)
|
||||
Medium_Plane[i].status = PLANE_STATUS_NONEXISTENT;
|
||||
}
|
||||
else if (Medium_Plane[i].status >= PLANE_STATUS_EXPLODING_1)
|
||||
{
|
||||
Medium_Plane[i].status--;
|
||||
}
|
||||
else if (Medium_Plane[i].status >= PLANE_STATUS_EXPLODING_2)
|
||||
{
|
||||
Medium_Plane[i].status--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == PLANE_TYPE_LARGE)
|
||||
{
|
||||
for (i = 0; i < LARGE_PLANE_MAX; i++)
|
||||
{
|
||||
if (Large_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
Large_Plane[i].x--;
|
||||
if (Large_Plane[i].x < -LP_GRAPHIC_WIDTH)
|
||||
Large_Plane[i].status = PLANE_STATUS_NONEXISTENT;
|
||||
}
|
||||
else if (Large_Plane[i].status >= PLANE_STATUS_EXPLODING_1)
|
||||
{
|
||||
Large_Plane[i].status--;
|
||||
}
|
||||
else if (Large_Plane[i].status >= PLANE_STATUS_EXPLODING_2)
|
||||
{
|
||||
Large_Plane[i].status--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Move_Bullet()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BULLET_MAX; i++)
|
||||
{
|
||||
if (Bullet[i].status == BULLET_STATUS_FLYING)
|
||||
{
|
||||
Bullet[i].x++;
|
||||
if (Bullet[i].x > SCREEN_WIDTH - STATUS_BAR_WIDTH)
|
||||
Bullet[i].status = BULLET_STATUS_NONEXISTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SMALL_PLANE_MAX; i++)
|
||||
{
|
||||
Small_Plane[i].status = PLANE_STATUS_NONEXISTENT;
|
||||
}
|
||||
|
||||
for (i = 0; i < MEDIUM_PLANE_MAX; i++)
|
||||
{
|
||||
Medium_Plane[i].status = PLANE_STATUS_NONEXISTENT;
|
||||
}
|
||||
|
||||
for (i = 0; i < LARGE_PLANE_MAX; i++)
|
||||
{
|
||||
Large_Plane[i].status = PLANE_STATUS_NONEXISTENT;
|
||||
}
|
||||
|
||||
for (i = 0; i < BULLET_MAX; i++)
|
||||
{
|
||||
Bullet[i].status = BULLET_STATUS_NONEXISTENT;
|
||||
}
|
||||
|
||||
Role_Plane.x = 0;
|
||||
Role_Plane.y = (SCREEN_HEIGHT - RP_GRAPHIC_HEIGHT) / 2;
|
||||
Role_Plane.status = PLANE_STATUS_ALIVE;
|
||||
|
||||
SP_Generate_Interval_Max = 300; //600
|
||||
SP_Generate_Interval_Min = 150; //300
|
||||
SP_Move_Interval = 3; //20
|
||||
|
||||
MP_Generate_Interval_Max = 600; //1200
|
||||
MP_Generate_Interval_Min = 300; //600
|
||||
MP_Move_Interval = 5; //30
|
||||
|
||||
LP_Generate_Interval_Max = 6000; //12000
|
||||
LP_Generate_Interval_Min = 3000; //6000
|
||||
LP_Move_Interval = 10; //60
|
||||
|
||||
Bullet_Move_Interval = 1; //3
|
||||
Bullet_Generate_Interval = 30; //100
|
||||
|
||||
Get_Key_Interval = 1;
|
||||
Turbo_Interval = 10000;
|
||||
|
||||
SP_Destroyed = 0;
|
||||
MP_Destroyed = 0;
|
||||
LP_Destroyed = 0;
|
||||
Score = 0;
|
||||
}
|
||||
|
||||
void Draw_All()
|
||||
{
|
||||
int i, j, digit, remain;
|
||||
unsigned char tmp;
|
||||
|
||||
for (i = 0; i < LARGE_PLANE_MAX; i++)
|
||||
{
|
||||
if (Large_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_LP_CoverArea, Large_Plane[i].x, Large_Plane[i].y, LP_GRAPHIC_WIDTH, LP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_LP_ClearArea, Large_Plane[i].x, Large_Plane[i].y, LP_GRAPHIC_WIDTH, LP_GRAPHIC_HEIGHT);
|
||||
}
|
||||
else if (Large_Plane[i].status >= PLANE_STATUS_EXPLODING_1)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_LP_CoverArea, Large_Plane[i].x, Large_Plane[i].y, LP_GRAPHIC_WIDTH, LP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_LP_ClearArea, Large_Plane[i].x, Large_Plane[i].y, LP_GRAPHIC_WIDTH, LP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_Large_1, Large_Plane[i].x, Large_Plane[i].y, 16, 16);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_Large_1, Large_Plane[i].x + LP_GRAPHIC_WIDTH - 16, Large_Plane[i].y + LP_GRAPHIC_HEIGHT - 16, 16, 16);
|
||||
}
|
||||
else if (Large_Plane[i].status >= PLANE_STATUS_EXPLODING_2)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_LP_CoverArea, Large_Plane[i].x, Large_Plane[i].y, LP_GRAPHIC_WIDTH, LP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_LP_ClearArea, Large_Plane[i].x, Large_Plane[i].y, LP_GRAPHIC_WIDTH, LP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_Large_2, Large_Plane[i].x, Large_Plane[i].y, 16, 16);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_Large_2, Large_Plane[i].x + LP_GRAPHIC_WIDTH - 16, Large_Plane[i].y + LP_GRAPHIC_HEIGHT - 16, 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MEDIUM_PLANE_MAX; i++)
|
||||
{
|
||||
if (Medium_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_MP_CoverArea, Medium_Plane[i].x, Medium_Plane[i].y, MP_GRAPHIC_WIDTH, MP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_MP_ClearArea, Medium_Plane[i].x, Medium_Plane[i].y, MP_GRAPHIC_WIDTH, MP_GRAPHIC_HEIGHT);
|
||||
}
|
||||
else if (Medium_Plane[i].status >= PLANE_STATUS_EXPLODING_1)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_MP_CoverArea, Medium_Plane[i].x, Medium_Plane[i].y, MP_GRAPHIC_WIDTH, MP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_MP_ClearArea, Medium_Plane[i].x, Medium_Plane[i].y, MP_GRAPHIC_WIDTH, MP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_1, Medium_Plane[i].x + 2, Medium_Plane[i].y, 8, 8);
|
||||
}
|
||||
else if (Medium_Plane[i].status >= PLANE_STATUS_EXPLODING_2)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_MP_CoverArea, Medium_Plane[i].x, Medium_Plane[i].y, MP_GRAPHIC_WIDTH, MP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_MP_ClearArea, Medium_Plane[i].x, Medium_Plane[i].y, MP_GRAPHIC_WIDTH, MP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_2, Medium_Plane[i].x + 2, Medium_Plane[i].y, 8, 8);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SMALL_PLANE_MAX; i++)
|
||||
{
|
||||
if (Small_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_SP_CoverArea, Small_Plane[i].x, Small_Plane[i].y, SP_GRAPHIC_WIDTH, SP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_SP_ClearArea, Small_Plane[i].x, Small_Plane[i].y, SP_GRAPHIC_WIDTH, SP_GRAPHIC_HEIGHT);
|
||||
}
|
||||
else if (Small_Plane[i].status >= PLANE_STATUS_EXPLODING_1)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_SP_CoverArea, Small_Plane[i].x, Small_Plane[i].y, SP_GRAPHIC_WIDTH, SP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_SP_ClearArea, Small_Plane[i].x, Small_Plane[i].y, SP_GRAPHIC_WIDTH, SP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_1, Small_Plane[i].x, Small_Plane[i].y - 1, 8, 8);
|
||||
}
|
||||
else if (Small_Plane[i].status >= PLANE_STATUS_EXPLODING_2)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_SP_CoverArea, Small_Plane[i].x, Small_Plane[i].y, SP_GRAPHIC_WIDTH, SP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_SP_ClearArea, Small_Plane[i].x, Small_Plane[i].y, SP_GRAPHIC_WIDTH, SP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_2, Small_Plane[i].x, Small_Plane[i].y - 1, 8, 8);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < BULLET_MAX; i++)
|
||||
{
|
||||
if (Bullet[i].status == BULLET_STATUS_FLYING)
|
||||
ML_bmp_or_cl(Bitmap_Bullet, Bullet[i].x, Bullet[i].y, BULLET_GRAPHIC_WIDTH, BULLET_GRAPHIC_HEIGHT);
|
||||
}
|
||||
|
||||
if (Role_Plane.status == PLANE_STATUS_ALIVE)
|
||||
{
|
||||
ML_bmp_or_cl(Bitmap_RP_CoverArea, Role_Plane.x, Role_Plane.y, RP_GRAPHIC_WIDTH, RP_GRAPHIC_HEIGHT);
|
||||
ML_bmp_xor_cl(Bitmap_RP_ClearArea, Role_Plane.x, Role_Plane.y, RP_GRAPHIC_WIDTH, RP_GRAPHIC_HEIGHT);
|
||||
}
|
||||
|
||||
j = 10000000;
|
||||
remain = Score;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
digit = remain / j;
|
||||
ML_bmp_or_cl(Bitmap_Numbers[digit], SCREEN_WIDTH - STATUS_BAR_WIDTH, i * 4, 7, 3);
|
||||
remain -= digit * j;
|
||||
j /= 10;
|
||||
}
|
||||
|
||||
GE_Draw_Rectangle(32, 56, 257, 129, BLACK);
|
||||
}
|
||||
|
||||
int Collision_Dection()
|
||||
{
|
||||
int i, j;
|
||||
int x1, y1, w1, h1, x2, y2, w2, h2, x3, y3, w3, h3;
|
||||
|
||||
x1 = Role_Plane.x + RP_COLLISION_POS_X;
|
||||
y1 = Role_Plane.y + RP_COLLISION_POS_Y;
|
||||
w1 = RP_COLLISION_WIDTH;
|
||||
h1 = RP_COLLISION_HEIGHT;
|
||||
|
||||
w2 = SP_COLLISION_WIDTH;
|
||||
h2 = SP_COLLISION_HEIGHT;
|
||||
w3 = BULLET_COLLISION_WIDTH;
|
||||
h3 = BULLET_COLLISION_HEIGHT;
|
||||
for (i = 0; i < SMALL_PLANE_MAX; i++)
|
||||
{
|
||||
if (Small_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
x2 = Small_Plane[i].x + SP_COLLISION_POS_X;
|
||||
y2 = Small_Plane[i].y + SP_COLLISION_POS_Y;
|
||||
if (x1 - x2 < w2 && x2 - x1 < w1 && y1 - y2 < h2 && y2 - y1 < h1)
|
||||
return COLLISION_ROLE_PLANE;
|
||||
for (j = 0; j < BULLET_MAX; j++)
|
||||
{
|
||||
if (Bullet[j].status == BULLET_STATUS_FLYING)
|
||||
{
|
||||
x3 = Bullet[j].x + BULLET_COLLISION_POS_X;
|
||||
y3 = Bullet[j].y + BULLET_COLLISION_POS_Y;
|
||||
if (x3 - x2 < w2 && x2 - x3 < w3 && y3 - y2 < h2 && y2 - y3 < h3)
|
||||
{
|
||||
Small_Plane[i].status--;
|
||||
if (Small_Plane[i].status == PLANE_STATUS_ALIVE - 1)
|
||||
{
|
||||
SP_Destroyed++;
|
||||
Score += 1000;
|
||||
}
|
||||
Bullet[j].status = BULLET_STATUS_NONEXISTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
w2 = MP_COLLISION_WIDTH;
|
||||
h2 = MP_COLLISION_HEIGHT;
|
||||
w3 = BULLET_COLLISION_WIDTH;
|
||||
h3 = BULLET_COLLISION_HEIGHT;
|
||||
for (i = 0; i < MEDIUM_PLANE_MAX; i++)
|
||||
{
|
||||
if (Medium_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
x2 = Medium_Plane[i].x + MP_COLLISION_POS_X;
|
||||
y2 = Medium_Plane[i].y + MP_COLLISION_POS_Y;
|
||||
if (x1 - x2 < w2 && x2 - x1 < w1 && y1 - y2 < h2 && y2 - y1 < h1)
|
||||
return COLLISION_ROLE_PLANE;
|
||||
for (j = 0; j < BULLET_MAX; j++)
|
||||
{
|
||||
if (Bullet[j].status == BULLET_STATUS_FLYING)
|
||||
{
|
||||
x3 = Bullet[j].x + BULLET_COLLISION_POS_X;
|
||||
y3 = Bullet[j].y + BULLET_COLLISION_POS_Y;
|
||||
if (x3 - x2 < w2 && x2 - x3 < w3 && y3 - y2 < h2 && y2 - y3 < h3)
|
||||
{
|
||||
Medium_Plane[i].status--;
|
||||
if (Medium_Plane[i].status == PLANE_STATUS_ALIVE - 1)
|
||||
{
|
||||
MP_Destroyed++;
|
||||
Score += 6000;
|
||||
}
|
||||
Bullet[j].status = BULLET_STATUS_NONEXISTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
w2 = LP_COLLISION_WIDTH;
|
||||
h2 = LP_COLLISION_HEIGHT;
|
||||
w3 = BULLET_COLLISION_WIDTH;
|
||||
h3 = BULLET_COLLISION_HEIGHT;
|
||||
for (i = 0; i < LARGE_PLANE_MAX; i++)
|
||||
{
|
||||
if (Large_Plane[i].status >= PLANE_STATUS_ALIVE)
|
||||
{
|
||||
x2 = Large_Plane[i].x + LP_COLLISION_POS_X;
|
||||
y2 = Large_Plane[i].y + LP_COLLISION_POS_Y;
|
||||
if (x1 - x2 < w2 && x2 - x1 < w1 && y1 - y2 < h2 && y2 - y1 < h1)
|
||||
return COLLISION_ROLE_PLANE;
|
||||
for (j = 0; j < BULLET_MAX; j++)
|
||||
{
|
||||
if (Bullet[j].status == BULLET_STATUS_FLYING)
|
||||
{
|
||||
x3 = Bullet[j].x + BULLET_COLLISION_POS_X;
|
||||
y3 = Bullet[j].y + BULLET_COLLISION_POS_Y;
|
||||
if (x3 - x2 < w2 && x2 - x3 < w3 && y3 - y2 < h2 && y2 - y3 < h3)
|
||||
{
|
||||
Large_Plane[i].status--;
|
||||
if (Large_Plane[i].status == PLANE_STATUS_ALIVE - 1)
|
||||
{
|
||||
LP_Destroyed++;
|
||||
Score += 10000;
|
||||
}
|
||||
Bullet[j].status = BULLET_STATUS_NONEXISTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NO_COLLISION_ROLE_PLANE;
|
||||
}
|
||||
|
||||
void Game_Over()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BULLET_MAX; i++)
|
||||
{
|
||||
Bullet[i].status = BULLET_STATUS_NONEXISTENT;
|
||||
}
|
||||
|
||||
ML_clear_vram();
|
||||
Draw_All();
|
||||
ML_display_vram();
|
||||
Sleep(750);
|
||||
ML_bmp_or_cl(Bitmap_Explosion_Large_1, Role_Plane.x - 2, Role_Plane.y - 2, 16, 16);
|
||||
ML_display_vram();
|
||||
Sleep(750);
|
||||
ML_clear_vram();
|
||||
Draw_All();
|
||||
ML_bmp_or_cl(Bitmap_Explosion_Large_2, Role_Plane.x - 2, Role_Plane.y - 2, 16, 16);
|
||||
ML_display_vram();
|
||||
Sleep(1500);
|
||||
}
|
||||
8
User/APP_Plane/APP_Plane.h
Normal file
8
User/APP_Plane/APP_Plane.h
Normal file
@ -0,0 +1,8 @@
|
||||
//飞机大战游戏
|
||||
|
||||
#ifndef __APP_PLANE
|
||||
#define __APP_PLANE
|
||||
|
||||
void APP_Plane_Launcher(void);
|
||||
|
||||
#endif
|
||||
162
User/APP_Plane/APP_Plane_Bitmap.h
Normal file
162
User/APP_Plane/APP_Plane_Bitmap.h
Normal file
@ -0,0 +1,162 @@
|
||||
#ifndef __APP_PLANE_BITMAP_H
|
||||
#define __APP_PLANE_BITMAP_H
|
||||
|
||||
const unsigned char Bitmap_SP_CoverArea[] = {
|
||||
0x18, 0x38, 0x7a, 0xfe, 0x7a, 0x38, 0x18};
|
||||
|
||||
const unsigned char Bitmap_SP_ClearArea[] = {
|
||||
0x00, 0x10, 0x30, 0x40, 0x30, 0x10, 0x00};
|
||||
|
||||
const unsigned char Bitmap_MP_CoverArea[] = {
|
||||
0x0f, 0x00, 0x02, 0x00, 0x1f, 0x00, 0x7f, 0xa0, 0xff, 0xf0, 0x7f, 0xa0, 0x1f, 0x00, 0x02, 0x00,
|
||||
0x0f, 0x00};
|
||||
|
||||
const unsigned char Bitmap_MP_ClearArea[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x56, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00};
|
||||
|
||||
const unsigned char Bitmap_LP_CoverArea[] = {
|
||||
0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x08, 0x00, 0x00, 0x07, 0xe0, 0x1f, 0xff, 0x80, 0x0f,
|
||||
0xff, 0xc9, 0xe0, 0x00, 0x1f, 0xff, 0xe7, 0xc0, 0x00, 0x3f, 0xff, 0xcf, 0x80, 0x00, 0x7f, 0xff,
|
||||
0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff,
|
||||
0x80, 0x00, 0x7f, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xff, 0xff, 0x80,
|
||||
0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x00,
|
||||
0x3f, 0xff, 0xcf, 0x80, 0x00, 0x1f, 0xff, 0xe7, 0xc0, 0x00, 0x0f, 0xff, 0xc9, 0xe0, 0x00, 0x07,
|
||||
0xe0, 0x1f, 0xff, 0x80, 0x03, 0xc0, 0x08, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00};
|
||||
|
||||
const unsigned char Bitmap_LP_ClearArea[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc0, 0x00, 0x0f, 0xcf, 0xc1, 0x80, 0x00, 0x1c, 0x37, 0x87, 0x00, 0x00, 0x33, 0x00,
|
||||
0x0e, 0x00, 0x00, 0x26, 0xff, 0xfe, 0x00, 0x00, 0x1d, 0x00, 0x06, 0x00, 0x00, 0x6b, 0x3f, 0x98,
|
||||
0x00, 0x00, 0x2a, 0xd2, 0xb4, 0x80, 0x00, 0x0a, 0xd2, 0xb4, 0x80, 0x00, 0x2b, 0x3f, 0x98, 0x00,
|
||||
0x00, 0x1d, 0x00, 0x06, 0x00, 0x00, 0x26, 0xff, 0xfe, 0x00, 0x00, 0x32, 0x00, 0x0e, 0x00, 0x00,
|
||||
0x1c, 0x37, 0x87, 0x00, 0x00, 0x0f, 0xcf, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x02,
|
||||
0x40, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
const unsigned char Bitmap_RP_CoverArea[] = {
|
||||
0x18, 0x00, 0x3c, 0x00, 0xff, 0x80, 0x3f, 0x00, 0x1f, 0x80, 0x3f, 0xf0, 0x3f, 0xf8, 0x3f, 0xf0,
|
||||
0x1f, 0x80, 0x3f, 0x00, 0xff, 0x80, 0x3c, 0x00, 0x18, 0x00};
|
||||
|
||||
const unsigned char Bitmap_RP_ClearArea[] = {
|
||||
0x00, 0x00, 0x08, 0x00, 0x2c, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x14, 0x00, 0x11, 0x30, 0x14, 0x00,
|
||||
0x03, 0x00, 0x0e, 0x00, 0x2c, 0x00, 0x08, 0x00, 0x00, 0x00};
|
||||
|
||||
const unsigned char Bitmap_Bullet[] = {
|
||||
0x70, 0xf8, 0x70};
|
||||
|
||||
const unsigned char Bitmap_Explosion_1[] = {
|
||||
0x00, 0x00, 0x08, 0x10, 0x3a, 0xac, 0x10, 0x00};
|
||||
|
||||
const unsigned char Bitmap_Explosion_2[] = {
|
||||
0x01, 0x25, 0x12, 0xb1, 0x74, 0x88, 0x97, 0x4c};
|
||||
|
||||
const unsigned char Bitmap_Explosion_Large_1[] = {
|
||||
0x00, 0x00, 0x20, 0x00, 0x08, 0x00, 0x20, 0x00, 0x09, 0x00, 0x0c, 0x20, 0x46, 0x10, 0x10, 0x20,
|
||||
0x10, 0x30, 0x0a, 0x10, 0x05, 0x80, 0x00, 0x00, 0x00, 0x80, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
const unsigned char Bitmap_Explosion_Large_2[] = {
|
||||
0x02,
|
||||
0x00,
|
||||
0x27,
|
||||
0x38,
|
||||
0x07,
|
||||
0x34,
|
||||
0x51,
|
||||
0x61,
|
||||
0x19,
|
||||
0x80,
|
||||
0x27,
|
||||
0xda,
|
||||
0x7d,
|
||||
0xf0,
|
||||
0xb0,
|
||||
0xa9,
|
||||
0x4f,
|
||||
0x30,
|
||||
0x2a,
|
||||
0xa0,
|
||||
0x8f,
|
||||
0x3b,
|
||||
0x03,
|
||||
0x2c,
|
||||
0x1a,
|
||||
0x41,
|
||||
0x29,
|
||||
0xc8,
|
||||
0x44,
|
||||
0x20,
|
||||
0x10,
|
||||
0x00,
|
||||
};
|
||||
|
||||
const unsigned char Bitmap_Numbers[][3] = {
|
||||
0xfe, 0x82, 0xfe, 0x82, 0xfe, 0x80, 0xf2, 0x92, 0x9e, 0x92, 0x92, 0xfe, 0x1e, 0x10, 0xfe, 0x9e,
|
||||
0x92, 0xf2, 0xfe, 0x92, 0xf2, 0x02, 0x02, 0xfe, 0xfe, 0x92, 0xfe, 0x9e, 0x92, 0xfe};
|
||||
|
||||
const unsigned char Bitmap_Menu[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0x1f, 0xff, 0xff, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xef, 0xbf, 0xff, 0xf7, 0xff, 0x1f, 0xff, 0xff, 0x3f, 0xe0, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xf7, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xe0, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xef, 0xbf, 0xff, 0xf7, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xef, 0xbf, 0xfc, 0x07, 0xff, 0x1f, 0xff, 0xff, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xed, 0xff, 0xef, 0xbf, 0xfd, 0xb7, 0xff, 0x1f, 0xff, 0xff, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xed, 0xff, 0xed, 0xbf, 0xfd, 0xb7, 0xff, 0x00, 0x00, 0x07, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xed, 0xff, 0xe1, 0xbf, 0xfd, 0xb7, 0xff, 0x00, 0x00, 0x07, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xfd, 0xb7, 0xff, 0x00, 0x00, 0x07, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xfd, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x6d, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x6d, 0xff, 0xfd, 0xff, 0xfc, 0x07, 0xff, 0x00, 0x00, 0x07, 0x39, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x61, 0xff, 0xe0, 0x3f, 0xfd, 0xff, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0x7d, 0xff, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0x7d, 0xff, 0xed, 0xbf, 0xfc, 0x07, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xed, 0xbf, 0xfd, 0xf7, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xed, 0xbf, 0xfd, 0xf7, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xe1, 0xbf, 0xfd, 0xb7, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xfc, 0x37, 0xff, 0xff, 0x8f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0x7f, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0x7f, 0xff, 0xef, 0xbf, 0xfc, 0x07, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xef, 0xbf, 0xff, 0xb7, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xef, 0xbf, 0xff, 0xb7, 0xff, 0xff, 0xff, 0xff, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xfd, 0xff, 0xef, 0xbf, 0xff, 0xb7, 0xff, 0xff, 0xff, 0xff, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0x9f, 0xff,
|
||||
0xff, 0xff, 0x01, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xfd, 0xff, 0xef, 0xbf, 0xfc, 0x07, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xfd, 0xff, 0xef, 0xbf, 0xff, 0xf7, 0xff, 0x00, 0x00, 0x07, 0x3f, 0xff, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xef, 0xbf, 0xfc, 0x07, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xff, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xf7, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xff, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0x8f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfd, 0xbf, 0xfc, 0x07, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfd, 0xbf, 0xfd, 0xb7, 0xff, 0xff, 0x8f, 0xc7, 0x3f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe1, 0xbf, 0xfd, 0xb7, 0xff, 0x00, 0x0f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xec, 0x3f, 0xfd, 0xb7, 0xff, 0x00, 0x0f, 0xc7, 0x38, 0x00, 0x1f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xb7, 0xff, 0x00, 0x0f, 0xc7, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0x1f, 0x80, 0x07, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xed, 0xbf, 0xff, 0xff, 0xff, 0x1f, 0x80, 0x07, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xed, 0xbf, 0xff, 0xff, 0xff, 0x1f, 0x80, 0x07, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xed, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xed, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xe7, 0x9f, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
#endif
|
||||
224
User/FxLib/fxlib.c
Normal file
224
User/FxLib/fxlib.c
Normal file
@ -0,0 +1,224 @@
|
||||
//fxlib 兼容层,用于从 fx-9860 平台向 STM32-Player 移植程序
|
||||
|
||||
#include "sys.h"
|
||||
#include "systick.h"
|
||||
|
||||
#include "led.h"
|
||||
#include "key.h"
|
||||
#include "lcd.h"
|
||||
|
||||
#include "GameEngine.h"
|
||||
|
||||
#include "fxlib.h"
|
||||
|
||||
/**************************************** 私有函数 ****************************************/
|
||||
|
||||
void FX_Draw_Point(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
uint16_t FX_Draw_GetPoint(int16_t x, int16_t y);
|
||||
|
||||
void FX_Draw_Mono(
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
uint8_t draw_mode,
|
||||
uint8_t pos_mode,
|
||||
uint16_t mono_color,
|
||||
uint16_t back_color,
|
||||
const unsigned char *pic,
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
/***************************************** FxLib *****************************************/
|
||||
|
||||
void Sleep(int millisecond)
|
||||
{
|
||||
Delay_ms(millisecond);
|
||||
}
|
||||
|
||||
void ML_clear_vram()
|
||||
{
|
||||
GE_Draw_ClrAll(WHITE);
|
||||
}
|
||||
|
||||
void ML_clear_screen()
|
||||
{
|
||||
GE_Draw_ClrAll(WHITE);
|
||||
GE_Draw_Disp();
|
||||
}
|
||||
|
||||
void ML_display_vram()
|
||||
{
|
||||
GE_Draw_Disp();
|
||||
}
|
||||
|
||||
void ML_bmp_or(const unsigned char *bmp, int x, int y, int width, int height)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_OR, UP_LEFT, BLACK, WHITE, bmp, width, height);
|
||||
}
|
||||
|
||||
void ML_bmp_and(const unsigned char *bmp, int x, int y, int width, int height)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_AND, UP_LEFT, BLACK, WHITE, bmp, width, height);
|
||||
}
|
||||
|
||||
void ML_bmp_xor(const unsigned char *bmp, int x, int y, int width, int height)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_XOR, UP_LEFT, BLACK, WHITE, bmp, width, height);
|
||||
}
|
||||
|
||||
void ML_bmp_or_cl(const unsigned char *bmp, int x, int y, int width, int height)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_OR, UP_LEFT, BLACK, WHITE, bmp, width, height);
|
||||
}
|
||||
|
||||
void ML_bmp_and_cl(const unsigned char *bmp, int x, int y, int width, int height)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_AND, UP_LEFT, BLACK, WHITE, bmp, width, height);
|
||||
}
|
||||
|
||||
void ML_bmp_xor_cl(const unsigned char *bmp, int x, int y, int width, int height)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_XOR, UP_LEFT, BLACK, WHITE, bmp, width, height);
|
||||
}
|
||||
|
||||
void ML_bmp_8_or(const unsigned char *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_OR, UP_LEFT, BLACK, WHITE, bmp, 8, 8);
|
||||
}
|
||||
|
||||
void ML_bmp_8_and(const unsigned char *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_AND, UP_LEFT, BLACK, WHITE, bmp, 8, 8);
|
||||
}
|
||||
|
||||
void ML_bmp_8_xor(const unsigned char *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_XOR, UP_LEFT, BLACK, WHITE, bmp, 8, 8);
|
||||
}
|
||||
|
||||
void ML_bmp_8_or_cl(const unsigned char *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_OR, UP_LEFT, BLACK, WHITE, bmp, 8, 8);
|
||||
}
|
||||
|
||||
void ML_bmp_8_and_cl(const unsigned char *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_AND, UP_LEFT, BLACK, WHITE, bmp, 8, 8);
|
||||
}
|
||||
|
||||
void ML_bmp_8_xor_cl(const unsigned char *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_XOR, UP_LEFT, BLACK, WHITE, bmp, 8, 8);
|
||||
}
|
||||
|
||||
void ML_bmp_16_or(const unsigned short *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_OR, UP_LEFT, BLACK, WHITE, bmp, 16, 16);
|
||||
}
|
||||
|
||||
void ML_bmp_16_and(const unsigned short *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_AND, UP_LEFT, BLACK, WHITE, bmp, 16, 16);
|
||||
}
|
||||
|
||||
void ML_bmp_16_xor(const unsigned short *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_XOR, UP_LEFT, BLACK, WHITE, bmp, 16, 16);
|
||||
}
|
||||
|
||||
void ML_bmp_16_or_cl(const unsigned short *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_OR, UP_LEFT, BLACK, WHITE, bmp, 16, 16);
|
||||
}
|
||||
|
||||
void ML_bmp_16_and_cl(const unsigned short *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_AND, UP_LEFT, BLACK, WHITE, bmp, 16, 16);
|
||||
}
|
||||
|
||||
void ML_bmp_16_xor_cl(const unsigned short *bmp, int x, int y)
|
||||
{
|
||||
FX_Draw_Mono(x, y, MONO_XOR, UP_LEFT, BLACK, WHITE, bmp, 16, 16);
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
/**************************************** 私有函数 ****************************************/
|
||||
|
||||
void FX_Draw_Point(int16_t x, int16_t y, uint16_t color)
|
||||
{
|
||||
if (x < 0 || x > ML_SCREEN_WIDTH - 1 || y < 0 || y > ML_SCREEN_HEIGHT - 1)
|
||||
return;
|
||||
|
||||
x = 2 * x + 33;
|
||||
y = 2 * y + 57;
|
||||
|
||||
GE_Draw_Point(x, y, color);
|
||||
GE_Draw_Point(x + 1, y, color);
|
||||
GE_Draw_Point(x, y + 1, color);
|
||||
GE_Draw_Point(x + 1, y + 1, color);
|
||||
}
|
||||
|
||||
uint16_t FX_Draw_GetPoint(int16_t x, int16_t y)
|
||||
{
|
||||
if (x < 0 || x > ML_SCREEN_WIDTH - 1 || y < 0 || y > ML_SCREEN_HEIGHT - 1)
|
||||
return WHITE;
|
||||
|
||||
return GE_Draw_GetPoint(2 * x + 33, 2 * y + 57);
|
||||
}
|
||||
|
||||
void FX_Draw_Mono(
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
uint8_t draw_mode,
|
||||
uint8_t pos_mode,
|
||||
uint16_t mono_color,
|
||||
uint16_t back_color,
|
||||
const unsigned char *pic,
|
||||
uint16_t width,
|
||||
uint16_t height)
|
||||
{
|
||||
if (pos_mode == MID)
|
||||
{
|
||||
x = x - width / 2;
|
||||
y = y - height / 2;
|
||||
}
|
||||
|
||||
uint8_t temp8;
|
||||
int16_t x0 = x, y0 = y;
|
||||
|
||||
for (uint16_t i = 0; y - y0 < height; i++)
|
||||
{
|
||||
temp8 = pic[i];
|
||||
|
||||
for (uint16_t j = 0; j < 8; j++)
|
||||
{
|
||||
if (temp8 & 0x80)
|
||||
{
|
||||
if (FX_Draw_GetPoint(x, y) == back_color && (draw_mode == MONO_OR || draw_mode == MONO_XOR || draw_mode == MONO_COVER))
|
||||
FX_Draw_Point(x, y, mono_color);
|
||||
else if (FX_Draw_GetPoint(x, y) == mono_color && draw_mode == MONO_XOR)
|
||||
FX_Draw_Point(x, y, back_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FX_Draw_GetPoint(x, y) == mono_color && (draw_mode == MONO_AND || draw_mode == MONO_COVER))
|
||||
FX_Draw_Point(x, y, back_color);
|
||||
}
|
||||
|
||||
temp8 <<= 1;
|
||||
|
||||
x++;
|
||||
if (x - x0 == width)
|
||||
{
|
||||
x = x0;
|
||||
y++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
36
User/FxLib/fxlib.h
Normal file
36
User/FxLib/fxlib.h
Normal file
@ -0,0 +1,36 @@
|
||||
//fxlib 兼容层,用于从 fx-9860 平台向 STM32-Player 移植程序
|
||||
|
||||
#ifndef __FXLIB_H
|
||||
#define __FXLIB_H
|
||||
|
||||
#define ML_SCREEN_WIDTH 128
|
||||
#define ML_SCREEN_HEIGHT 64
|
||||
|
||||
void Sleep(int millisecond);
|
||||
|
||||
void ML_clear_vram();
|
||||
void ML_clear_screen();
|
||||
void ML_display_vram();
|
||||
|
||||
void ML_bmp_or(const unsigned char *bmp, int x, int y, int width, int height);
|
||||
void ML_bmp_and(const unsigned char *bmp, int x, int y, int width, int height);
|
||||
void ML_bmp_xor(const unsigned char *bmp, int x, int y, int width, int height);
|
||||
void ML_bmp_or_cl(const unsigned char *bmp, int x, int y, int width, int height);
|
||||
void ML_bmp_and_cl(const unsigned char *bmp, int x, int y, int width, int height);
|
||||
void ML_bmp_xor_cl(const unsigned char *bmp, int x, int y, int width, int height);
|
||||
|
||||
void ML_bmp_8_or(const unsigned char *bmp, int x, int y);
|
||||
void ML_bmp_8_and(const unsigned char *bmp, int x, int y);
|
||||
void ML_bmp_8_xor(const unsigned char *bmp, int x, int y);
|
||||
void ML_bmp_8_or_cl(const unsigned char *bmp, int x, int y);
|
||||
void ML_bmp_8_and_cl(const unsigned char *bmp, int x, int y);
|
||||
void ML_bmp_8_xor_cl(const unsigned char *bmp, int x, int y);
|
||||
|
||||
void ML_bmp_16_or(const unsigned short *bmp, int x, int y);
|
||||
void ML_bmp_16_and(const unsigned short *bmp, int x, int y);
|
||||
void ML_bmp_16_xor(const unsigned short *bmp, int x, int y);
|
||||
void ML_bmp_16_or_cl(const unsigned short *bmp, int x, int y);
|
||||
void ML_bmp_16_and_cl(const unsigned short *bmp, int x, int y);
|
||||
void ML_bmp_16_xor_cl(const unsigned short *bmp, int x, int y);
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user