当前位置: 首页>>代码示例>>C++>>正文


C++ Tetris类代码示例

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


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


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