• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Tetris类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Tetris的典型用法代码示例。如果您正苦于以下问题:C++ Tetris类的具体用法?C++ Tetris怎么用?C++ Tetris使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Tetris类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1:

int
Tetris::gameAbout(GtkAction *action, void *d)
{
	Tetris *t = (Tetris*) d;

	const gchar * const authors[] = { "Gnome Games Team", NULL };

	const gchar * const documenters[] = { "Angela Boyle", NULL };

	gchar *license = games_get_license (_("Gnometris"));

	gtk_show_about_dialog (GTK_WINDOW (t->getWidget()),
#if GTK_CHECK_VERSION (2, 11, 0)
			       "program-name", _("Gnometris"),
#else
			       "name", _("Gnometris"),
#endif
			       "version", VERSION,
			       "comments", _("A classic game of fitting falling blocks together.\n\nGnometris is a part of GNOME Games."),
			       "copyright", "Copyright \xc2\xa9 1999 J. Marcin Gorycki, 2000-2008 Others",
			       "license", license,
			       "website-label", _("GNOME Games web site"),
			       "authors", authors,
			       "documenters", documenters,
			       "translator-credits", _("translator-credits"),
			       "logo-icon-name", "gnome-gnometris",
			       "website", "http://www.gnome.org/projects/gnome-games/",
			       "wrap-license", TRUE,
			       NULL);
	g_free (license);

	return TRUE;
}
开发者ID:chenxiaolong,项目名称:gnometris,代码行数:33,代码来源:tetris.cpp


示例2: main

/////////////////////////////////////////////////
/// \brief Main function of the program.
///
/// Create a Tetris instance and run the game.
///
/// \param argc : Number of given command-line parameters.
/// \param argv : Command-line parameters.
/// \return Program ending status code.
/////////////////////////////////////////////////
int main(int argc, char* argv[])
{
    Tetris tetris;

    tetris.run();

    return EXIT_SUCCESS;
}
开发者ID:TheFakeCake,项目名称:Tetris-Clone,代码行数:17,代码来源:main.cpp


示例3: srand

bool MyApp::OnInit()
{
    srand(time(NULL));
    Tetris *tetris = new Tetris(wxT("Tetris"));
    tetris->Centre();
    tetris->Show(true);

    return true;
}
开发者ID:imousewyfzml,项目名称:mylibrary,代码行数:9,代码来源:main.cpp


示例4: main

int main(int argc, char **argv) {
  try {
    Tetris game;
    game.run();
    return 0;
  }
  catch(const std::exception &exc) {
    std::cerr << exc.what() << std::endl;
  }
}
开发者ID:BlaiseRitchie,项目名称:WeirdTetris,代码行数:10,代码来源:main.cpp


示例5: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTranslator translator;
    translator.load("tetris_ru.qm", ".");
    a.installTranslator(&translator);
    Tetris w;
    w.show();
    return a.exec();
}
开发者ID:Dilaere,项目名称:Tetris,代码行数:10,代码来源:main.cpp


示例6: main

int main(){
	Tetris game;
	event_handle event_hdl;
	game.StartTetris(79, 52); // creates the enviroment
	unsigned long int Event;
	while(true){
		Sleep(10); // sleep added, to increase performance
		Event = event_hdl.getEvent(); // gets any buttons pressed and the windows focus
		if(!game.RunTetris(Event)) break; // everything else
	}
	return 0;
}
开发者ID:Darkov3,项目名称:CV,代码行数:12,代码来源:main.cpp


示例7: main

int main(int argc, char *argv[]) {
  ALLEGRO_DISPLAY *display;
  unsigned int ticks = 0;

  if (!al_init()) {
    std::cerr << "[ERROR] Error initializing Allegro" << std::endl;
  }

  display = al_create_display(SCREEN_WIDTH, SCREEN_HEIGHT);

  if (!display) {
    std::cerr << "[ERROR] Error creating Allegro display" << std::endl;
  }

  al_install_audio();
  al_install_keyboard();

  al_init_primitives_addon();
  al_init_acodec_addon();
  al_init_font_addon();
  al_init_ttf_addon();
  al_init_image_addon();

  al_reserve_samples(10);

  srand(time(NULL));

  ALLEGRO_TIMER *timer = al_create_timer(1.0 / FPS);
  ALLEGRO_EVENT_QUEUE *timerQueue = al_create_event_queue();
  al_register_event_source(timerQueue, al_get_timer_event_source(timer));

  al_start_timer(timer);

  Tetris *game = new Tetris(SCREEN_WIDTH, SCREEN_HEIGHT, timerQueue);

  while (game->update(ticks)) {
    game->render();

    ++ticks;
  }

  delete game;

  al_destroy_display(display);
  al_destroy_timer(timer);
  al_destroy_event_queue(timerQueue);

  return 0;
}
开发者ID:jsvana,项目名称:gamejam,代码行数:49,代码来源:main.cpp


示例8: rightMove

void Interface::rightMove()
{
	Tetris copy = ArrayTe[rear];
	copy.right_move(20);
	bool canMove = true;
	for (int i = 0; i < 4; i++)
	{
		if (sc[copy.trans_to_yindex(i)][copy.trans_to_xindex(i)]){
			canMove = false;
			break;
		}
	}
	if (canMove)
		ArrayTe[rear].right_move(20);
}
开发者ID:happylrd,项目名称:game-tetris,代码行数:15,代码来源:interface.cpp


示例9: main

int main( int argc, char** argv )
{
    (void)argc;
    (void)argv;

    try{
        Tetris tetris;
        tetris.run();
    }catch( std::exception& ex ){
        std::cerr << ex.what() << std::endl;
        return 1;
    }

	return 0;
}
开发者ID:moisesjbc,项目名称:moblok,代码行数:15,代码来源:main.cpp


示例10: main

int main(int argc, char* argv[]){
	

	try {
		setWorkdir();
		
		Tetris tetris;
		tetris.play();
	}
	catch (TetrisException& e) {
		std::cerr << "Tetris exception occured:\n" << e.what();
	}
	catch (std::exception& e){
		std::cerr << "Standard exception occured: \n" << e.what();
	}
}
开发者ID:KarolStola,项目名称:Tetris,代码行数:16,代码来源:main.cpp


示例11: main

int main (void) {
	cout << "Genetic Algorithm Tetris version 0.1" << endl;

	// The pieces that will allow us to play some tetris
	Tetris tetris;
	Controller controller;
	Display_Manager output;

	// Connect the pieces
	//tetris.input = controller;
	//output.feed = tetris.state;

	// Let it rip!
	tetris.run ();

	return 0;
}
开发者ID:abhinavchanda,项目名称:gen-alg-tetris,代码行数:17,代码来源:main.cpp


示例12: main

int main()
{
	const int FRAMES_PER_SECOND = 25;
    const int SKIP_TICKS = 1000 / FRAMES_PER_SECOND;
	const int MAX_FRAMESKIP = 10;

    unsigned long next_game_tick = GetTickCount();
	int loops = 0;

	Tetris game;
	printf("Game initializing\n");
	game.init();
	
	printf("Game initialized\n");
	View view;
	view.init(game);

    //int sleep_time = 0;
	int quit = 0;

    bool game_is_running = true;
    while( game_is_running ) 
	{
		while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) 
		{
			quit = view.getInput();
			next_game_tick += SKIP_TICKS;
			loops++;
		}
		if(quit == 1)
		{
			game.pause();
			quit = 0;
		}
		else if(quit == 2)
		{
			game_is_running = false;
			quit = 0;
		}
		game.update();
        view.update();
    }
	return 0;
}
开发者ID:Royce37,项目名称:OSTetris,代码行数:44,代码来源:main.cpp


示例13: display

void display(void)
{
	/* clear window */
	glClear(GL_COLOR_BUFFER_BIT); 

	/* draw unit square polygon */

	tetris.displayTetris();
	/* flush GL buffers */
	glFlush(); 
}
开发者ID:atw80,项目名称:tetris,代码行数:11,代码来源:main.cpp


示例14: main

int main(int argc, char** argv)
{

	std::string ipAddress("");
	if (argc > 1)
	{
		if (stricmp(argv[1], "--server") == 0)
		{
			g_networkPtr = new TetrisServer();
		}
		else
		{
			ipAddress = argv[1];
			g_networkPtr = new TetrisClient(ipAddress);
		}
	}

	if (g_networkPtr != NULL)
	{
		if (!g_networkPtr->Init())
		{
			delete g_networkPtr;
			g_networkPtr = NULL;
		}
	}

	sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "SFML TETRIS");
	
	sf::View playerView;
	GameManager gameMgr;
	Tetris* localGame = new Tetris();
	localGame->Init();
	gameMgr.AddGame(localGame, sf::FloatRect(.5, 0, 0.4, .4));

	Tetris* otherGame = new Tetris();
	otherGame->Init();
	gameMgr.AddGame(otherGame, sf::FloatRect(0.5, 0.5, .4, 0.4));
	
	
	sf::Clock clock;

	while (window.isOpen() && gameMgr.IsRunning())
	{
		if (g_networkPtr != NULL)
		{
			g_networkPtr->Loop();
		}

		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
				window.close();
		}
		
		sf::Time time = clock.restart();
		gameMgr.Update(&window, time.asSeconds());
				
		//window.setView(window.getDefaultView());
		//window.clear(sf::Color(40, 40, 40));
		//game.Draw(&window);
		
		window.display();
	}

	if (g_networkPtr != NULL)
	{
		delete g_networkPtr;
		g_networkPtr = NULL;
	}
	return 0;
}
开发者ID:vampvarg,项目名称:SFMLTetris,代码行数:72,代码来源:Main.cpp


示例15: main

int main() {
	twi_init();
	srandom(0);

	//timer_init();
	
	DDRB = 0xff;
	PORTB = 0x00;

	uint16_t buttons;
	uint16_t changed;
	uint8_t selected = 0;
	
	matrix.setFont(font_3x5, codepage_ascii_caps, 3, 5);
	
	while (1) {
		psx.poll();
		buttons = psx.buttons();
		changed = psx.changed();
		if (buttons & PSB_SELECT && changed & PSB_SELECT) {
			selected++;
			selected %= 6;
		}
		else if (buttons & PSB_SQUARE && changed & PSB_SQUARE) {
			hsv.addHue(-30);
		}
		else if (buttons & PSB_CIRCLE && changed & PSB_CIRCLE) {
			hsv.addHue(30);
		}
		else if (buttons & PSB_PAD_DOWN && changed & PSB_PAD_DOWN) {
			uint8_t v = hsv.getValue();
			switch (v) {
				case 0xff: hsv.setValue(0x7f); break;
				case 0x7f: hsv.setValue(0x3f); break;
				case 0x3f: hsv.setValue(0x1f); break;
				case 0x1f: hsv.setValue(0x0f); break;
				case 0x0f: hsv.setValue(0x07); break;
				case 0x07: hsv.setValue(0x03); break;
				case 0x03: hsv.setValue(0x01); break;
				default: hsv.setValue(0x00);
			}
		}
		else if (buttons & PSB_PAD_UP && changed & PSB_PAD_UP) {
			uint8_t v = hsv.getValue();
			switch (v) {
				case 0x00: hsv.setValue(0x01); break;
				case 0x01: hsv.setValue(0x03); break;
				case 0x03: hsv.setValue(0x07); break;
				case 0x07: hsv.setValue(0x0f); break;
				case 0x0f: hsv.setValue(0x1f); break;
				case 0x1f: hsv.setValue(0x3f); break;
				case 0x3f: hsv.setValue(0x7f); break;
				default: hsv.setValue(0xff);
			}
		}
		else if (buttons & PSB_PAD_LEFT && changed & PSB_PAD_LEFT) {
			uint8_t s = hsv.getSaturation();
			switch (s) {
				case 0xff: hsv.setSaturation(0xfe); break;
				case 0xfe: hsv.setSaturation(0xfc); break;
				case 0xfc: hsv.setSaturation(0xf8); break;
				case 0xf8: hsv.setSaturation(0xf0); break;
				case 0xf0: hsv.setSaturation(0xe0); break;
				case 0xe0: hsv.setSaturation(0xc0); break;
				case 0xc0: hsv.setSaturation(0x80); break;
				default: hsv.setSaturation(0x00);
			}
		}
		else if (buttons & PSB_PAD_RIGHT && changed & PSB_PAD_RIGHT) {
			uint8_t s = hsv.getSaturation();
			switch (s) {
				case 0x00: hsv.setSaturation(0x80); break;
				case 0x80: hsv.setSaturation(0xc0); break;
				case 0xc0: hsv.setSaturation(0xe0); break;
				case 0xe0: hsv.setSaturation(0xf0); break;
				case 0xf0: hsv.setSaturation(0xf8); break;
				case 0xf8: hsv.setSaturation(0xfc); break;
				case 0xfc: hsv.setSaturation(0xfe); break;
				default: hsv.setSaturation(0xff);
			}
		}
		else if (buttons & PSB_START && changed & PSB_START) {
			switch (selected) {
				case 0: { Clock clk; clk.run(); break; }
				case 1: { AltClock alt; alt.run(); break; }
				case 2: { Life life; life.run(); break; }
				case 3: { Mood mood; mood.run(); break; }
				case 4: { Animated ani; ani.run(); break; }
				case 5: { Tictactoe ttt; ttt.run(); break; }
				case 6: { Tetris tet; tet.run(); break; }
			}
		}
		
		matrix.setColor(0,0,0);
		matrix.rectangle(0,0,11,11, DRAW_FILLED);
		matrix.setColor(Rgb(hsv));
		switch (selected) {
			case 0: matrix.text(0, 3, "CLK", DRAW_ORIENTATION_0); break;
			case 1: matrix.text(0, 3, "ALT", DRAW_ORIENTATION_0); break;
			case 2: matrix.text(0, 3, "LIF", DRAW_ORIENTATION_0); break;
//.........这里部分代码省略.........
开发者ID:imaculate,项目名称:microcontroller-projects,代码行数:101,代码来源:LedTable.cpp


示例16:

GameObject::GameObject(Tetris& tetris) :
    m_tetris(tetris),
    m_window(tetris.getWindow())
{}
开发者ID:TheFakeCake,项目名称:Tetris-Clone,代码行数:4,代码来源:GameObject.cpp


示例17: SDL_GetTicks

void Game::start(const int TICKS_PER_SECOND, const int MAX_FRAMESKIP) {

    bool quit = false;
    const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
    Uint32 next_tick = SDL_GetTicks();

	Uint32 fps_ticks = SDL_GetTicks();
	Uint32 fps = 0;
	SDL_Rect fpsRenderRect = { 10, 10, 50, 30 };
    SDL_Color fpsColor = {255, 255, 255, 255};

    int loops;
    float interpolation;
	Tetris tetris;
	tetris.init();
    SDL_Event e;
    
    GLuint MatrixID = glGetUniformLocation(_programID, "mvp");
    
    bool moveUp = false;
    bool moveDown = false;
    bool moveLeft = false;
    bool moveRight = false;
    float testValY = 0.0f;
    float testValX = 0.0f;
    bool projectionMod = false;
    float angle = 0.0f;
    float prevAngle = angle;
    
    glm::mat4 Projection = glm::perspective(glm::radians(90.0f), _screen.x / _screen.y, 0.1f, 100.0f);
    
    glm::mat4 View = glm::lookAt(
                                 glm::vec3(0, 0, 1),
                                 glm::vec3(0, 0, 0),
                                 glm::vec3(0, 1, 0)
                                 );
    
    glm::mat4 Translate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f));
    
    glm::mat4 Scale = glm::scale(glm::mat4(1.0f), glm::vec3(1.0));

    glm::mat4 Rotate = glm::rotate(glm::mat4(1.0f), 0.0f, glm::vec3(0.0f));
    
    glm::mat4 Model = glm::mat4(1.0f);
    
    glm::mat4 MVP = Projection * View * Model;

    while(!quit) {
        loops = 0;
        while (SDL_GetTicks() > next_tick && loops < MAX_FRAMESKIP) {

			if (SDL_GetTicks() > fps_ticks) {
				float fps_delta = (SDL_GetTicks() - fps_ticks) / 1000.0f;
				fps = Uint32(1.0 / fps_delta);
			}

            while(SDL_PollEvent(&e)) {
                if (e.type == SDL_QUIT) {
                    quit = true;
                }
                if (e.type == SDL_KEYDOWN) {
                    switch( e.key.keysym.sym ) {
                        case SDLK_UP:
                            moveUp = true;
                            break;
                        case SDLK_DOWN:
                            moveDown = true;
                            break;
                        case SDLK_LEFT:
                            moveLeft = true;
                            break;
                        case SDLK_RIGHT:
                            moveRight = true;
                            break;
                        case SDLK_RETURN:
                            projectionMod = !projectionMod;
                        default:
                            break;
                    }
                }
                if (e.type == SDL_KEYUP) {
                    switch( e.key.keysym.sym ) {
                        case SDLK_UP:
                            moveUp = false;
                            break;
                        case SDLK_DOWN:
                            moveDown = false;
                            break;
                        case SDLK_LEFT:
                            moveLeft = false;
                            break;
                        case SDLK_RIGHT:
                            moveRight = false;
                            break;
                        default:
                            break;
                    }
                }
				tetris.handleInput(e);
            }
//.........这里部分代码省略.........
开发者ID:SuperiorJT,项目名称:sdl-tetris,代码行数:101,代码来源:game.cpp


示例18: draw

void Interface::draw(Tetris next)
{
	int j;
	next.set_offset(270, 110); 
	setfillcolor(EGERGB(next.getR(), next.getG(), next.getB()));
	for (j = 0; j < 4; j++)
	{
		bar(next.getXCoord(j) - 10, next.getYCoord(j) - 10, next.getXCoord(j) + 10, next.getYCoord(j) + 10);
		setcolor(WHITE);
		rectangle(next.getXCoord(j) - 10, next.getYCoord(j) - 10, next.getXCoord(j) + 10, next.getYCoord(j) + 10);
	}
}
开发者ID:happylrd,项目名称:game-tetris,代码行数:12,代码来源:interface.cpp


示例19: GameOnSelect

void GameOnSelect( VariantList* pVList )
{
	Entity *pEntClicked = pVList->m_variant[1].GetEntity();

	Tetris* tetris = Tetris::GetInstance();
	Config* config = Config::GetInstance();

	if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_MENU_BUTTON )
	{
		GetApp()->buttonClickSound();

		if( tetris->isEndGame() )
		{
			SlideScreen( pEntClicked->GetParent(), false );
			GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
		
			GetApp()->setGame( false );
			GetApp()->setContinueBtn( false );

			if( tetris->getScoreInt() > config->getMinScore() )
			{
				GameState::SetState( new GS_Menu() );
				InputBestScoreCreate( pEntClicked->GetParent()->GetParent() );
			}
			else
			{
				tetris->ResetEndGame();

				GameState::SetState( new GS_Menu() );
				MainMenuCreate( pEntClicked->GetParent()->GetParent() );
			}
		
			tetris->FreeInstance();
			config->FreeInstance();

			return;
		}

		GameState::SetState( new GS_Menu() );

		if( config->getMusic() )
		{
			GetAudioManager()->StopMusic();
		}
		
		GetApp()->setGame( false );
		SlideScreen( pEntClicked->GetParent(), false );
		GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
		MainMenuCreate( pEntClicked->GetParent()->GetParent() );
	}

	if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_DOWN && !tetris->isEndGame() )
	{
		if( config->getSoundEffects() )
		{
			GetAudioManager()->Play( GetApp()->getResourceInstance()->getItem(GetApp()->getResolutionType(), RES_TYPE_AUDIO, RES_ID_AUDIO_FIGURE_DOWN ) );
		}
		tetris->ClickForceDown();
	}

	if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_LEFT && !tetris->isEndGame() )
	{
		buttonMoveSound();
		tetris->ClickLeft();
	}

	if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_RIGHT && !tetris->isEndGame() )
	{
		buttonMoveSound();
		tetris->ClickRight();
	}

	if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_ROTATE && !tetris->isEndGame() )
	{
		buttonMoveSound();
		tetris->ClickRotate();
	}

	tetris->FreeInstance();
	config->FreeInstance();
}
开发者ID:maximbilan,项目名称:tblock,代码行数:81,代码来源:GUI_Game.cpp


示例20: getOutput

void getOutput( OutputPack* opack )
{
	if ( tetris_output == NULL )
	{
		tetris_output = opack ;
	}

	// Clear screen
	if ( system("clear") )
	{
		system("cls");
	}
	
	// Print tetris
	printMatrix( opack->tetris , TT_NONE , ' ' );

	// Print time
	printf("Time : %f\n" , trt.getGameplayTime() );

	// Print erased lines
	if ( opack->didEraseLines )
	{
		printf("Deleted Rows : %d\n" , opack->numOfErasedLines );
	}
}
开发者ID:Tsopanoglou,项目名称:TGL,代码行数:25,代码来源:main.cpp



注:本文中的Tetris类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Teuchos类代码示例发布时间:2022-05-31
下一篇:
C++ TetrahedralMesh类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap