資源簡介
opengl 簡單記憶翻牌游戲 四乘四

代碼片段和文件信息
#include?“afx.h“
#include?
#include?
#include?
#include?
#include?
#include
#include
#include?“base.h“
#include?“ball.h“
#include?“block.h“
#include?“blocks.h“
#include?“border.h“
#include?“stick.h“
using?namespace?std;
//?邊框參數設置
float?Border_Left=-0.8???Border_Right=0.8;
float?Border_Bottom=-0.8?Border_Top=0.8;
vector?selected;????//選中的磚的下標號
int?num=0;//選中的塊的次數,初始為0;
//?磚塊參數設置
int?Block_Row=4Block_Col=4;?//?行數、列數
float?Blocks_Area_Scale=1;?//?磚塊區占整個游戲區域的比例
//?邊框對象
BORDER?Border(Border_LeftBorder_RightBorder_TopBorder_Bottom);
//?磚塊群對象
BLOCKS?Blocks(BorderBlocks_Area_ScaleBlock_RowBlock_Col);?
void?myDisplay(void);
void?myMouse(int?buttonint?stateint?xint?y);
void?ToString(unsigned?int?vchar?s[]);
int?main(int?argc?char*?argv[])
{
??selected.clear();
??glutInit(&argc?argv);
??glutInitDisplayMode(GLUT_DOUBLE);
??glutInitWindowSize(800?800);
??glutInitWindowPosition(100?100);
??glutCreateWindow(“記憶翻牌游戲“);
??glutDisplayFunc(myDisplay);
??glutMouseFunc(myMouse);
??glutMainLoop();
??return?0;
}
void?myDisplay(void)
{?glClear(GL_COLOR_BUFFER_BIT?|?GL_DEPTH_BUFFER_BIT);
??Blocks.Draw();
??glutSwapBuffers();
}
void?myMouse(int?buttonint?stateint?xint?y)
{???
?????
????
????
if(state==GLUT_DOWN&&button==GLUT_LEFT_BUTTON)
{??????
?glutPostRedisplay();
?????cout<<1< ?GLint?viewport[4];?
?????GLdouble?modelview[16];?
?????GLdouble?projection[16];?
?????GLfloat?winx?winy?winz;?
?????GLdouble?posx?posy?posz;
?????glGetIntegerv(GL_VIEWPORT?viewport);?
?????glGetDoublev(GL_MODELVIEW_MATRIX?modelview);?
?????glGetDoublev(GL_PROJECTION_MATRIX?projection);?
?????winx?=?x;?
?????winy?=?viewport[3]?-?y;
?????glReadPixels(x?int(winy)?11?GL_DEPTH_COMPONENT?GL_FLOAT?&winz?);?
?????gluUnProject(?winx?winy?winz?modelview?projectionviewport?&posx?&posy?&posz);
?????????
???int?pindex=Blocks.getpblock(posxposy);???//獲得單擊所得的base的下標號
???if(pindex==-1)?return;?//沒選中塊則返回
???
???????????if(!Blocks.Exist(pindex))?
???{
???return;
???}?//如果選中的塊是已經被消除了也返回
???????????
???num++;
???
???????????if(num==1)??
???{
???selected.push_back(pindex);
???Blocks.setsel(pindex);???????????//如果只選中了一個塊,則將當前選中的base的顏色顯示出來
???}
???
???if(num==2)???????????????????????????//已經選中了兩個
???{???
??????int??index1=selected.at(0);
??????????if(index1==pindex)???????????????????//如果兩次選中的是同一個塊,則恢復該塊的selected為false
??{
????????????Blocks.setunsel(index1);
????????????selected.clear();
????????????num=0;
??}
???????????else
???{
?????if(Blocks.colorsame(index1pindex))???????//兩個顏色相同
?{
????????????????????????Blocks.setbaseEx(index1);
????????Blocks.setbaseEx(pindex);
????????num=0;
????????selected.clear();
?}
????????????????????
??????else
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????905??2014-04-12?22:42??簡易翻牌游戲\ball.h
?????文件???????5291??2014-04-23?21:41??簡易翻牌游戲\ba
?????文件????????491??2007-08-03?14:56??簡易翻牌游戲\block.h
?????文件???????2342??2014-04-23?21:43??簡易翻牌游戲\blocks.h
?????文件????????221??2007-08-03?14:56??簡易翻牌游戲\border.h
?????文件????1920056??2011-06-06?21:12??簡易翻牌游戲\data\test.bmp
?????文件????1745920??2014-04-23?21:50??簡易翻牌游戲\Debug\gl.bsc
?????文件?????135239??2014-04-23?21:50??簡易翻牌游戲\Debug\gl.exe
?????文件?????255680??2014-04-23?21:50??簡易翻牌游戲\Debug\gl.ilk
?????文件?????102464??2014-04-23?21:50??簡易翻牌游戲\Debug\gl.obj
?????文件????6090176??2014-04-23?21:43??簡易翻牌游戲\Debug\gl.pch
?????文件?????476160??2014-04-23?21:50??簡易翻牌游戲\Debug\gl.pdb
?????文件??????????0??2014-04-23?21:50??簡易翻牌游戲\Debug\gl.sbr
?????文件?????173056??2014-04-23?21:50??簡易翻牌游戲\Debug\vc60.idb
?????文件?????151552??2014-04-23?21:50??簡易翻牌游戲\Debug\vc60.pdb
?????文件???????3482??2014-04-23?21:49??簡易翻牌游戲\gl.cpp
?????文件???????3428??2014-04-23?21:49??簡易翻牌游戲\gl.dsp
?????文件????????529??2007-08-02?14:24??簡易翻牌游戲\gl.dsw
?????文件??????91136??2014-04-23?21:50??簡易翻牌游戲\gl.ncb
?????文件??????49664??2014-04-23?21:50??簡易翻牌游戲\gl.opt
?????文件????????998??2014-04-23?21:50??簡易翻牌游戲\gl.plg
?????文件????????869??2014-04-09?23:21??簡易翻牌游戲\gl.sln
????..A..H.??????9216??2014-04-09?23:21??簡易翻牌游戲\gl.suo
?????文件???????5159??2014-04-09?23:21??簡易翻牌游戲\gl.vcproj
?????文件???????1427??2014-04-09?23:21??簡易翻牌游戲\gl.vcproj.5SLWJHCZF6ZKCKP.Administrator.user
?????文件???????1392??2007-08-03?14:48??簡易翻牌游戲\stick.h
?????目錄??????????0??2014-04-23?12:37??簡易翻牌游戲\data
?????目錄??????????0??2014-04-23?21:50??簡易翻牌游戲\Debug
?????目錄??????????0??2014-04-23?21:50??簡易翻牌游戲
-----------?---------??----------?-----??----
............此處省略2個文件信息
- 上一篇:校園新聞發布管理系統
- 下一篇:HFSS中文教程_微波仿真論壇
評論
共有 條評論