模拟射击游戏仿真没问题,实物也做出来了
2
1
单片机程序源码:
- #include<reg52.h>
- #include <intrins.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <lcd_160128.h>
- extern uchar LCD_Initialise();
- extern uchar LCD_Write_Command(uchar cmd);
- extern uchar LCD_Write_Command_P1(uchar cmd,uchar paral);
- extern uchar LCD_Write_Command_P2(uchar cmd,uchar paral,uchar para2);
- extern uchar LCD_Write_Data(uchar dat);
- extern void Set_LCD_POS(uchar row,uchar col) reentrant;
- extern void Line(uchar x1,uchar y1,uchar x2,uchar y2,uchar Mode) reentrant;//以上在中断中也有用到所以定义为可重入函数
- extern void Draw_Image(uchar *G_Buffer,uchar Start_Row,uchar Start_Col)reentrant;
- extern void Display_Str_at_xy(uchar x,uchar y,char *Buffer,uchar wb) reentrant;
- extern void cls();
- void Show_Score_and_Bullet() reentrant;
- sbit K1=P1^4;
- sbit K2=P1^5;
- sbit K3=P1^6;
- sbit K4=P1^7;
- sbit BEEP=P1^0;
- //开机界面绘制//
- code uchar const Game_Surface[]=
- {160,110,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFC,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x0E,0x1F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x7F,0xDF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFC,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x1F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x03,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x7F,0xFF,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0xFF,0xFF,0xE0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x7F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0x7F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x7F,0xFF,0xF0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFC,0xFF,
- 0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x0F,0xFF,0xFC,0x3F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0xFF,0xFC,0x07,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0xFF,0xFF,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF0,
- 0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFE,0x03,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xC0,0x7F,0xFF,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF8,0x0F,0xFF,0xE0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
- 0xFF,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x1F,0xFF,0xE0,0x3F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFC,0x0F,0xFF,0xF0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x01,0xFF,
- 0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x0F,0xFF,0xE0,0x3F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0xFF,0xFC,0x07,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0xFF,0xFE,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF0,
- 0x1F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x01,0xFF,0xFE,0x03,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xC0,0x7F,0xFF,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF8,0x0F,0xFF,0xC0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
- 0xFE,0x03,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x1F,0xFF,0xC0,0x7F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xF0,0x0F,0xFF,0xE0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x01,0xFF,
- 0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x0F,0xFF,0xC0,0x7F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x03,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x01,0xFF,0xFE,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xE0,
- 0x3F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x03,0xFF,0xFC,0x07,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x83,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xE7,0xFF,0xFF,0xFF,
- 0x07,0x80,0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xCF,0xC0,0x00,0x00,0x00,0x07,0xFF,0xFF,0x80,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x1F,0xFF,0xFF,
- 0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,
- 0x00,0x3F,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x03,0xFF,
- 0xFF,0xE0,0x00,0x00,0x00,0x7F,0xC0,0x07,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x3F,0xFF,0xC0,0x7F,0xFF,0xE0,0x00,0x00,0x00,0xFF,0x00,0x03,0xFC,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x0F,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x00,0x01,0xFC,0x00,0x00,
- 0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0x01,0xFF,0xFE,0x00,0x00,
- 0x01,0xF8,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x9F,0xFF,0xC0,
- 0x3F,0xFF,0x80,0x00,0x03,0xF0,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x1F,0x03,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x07,0xE0,0x00,0x00,0x1F,0x80,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x3F,0x00,0x7F,0xFF,0x07,0xFF,0xFE,0x00,0x07,0xE0,0x00,0x00,
- 0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x0F,0xFF,0xE7,0xFF,0xFE,0x00,
- 0x07,0xC0,0x00,0x00,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x01,0xFF,
- 0xFF,0xFF,0xFE,0x00,0x0F,0xC0,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x3E,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x00,0x0F,0x80,0x00,0x00,0x07,0xC0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x0F,0xFF,0xFF,0x9E,0x00,0x0F,0x80,0x00,0x00,
- 0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x01,0xFF,0xFF,0x82,0x00,
- 0x0F,0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,
- 0x3F,0xFF,0xC0,0x00,0x1F,0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x1F,0x00,0x00,0x00,0x0F,0xFF,0xF0,0x00,0x0F,0x00,0x00,0x00,0x07,0xC0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x1F,0x80,0x00,0x00,0x1F,0xFF,0xFE,0x00,0x0F,0x80,0x00,0x00,
- 0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xC0,0x00,0x00,0x3F,0xFF,0xFE,0x00,
- 0x0F,0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x00,
- 0x7F,0xFB,0xFE,0x00,0x0F,0x80,0x00,0x00,0x07,0xC0,0x03,0xFF,0xC0,0x00,0x00,0x00,
- 0x07,0xF8,0x00,0x01,0xFE,0xFF,0xFE,0x00,0x07,0x80,0x00,0x00,0x07,0x80,0x1F,0xFF,
- 0xF8,0x00,0x00,0x00,0x03,0xFE,0x00,0x07,0xFC,0xFF,0xFE,0x00,0x07,0xC0,0x00,0x00,
- 0x0F,0x80,0x3F,0xFF,0xFC,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xF8,0xFF,0xFE,0x00,
- 0x07,0xE0,0x00,0x00,0x1F,0x80,0x7F,0xFF,0xFE,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,
- 0xF0,0xFF,0xFE,0x00,0x07,0xE0,0x00,0x00,0x1F,0x80,0xFF,0xFF,0xFF,0x00,0x00,0x00,
- 0x00,0x3F,0xFF,0xFF,0xC0,0xFF,0xFE,0x00,0x03,0xF0,0x00,0x00,0x3F,0x01,0xFE,0x00,
- 0x7F,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x01,0xF8,0x00,0x00,
- 0x7E,0x01,0xF8,0x00,0x1F,0x00,0x00,0x00,0x00,0x03,0xFF,0xF8,0x00,0xFF,0xFF,0x00,
- 0x01,0xFC,0x00,0x00,0xFE,0x01,0xF0,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x7F,0xFF,0x80,0x00,0xFF,0x00,0x03,0xFC,0x01,0xF0,0x00,0x0F,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x7F,0xC0,0x07,0xF8,0x01,0xF8,0x00,
- 0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x3F,0xFF,0xFF,
- 0xF0,0x01,0xFE,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
- 0x00,0x1F,0xFF,0xFF,0xE0,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x7F,0xFF,0xE0,0x00,0x07,0xFF,0xFF,0x80,0x00,0x7F,0xFF,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xF0,0x00,0x03,0xFF,0xFF,0x00,0x00,0x3F,0xFF,
- 0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xF8,0x00,0x00,0x7F,0xF0,
- 0x00,0x00,0x1F,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xF8,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x7F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFC,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFC,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x00,0x30,0x00,0x30,0xC1,0x80,0x20,0x30,
- 0x00,0x21,0x80,0x00,0x0C,0xC0,0x00,0x00,0x00,0x00,0x40,0x30,0x00,0x30,0x00,0x38,
- 0xC9,0x80,0x33,0xFF,0x06,0x31,0x80,0x00,0x0D,0xC0,0x00,0x00,0x00,0x01,0xFC,0x30,
- 0x07,0xFF,0x00,0x06,0xC9,0x80,0x63,0xFE,0x03,0x89,0xF8,0x0F,0xCE,0x00,0x00,0x00,
- 0x00,0x01,0xFB,0xF8,0x07,0xB0,0x00,0x00,0xC9,0x80,0x88,0x40,0x00,0x7E,0x80,0x18,
- 0xDF,0xE0,0x00,0x00,0x00,0x01,0x8F,0x3E,0x00,0x30,0x00,0xF8,0xC9,0x81,0xFB,0xF0,
- 0x08,0x35,0xF8,0x0C,0xBE,0x00,0x00,0x00,0x00,0x01,0xF9,0x30,0x3F,0xFF,0xF8,0xC8,
- 0xC9,0x81,0x25,0xB0,0x0F,0x3C,0x70,0x0F,0xAC,0xC0,0x00,0x00,0x00,0x07,0xF9,0xB0,
- 0x3C,0x33,0xF8,0x08,0xC9,0x80,0xCB,0xFE,0x00,0x24,0x60,0x03,0x8D,0x80,0x00,0x00,
- 0x00,0x07,0xB8,0xB0,0x02,0x31,0x30,0x18,0xC9,0x81,0xF3,0x30,0x00,0x6F,0xFE,0x03,
- 0x87,0x80,0x00,0x00,0x00,0x00,0xE8,0x30,0x02,0x30,0x80,0x1E,0xC9,0x80,0x01,0xB4,
- 0x07,0x48,0x20,0x0E,0x47,0x00,0x00,0x00,0x00,0x03,0x88,0x30,0x06,0x30,0x80,0x1D,
- 0xC9,0x80,0xFB,0xB3,0x0E,0xC8,0x20,0x3C,0x1F,0x80,0x00,0x00,0x00,0x0F,0x58,0x70,
- 0x07,0xFF,0x80,0x3B,0x89,0x83,0xC6,0x31,0xC1,0x98,0x60,0x10,0xFB,0xF8,0x00,0x00,
- 0x00,0x00,0x79,0xE0,0x07,0xFF,0xC0,0x37,0x09,0x82,0x19,0xF1,0x82,0x77,0xE0,0x00,
- 0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xE0,
- 0x00,0x00,0xC0,0x00,0x00,0x20,0x00,0x00
- };
- //枪支绘制//
- uchar code Gun_Image[]=
- {24,12,
- 0x03,0x00,0x00,0x07,0x80,0x00,0x07,0x80,0x00,0x7F,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
- 0xFE,0xFC,0x7F,0xFE,0xFC,0x00,0x01,0xFC,0x00,0x01,0xFC,0x00,0x00,0x7F,0x00,0x00,
- 0x7F,0x00,0x00,0x1F
- };
- uchar tCount =0;
- uchar HCount,LCount;
- uchar Score =0; Bullet_Count = 20;
- uchar Target_x=0,Target_y=0;
- uchar Pre_Target_y = 0;
- uchar gun_y = 20;
- void delay(uint ms)
- {
- uchar i;
- while (--ms)for(i=0;i<120;i++);
- }
- void EX_INT0() interrupt 0
- {
- if(K1==0)
- {
- if(gun_y !=0)Display_Str_at_xy(16*8,gun_y," ",0);
- gun_y -=8;
- if(gun_y < 20)gun_y = 20;
- Draw_Image(Gun_Image,gun_y,16);
- }
- else
- if(K2==0)
- {
- if(gun_y !=0) Display_Str_at_xy(16*8,gun_y," ",0);
- gun_y +=8;
- if(gun_y>100) gun_y = 100;
- Draw_Image(Gun_Image,gun_y,16);
- }
- else
- if(K3==0)
- {
- if(Bullet_Count !=0) TR1=1;else return;
- //弹道绘制//
- Line(10, gun_y +4,125,gun_y +4,1);
- delay(150);
- Line(10, gun_y +4,125,gun_y +4,0);
- if(Bullet_Count !=0)
- {
- Bullet_Count--;
- if((gun_y +4) >Target_y && (gun_y +4)<Target_y +11 &&Pre_Target_y !=Target_y)
- {
- Score++; Pre_Target_y = Target_y;
- }
- }
- Show_Score_and_Bullet();
- }
- else
- if(K4==0)
- {
- Score = 0;Bullet_Count = 20;
- Show_Score_and_Bullet();
- }
- }
- void T0_INT() interrupt 1
- {
- TH0 = -50000/256;
- TL0 = -50000%256;
- if(++tCount !=70) return;
- tCount = 0;
- if(Target_x!=0 && Target_y!=0)
- Display_Str_at_xy(Target_x,Target_y," ",0);
- Target_x = rand() %60 +8;
- Target_y = rand() %80+20;
- while ( abs(Pre_Target_y - Target_y )< 4) Target_y =rand() % 80 + 20;
- Display_Str_at_xy(Target_x,Target_y,"■",0);
- }
- void T1_INT () interrupt 3
- {
- BEEP = ~BEEP;
- if(LCount !=0 )
- {
- TH1 =HCount;TL1 = --LCount;
- }
- else
- if(--HCount !=0xFB)
- {
- TH1 = HCount;TL1 = --LCount;
- }
- else
- {
- TH1 = HCount = -420 / 256;
- TL1 = LCount = -420 % 256;
- BEEP = 1;
- TR1 = 0;
- }
- }
- void Show_Score_and_Bullet()reentrant
- {
- char dat_str[4] = {' ',0,0,0};
- dat_str[1] = Score / 10+ '0';
- dat_str[2] = Score % 10+ '0';
- Display_Str_at_xy(37,117,dat_str,1);
- dat_str[1] = Bullet_Count / 10+ '0';
- dat_str[2] = Bullet_Count % 10+ '0';
- Display_Str_at_xy(134,117,dat_str,1);
- }
- void main()
- {
- RESET=0;
- RESET=1;
- LCD_Initialise();
- cls();
- Set_LCD_POS(0,0);
- //显示游戏封面//
- Draw_Image(Game_Surface,6,0);
- delay(5000);
- cls();
- Display_Str_at_xy(12,1,"★★ 射击训练游戏 ★★",1);
- Display_Str_at_xy(2,117,"得分",0);
- Display_Str_at_xy(75,117,"剩余弹药:",0);
- Show_Score_and_Bullet();
- Line (0,18,159,18,1);
- Line (159,18,159,112,1);
- Line (159,112,0,112,1);
- Line (0,112,0,18,1);
- Draw_Image(Gun_Image,gun_y,16);
- IE = 0x8B;
- IP = 0x01;
- IT0 = 0x01;
- TMOD = 0x11;
- TH0 = -50000/256;
- TL0 = -50000%256;
- TH1 = HCount = -420/256;
- TL1 = LCount = -420%256;
- TR0 = 1;
- while (1);
- }
复制代码
单片机模拟射击游戏所有资料打包下载:
SM160128液晶设计游戏仿真.zip
(123.56 KB, 下载次数: 115)
|