- 易迪拓培训,专注于微波、射频、天线设计工程师的培养
LabWindows/CVI虚拟仪器设计技术场景与游戏设计之: 打字练习
(2)程序源代码
//头文件声明
#include <formatio.h>
#include "toolbox.h"
#include <cvirte.h>
#include <userint.h>
#include "打字练习.h"
static int panelHandle;
//声明得分为全局静态变量
static int score;
//声明自定义初始化函数
int InitChar (int choice);
//主函数
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return –1;
if ((panelHandle = LoadPanel (0, " 打字练习.uir", PANEL)) < 0)
return –1;
//初始化要显示的下落字符
InitChar (0);
InitChar (1);
//设置下落字符背景透明
SetCtrlAttribute (panelHandle, PANEL_TEXTMSG, ATTR_TEXT_BGCOLOR, VAL_TRANSPARENT);
SetCtrlAttribute (panelHandle, PANEL_TEXTMSG_1, ATTR_TEXT_BGCOLOR, VAL_TRANSPARENT);
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
//面板回调函数
int CVICALLBACK PanleCB (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
char str[2];
switch (event)
{
//响应键盘事件
case EVENT_KEYPRESS:
str[0] = '