天地之灵学习小组
我们学习小组的OpenGL学习笔记 大家一定要互相折磨呀~~
posts - 150,  comments - 156,  trackbacks - 0
以前从没写过游戏,甚至连大程序都没尝试写过,这一次可谓要突破一下了。昨天晚上一夜都没睡好,一直都在想着这个游戏。参考了一下俄罗斯方块,罗列了一些函数,由于能力有限函数的具体功能都没实现,但是我会尽快补全这些功能的,请大家监督。第一次分析的难免会有很多漏洞与不全,请大家多多指教。
首先是导入各函数库
#include 
<.h>
各个全局变量
Static 
const int Bottle_width                瓶子的宽和高度
Static 
const int Bottle_height
Static 
const int Pill_Szie                     药丸的尺寸
Static 
const int bug_rate                   虫子的几率
static const int  WindowPositionX         窗口位置
static const int  WindowPositionY 



定义枚举类型的颜色
Enmu color
{………};
定义瓶子网格的类型
enmu BottleGridType 
{
    BGT_EMPTY,        
//空的
    BGT_BUG,          //虫子
    BGT,MEDICINE      //药片
}
;

定义瓶子类
class Bottle
{
private :
    BottleGrifTYpe 
**b_ptr;
    
int b_Width;
    
int b_Height;
public:
      Bottle(
int width,int height,intbug_rate)
      
{
           B_Width
=width;
           B_Height
=height;
           b_ptr
=new BottleGridTYpe*[height];
           
for(int i=0;i<k;i++)
           
{
               For(
int j=0;j<width;j++)
               
{
                   对从第0行到第k行进行初始化,                 全  部设置成空的,即不包含虫子。K                 根据关数自定义
                  }

           }

           For(
int i=k;i<height;i++)
           
{
              
for(int j=0;j<width;j++)
                
if(bug_rate>0)
                
{
                   如果虫子出现的几率
>0则根据rate              设置某些网格成虫子
                  }

                Else
                
{
                   设置网格为空
                   }

            }

       }

       
~Bottle()                   析构函数
        
{
             
for(int i=0; i<m_Height; ++i)
                  delete[] b_ptr[i];
             delete[] b_ptr;
       }

       Void display()
        
{
          For(
int i=0;i<b_Width;i++)
              
{
          For(
int j=0;j<b_Height;j++)
                    Switch(b_ptr[j][i] )
                    
{
                    Case BGT_EMPTY:
                                    
{
    
                                     }

                        Case BGT_BUG:
                                    
{
    
                                     }

                         Case BGT_EMPTY:
                                    
{
    
                                     }

                      }

                   }

              }

          }

}
定义Medicine 类型
enmu Medicine
{
    
char c[2][2];
    
int x;
    
int y;
    
char color;
    
char size;
    
char name;
}

drawBug()
{
    画虫子
}

drawMedicine()
{
    画药片
}

canRotate(Medicine mc)
{
    判断药片是否可以旋转
    Can
        Return  
true;
    Not 
        Return 
false;
}

Int canMove(Medicine mc)
{
    判断药片是否可以向左右移动
    If(can move to left )
        Return  
1;
    If(can move to right)
        Return 
2
}

Void display()           显示函数,
{
    glClear(GL_COLOR_BUFFER_BIT);
    (Bottle)
->display();          //Bottle的一个对象
    glutSwapBuffers();
}

Void clearMedicineAndBug()
{
    如果垂直或水平相邻颜色的虫子或药丸大于或等于四个,消除。。。。
}

Void keyboard(unsigned 
char key,int x,int y)
{
    Switch(key)
{
    Case ‘a’:
    Case ‘A’:
        If(canMove(Mecidine mc)
==1 )
                药片向左移动
            Break;
        Case ‘d’:
        Case ‘D’:
        If(canMove(Mecidine mc)
==2 )
            药片向右移动
        Break;
        Case ‘s’:
        Case ‘S’:
        药片加速下移
        Break;
        Case ‘w’:
        Case ‘W’:
        If(canRotate(Mecidine mc))
            药片旋转
        Break;
        Case ‘p’:
        Case ‘P’:
        暂停,按任意键继续
        Break;
    }

}

Void init()
{
     glClearColor(,        ,    ,    ,);
     。
     。
     。
}

Int main(
int argc,char*argv[])
{
    初始化一个瓶子
    
       glutInit(
&argc,argv);
      glutInitDisplayMode(GLUT_
|GLUT_);
      glutInitInitWindowSize();
      glutInitWindowPosition();
      glutCreateWindow(argv);
      init();
      glutDisplayFunc(display);
      glutMainLoop();
      
return 0;
}



FeedBack:
# re: 10月18日_关于玛丽医生的部分函数(现在就想到这一点,至于功能还不会实现,我会慢慢写全的)_By risky
2008-10-18 21:08 | 肖赫_王婷婷_王冠_郑燚_孙婷
risky,你不会是在用word在写程序吧……怎么连int main都搞成大写了……  回复  更多评论
  
# re: 10月18日_关于玛丽医生的部分函数(现在就想到这一点,至于功能还不会实现,我会慢慢写全的)_By risky
2008-10-18 21:17 | 肖赫_王婷婷_王冠_郑燚_孙婷
我举报我举报,他确实开Word了。。  回复  更多评论
  
# re: 10月18日_关于玛丽医生的部分函数(现在就想到这一点,至于功能还不会实现,我会慢慢写全的)_By risky
2008-10-18 21:40 | 肖赫_王婷婷_王冠_郑燚_孙婷
恭喜你猜对了,本来是些个计划的,结果越写越像是伪代码。@肖赫_王婷婷_王冠_郑燚_孙婷
  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(6)

随笔分类(149)

随笔档案(150)

同道中人

搜索

  •  

积分与排名

  • 积分 - 43805
  • 排名 - 486

最新随笔

最新评论

阅读排行榜

评论排行榜