c8656
2010-06-28 23:49:00
猜按键游戏
希望认识到更多爱好编程的人
放出源代码
#include
#include
#include
#include
#include
#include
#include
#include
/*
enum {
1,8,16,32,64,128,256,512,4096,8192,16384,32768
}ctrlJeux;
*/
PSP_MODULE_INFO("Jeux de Radom",0,1,1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
void dump_threadstatus(void);
int done = 0;
int exit_callback(int arg1,int arg2,void *comme) {
done = 1;
return 0;
}
int CallbackThread(SceSize args,void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit callback",exit_callback,NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("updata_thread",CallbackThread,0x11,0xFA0,0,0);
if(thid>=0) {
sceKernelStartThread(thid,0,0);
}
return thid;
}
int main() {
SceCtrlData pad;
//对应的键位值
int ctrlJeux[12] = {1,8,16,32,64,128,256,512,4096,8192,16384,32768};
int vitesse;
pspDebugScreenInit();
SetupCallbacks();
srand((unsigned)time(NULL));
int i;
int random;
i = rand()%12;
random=ctrlJeux[i];
//随机数
while(1) {
//pspDebugScreenClear();
//按start 键开始游戏
printf("Presse START pour commencer le jeux
");
pspDebugScreenClear();
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons & PSP_CTRL_START) {
printf("START!!!!!!!!!!!!!!!!!
");
break;
}
}
while(1) {
pspDebugScreenClear();
printf("Presse un button
");
sceCtrlReadBufferPositive(&pad,1);
printf("%d
",pad.Buttons);
if(pad.Buttons == random) {
printf("Tu ganer
");
break;
}
//pspDebugScreenClear();
for(vitesse=0;vitesse<5;vitesse++) {
sceDisplayWaitVblankStart();
}
}
sceKernelExitGame();
return 0;
}
makefile:
TARGET = CtrlJeux
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exception -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Ctrl Jeux
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
wz20084596
2010-06-29 02:25:25
哥 ~~我完全看不懂~~~
c8656
2010-06-29 04:49:01
我这个游戏是踩地雷,对应的每个psp的按键是每个位置,当你按下按键的时候,看一下是否踩中地雷,踩中了就退出游戏
掌叔
2010-06-29 07:27:43
不错~再接再厉哦:)
『兔寳貝』
2010-06-29 08:49:57
结果..呢?
a68537699
2010-06-29 12:36:47
支持一个
明日青蛙
2010-06-29 12:43:02
[i=s] 本帖最后由 明日青蛙 于 2010-6-29 12:44 编辑 [/i]
额~~~俺是来膜拜牛人的~~~
love_xiaolu
2010-06-29 16:36:49
嘻嘻,相当不错的说,加油……
qq6728149
2010-06-29 16:54:55
路过顶个
qq6728149
2010-06-29 16:55:42
话说现在下东西都要成就 成就哪来的啊
c8656
2010-06-29 18:51:52
[b]回复 [url=http://ons.yayabo.cn/redirect.php?goto=findpost&pid=49653&ptid=5286]4#[/url] [i]掌叔[/i] [/b]
谢谢啦
c8656
2010-06-29 18:52:54
呵呵,谢谢大家捧场
白枫
2010-06-29 19:36:55
俺是来膜拜牛人的!!
c8656
2010-06-30 16:03:18
我刚学点皮毛,希望以后能用psp控制机器人才是目标
感谢分享
2010-06-30 16:30:54
看不懂,不过还是支持了
LVAbyss
2010-07-29 23:53:41
支持 的我