网站大量收购独家精品文档,联系QQ:2885784924

opengl实现推箱子游戏讲述.docx

  1. 1、本文档共19页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
共分为4个.h文件和5个.cpp文件 keyListener.h,keyListener.cpp map.h,map.cpp texture.h,texture.cpp textview.h,textview.cpp Main.cpp Main.cpp #include GL/glut.h #include GL/glu.h #include GL/gl.h #include string.h #include stdio.h #include map.h #include Texture.h #include keyListener.h #include textview.h #pragma comment(linker,/subsystem:\Windows\ /entry:\mainCRTStartup\) Texture texture; // 文理加载类 Map map; // 地图加载类 KeyListener keylistener; //键盘监听事件类 TextView textview; int* image; int **mp; int window; //窗口 int is_pass = 0; // 是否过关标志 int *pass = is_pass; int level = 1; // 关卡 int *lv = level; int pre_lv = 1; //颜色的RGB值 int black[3] = {0 , 0 , 0}; int white[3] = {255 , 255 , 255}; int orange[3] = {255, 128, 0}; //窗口大小变化时调用的函数 void ChangeSize(GLsizei w, GLsizei h) { if(h == 0) { h = 1; } glViewport(0, 0, w, h); //定义视口大小,宽高一致 int width = 550; int height = 550; glMatrixMode(GL_PROJECTION); //重置坐标系统,使投影变换复位 glLoadIdentity(); //将当前的用户坐标系的原点移到了屏幕中心 GLfloat aspect; if(w = h) { aspect = (GLfloat) h / w; glOrtho(0, width, 0, height * aspect, 0, height); } else if(w h) { aspect = (GLfloat) w / h; glOrtho(0, width * aspect, 0, height, 0, width); } } void display_text() { glColor3ub(orange[0],orange[1],orange[2]); glRasterPos2i(250, 570); //起始位置 textview.drawString(推箱子); //输出的字符串 glRasterPos2i(400, 570); char c[10] = 第; char d[5] ; sprintf(d, %d关, level); strcat(c, d); textview.drawString(c); glRasterPos2i(120, 80); textview.drawString(1、ESC键退出游戏); glRasterPos2i(120, 60); textview.drawString(2、BackSpace后退); glRasterPos2i(120, 40); textview.drawString(3、PageUp、PageDown切换关卡); glRasterPos2i(120, 20); textview.drawString(4、键盘上、下、左、右键控制方向); } //画长方形 void draw_rect(int leftX, int leftY) { glBegin(GL_POLYGON); glColor3ub(black[0],black[1],black[2]); glVertex2d(leftX,leftY);

文档评论(0)

jiayou10 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8133070117000003

1亿VIP精品文档

相关文档