Skip to content

Instantly share code, notes, and snippets.

@hydai
Created April 23, 2014 16:21
Show Gist options
  • Save hydai/11222107 to your computer and use it in GitHub Desktop.
Save hydai/11222107 to your computer and use it in GitHub Desktop.
//
// main.cpp
// smallgame
//
// Created by Apple on 2014/4/21.
// Copyright (c) 2014年 Apple. All rights reserved.
//
#include<cstdio>
#include<cstdlib>
#include"GLHeader.h"
int arr[4][4]={0};
void Keydown(unsigned char key, int x, int y)
{
switch(key)
{
case 27:
exit(0);
break;
}
glutPostRedisplay();
return;
}
void Display(){
ClearScreen();
for(float i=0;i<2;i=i+1){
for (int j=0;j<4;j=j+1){
DrawText("0",arr[i][j],arr[i][j],1,0,0);
}
}
while(1){
arr[x][y]=[(rand()%2)+1]x2;
break;
}
char ch[3];
double x=0,y=0;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
sprintf(ch,"%d",a[i][j]);
DrawText(ch,x,y,0,0,0);
x+=0.2;
}
y+=0.2;
}
}
Update();
}
// Must use "int main(int argc, char*argv[])"
// You should put "glutInit(&argc, argv);",
// before trying to use any glut function.
int main(int argc, char*argv[])
{
glutInit(&argc, argv);
InitialGame(600,600,"2048");
glutDisplayFunc(Display);
glutKeyboardFunc(KeyDown);
MainLoop();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment