Exemplo n.º 1
0
Arquivo: jump.c Projeto: Bediko/r0ket
void ram(void) {

	splash_scene();

	long frame_count = 0;
	init_game();

	while(1) {
		frame_count++;

		lcdFill(0);
		update_platforms(frame_count);
		move_player(frame_count);
		draw_platforms();
		draw_player();
		draw_hud();
		blink_led();
		lcdDisplay();

		if(!game.running) {
			if(!gameover_scene()){
                delayms_queue_plus(10,1);
				return;
            }
			init_game();
		}
        delayms_queue_plus(24,0);
	}
}
Exemplo n.º 2
0
void mouse(int button, int state, int x, int y)
{
// We convert windows mouse coords to out openGL coords
mouse_x =  (18 * (float) ((float)x/(float)Win_x))/6;
mouse_y =  (18 * (float) ((float)y/(float)Win_y))/6;

// What square have they clicked in?
object_select = mouse_x + mouse_y * 3;

if ( start_game == 0)
	{
    if ((button == GLUT_RIGHT_BUTTON) && (state == GLUT_DOWN))
      {
       player = 1;
	   computer = -1;
	   init_game();
	   return;
      }

    if ((button == GLUT_LEFT_BUTTON) && (state == GLUT_DOWN))
      {
	  player = -1;
      computer = 1;
	  init_game();
	  computer_move();
	  return;
      }
   }

if ( start_game == 1)
	{
    if ((button == GLUT_LEFT_BUTTON) && (state == GLUT_DOWN))
      {
      if (win == 0)
         {
         if (box_map[ object_select ] == 0)
            {
            box_map[ object_select ] = player;
	        win = check_move();
	        if (win == 1)
	           {
	           start_game = 0;
               return;
               }
              computer_move();
	          win = check_move();
	          if (win == 1)
	             {
                  win = -1;
                  start_game = 0;
                  }
              }
            }
	  }
   }

if ( win == 2 )start_game = 0;

}
Exemplo n.º 3
0
Arquivo: test.c Projeto: simonppg/game
static void test_game(void)
{
    struct Draughts *game;
    game = init_game();
    CU_ASSERT_PTR_NOT_NULL_FATAL(game);
    free(game);
    fake_malloc_params.should_fail = 1;
    struct Draughts *game_fail;
    game_fail = init_game();
    CU_ASSERT_PTR_NULL_FATAL(game_fail);
}
Exemplo n.º 4
0
int main(void)
{
   
   title();
   
   menu();
   
	init_game();
	
	int x=0, y=0;
	while(1)
	{
	   key_poll();
	   
	   x += key_tri_horz()*2;
	   y += key_tri_vert()*2;
	   
	   vid_vsync();
	   
	   //oam_copy(oam_mem, obj_buffer, 128);
	   
	   REG_BG1HOFS = x;
	   REG_BG1VOFS = y;
	}
	
	return 0;
}
Exemplo n.º 5
0
CGame::CGame(char *mapname,int mode,int left_key1,int right_key1,int fire_key1,
						   int left_key2,int right_key2,int fire_key2,
						   int score1,int score2,int cl,bool extras)
{
	CObject *o;

	game_mode=mode;

	init_game(mapname);
	current_level=cl;

	game_remake_extras=extras;

	o=new CPlayerCarObject((dx/2)-30,dy-128,&player_tiles,0,8,
											left_key1,right_key1,fire_key1,score1,start_delay+8,this);
	objects.Add(o);
	focusing_objects.Add(o);
	checkpoint_delay.Add(new int(-1));
	focusing_fy.Add(new float(0.66F));
	focusing_next_car.Add(new int(CAR_INTERVAL));
	focusing_next_car_index.Add(new int(0));

	o=new CPlayerCarObject((dx/2)+14,dy-128,&player_tiles,9,17,
											left_key2,right_key2,fire_key2,score2,start_delay+8,this);
	objects.Add(o);
	focusing_objects.Add(o);
	checkpoint_delay.Add(new int(-1));
	focusing_fy.Add(new float(0.66F));
	focusing_next_car.Add(new int(CAR_INTERVAL));
	focusing_next_car_index.Add(new int(0));

} /* CGame::CGame */ 
Exemplo n.º 6
0
CGame::CGame(char *mapname,int mode,int left_key,int right_key,int fire_key,int score,int cl,bool extras)
{
	CObject *o;

	game_mode=mode;

	init_game(mapname);
	current_level=cl;

	game_remake_extras=extras;

	if (start_delay!=default_start_delay) { /* There is a SEMAPHORE */ 
		o=new CEnemyRacerCarObject((dx/2)+14,dy-128,enemy_tiles[0],start_delay,this);
		objects.Add(o);
	} /* if */ 

	o=new CPlayerCarObject((dx/2)-30,dy-128,&player_tiles,0,8,
											left_key,right_key,fire_key,score,start_delay+8,this);
	objects.Add(o);
	focusing_objects.Add(o);
	checkpoint_delay.Add(new int(-1));
	focusing_fy.Add(new float(0.66F));
	focusing_next_car.Add(new int(CAR_INTERVAL));
	focusing_next_car_index.Add(new int(0));
} /* CGame::CGame */ 
Exemplo n.º 7
0
int main(int argc, char* argv[])
{
	/* Unused arguments */
	(void)argc;
	(void)argv;

	/* Initialize SDL */
	if (SDL_Init(SDL_INIT_VIDEO) != 0){
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
		                         "SDL_Init Failure",
		                         SDL_GetError(),
		                         NULL);
		return EXIT_FAILURE;
	}

	/* Initialize game state */
	init_game();
	/* Initialize graphics */
	if (init_graphics() != 0){
		return EXIT_FAILURE;
	}

	/* Start game logic thread */
	SDL_CreateThread(game_thread, "GameLogic", NULL);

	/* Main Loop */
	while (!quit){
		/* Handle events*/
		handle_event();
		/* Render graphics */
		update_graphics();
	}

	return EXIT_SUCCESS;
}
Exemplo n.º 8
0
void
init(void)
{
	CORE->palette.colors[PC_TRANSPARENT] = color_make(0x00, 0x00, 0x00, 0x00);
	CORE->palette.colors[PC_TRUE_BLACK]  = color_make(0x00, 0x00, 0x00, 0xff);
	set_palette_set(PS_WHITE); // IMPORTANT NOTE(bill): This must be white as the spritesheet is white

	CORE->palette.colors_count = PC_COUNT;
	canvas_clear(1);

	bitmap_load_resource(&spritesheet, "spritesheet.png");
	bitmap_load_resource(&title_screen, "title_screen.png");

	bitmap_load_resource(&font.bitmap, "font.png");
	font.char_width = 4;
	font.char_height = 7;


	CORE->font = &font;

	init_game();

#if 0
	set_palette_set(PS_WHITE);
#endif
}
Exemplo n.º 9
0
int			main(int UNUSED(argc), char ** argv, char **envp)
{
	Game *			game = init_game();
	int				i = -1;
	std::string		visual[] = {
		" ",
		"*",
		" ",
		"~"
	};

	while (++i < WIN_WIDTH )
	{
		game->getBg()[i].setY(0);
		game->getBg()[i].setPatern(Patern(visual[rand() % 4]));
		game->getBg2()[i].setY(WIN_HEIGHT - 1);
	}
	while ( 42 )
	{
		usleep( 1000000 / NB_FRAME );
		if ( doKeyAction(game->getPlayer()) )
			break ;
		game->popRandomEnemy();
		game->move_all();
		if (checkCollisions(game, game->getEnemies(), game->getPlayer()->getBullets()))
			endGame(game->getPlayer()->getScore(), argv[0], envp, "You Win !");
		if (game->getPlayer()->getHp() <= 0)
			break ;
		clear();
		game->display_all();
	}
	endGame(game->getPlayer()->getScore(), argv[0], envp, "You loose !");

	COUT << ENDL;
}
Exemplo n.º 10
0
int main( int argc, char *argv[] )
{
    atexit(end);

    running = 0;
    level = 0;

    init_gui( &argc, argv );

    if( parse_args( &argc, argv ) < 0 )
        exit(0);

    if( init_game( &argc, argv ) < 0 )
        exit(0);

    if( argc > 1 )
    {
        print_usage(argv[0]);
        exit(0);
    }

    print_board();
    start_gui();

    end();
    exit(0);/*Jules : on ne devrait jamais arriver ici mais bon... */
    return 0; /*Vinz : ici encore moins mais restons standards */
}
Exemplo n.º 11
0
static void go_render() {

	SDL_Rect rc = { 25, 100, 640-50, 480-200 };
	SDL_BlitSurface( gbg, 0, front, 0);
	SDL_FillRect( front, &rc, 0);
	{
		static char sbuf[256];

		sprintf(sbuf, "Player %d Wins with Score of %d!!", winner->player_num,  winner->score );
		SDL_PrintText(front, font, rc.x+25, rc.y+25, SDL_MapRGB(front->format, 255, 255, 255), sbuf);
		sprintf(sbuf, "Player %d Press Button 1 to Continue", winner->player_num);
	}
	{

		int i;
		for( i = 0; i < 12; i++) {

			if(SDL_JoystickGetButton(winner->stick, i)) {
				scr = ID_START;
				init_game();
			}
		}

	}
}
Exemplo n.º 12
0
void play_y()
{
	player = -1;
      computer = 1;
	  init_game();
	  computer_move();
}
Exemplo n.º 13
0
int main()
{
    // compteur du nombre de victoires pour les scores
    int count_p1_victories = 0, count_p2_victories = 0;
    game_struct *game = init_game(); // Cree une variable avec la structure game_struct et a qui on lui attribue comme valeur la fonction init_game qui a la meme structure pour plus de proprete

    int replay = 0; // variable booleenne pour savoir si le joueur veut rejouer
    do{
        // play again est une fonction qui a pour but de réinitialiser le board en le vidant prealablement
        if(count_p1_victories > 0 || count_p2_victories > 0)
            game = play_again(game);
        int player_number = start_game(game); // on APPELLE la fonction start_game() avec comme parametre game (ainsi que ses variables initialisees precedement)
        if(player_number == 1)
            count_p1_victories++;
        else
            count_p2_victories++;

        printf("Fin de la partie :\n");
        printf("%s a %d victoires\n", game->first_player, count_p1_victories);
        printf("%s a %d victoires\n", game->second_player, count_p2_victories);

        printf("Voulez-vous rejouer (1 pour oui, 2 pour non)?\n");
        scanf("%d", &replay);
    }while(replay == 1);

    free(game);
    //system("pause"); // laisser la console affichee une fois le programme termine !!! (Ne marche que sur Windows) !!!
    return 0;
}
Exemplo n.º 14
0
int		main(int argc, char** argv)
{
	(void)		argc;
	(void)		argv;
	env_game	game;
	GdkColor        color;
	
	gtk_init(&argc, &argv);
	if(init_game(&game))
		return 0;
	init_score(&game);
	gdk_color_parse ("brown", &color);
	gtk_window_set_position(GTK_WINDOW(game.window),GTK_WIN_POS_CENTER); 
	generate_all_button(game.button, &color);
	g_signal_connect(game.window, "destroy", G_CALLBACK(destroy),&game);
	while (game.i != 64)
	{
		g_signal_connect(game.button[game.i], "clicked", G_CALLBACK(move), &game);
		assign_button_coord(game.button[game.i], game.terrain, game.i);
		game.i = game.i + 1;
	}
	generated_platform(game.hbox,game.vbox,game.button);
	gtk_container_add(GTK_CONTAINER(game.window), GTK_WIDGET(game.vbox));
	gtk_widget_show_all(game.window);
	gtk_main();
	return (0);
}
Exemplo n.º 15
0
/*
 * Handle a message about game parameters.
 */
static void handle_status_meta(char *ptr)
{
    char name[1024];
    int i;

    /* Read basic game parameters */
    real_game.num_players = get_integer(&ptr);
    real_game.expanded = get_integer(&ptr);
    real_game.advanced = get_integer(&ptr);
    real_game.goal_disabled = get_integer(&ptr);
    real_game.takeover_disabled = get_integer(&ptr);

    /* Initialize card designs for this expansion level */
    init_game(&real_game);

    /* Load AI neural networks for this game */
    ai_func.init(&real_game, 0, 0);

    /* Loop over goals */
    for (i = 0; i < MAX_GOAL; i++)
    {
        /* Read goal presence */
        real_game.goal_active[i] = get_integer(&ptr);
    }

    /* Loop over players */
    for (i = 0; i < real_game.num_players; i++)
    {
        /* Read player name */
        get_string(name, &ptr);

        /* Copy name */
        real_game.p[i].name = strdup(name);
    }
}
Exemplo n.º 16
0
void keyboard(unsigned char key, int x, int y)
{
    if (key == 'g')
        init_game();
    if (key == 'p')
        pause = !pause;
    if (key == 'q')
        exit(0);
    if (key == '\'')
        draw_cos = !draw_cos;
    if (key == 'y')
    {
        int r = rand() % world.bodies.size();
        if (world.bodies[r]->mass < world.vars.UNMOVABLE_MASS)
            world.bodies[r]->velocity = world.bodies[r]->velocity + Vector2(0, 12);
    }
    if (key == '+' || key == '-')
    {
        int w = glutGet(GLUT_WINDOW_WIDTH);
        int h = glutGet(GLUT_WINDOW_HEIGHT);
        if (key == '+')
            zoom_distance -= 1;
        if (key == '-')
            zoom_distance += 1;
        reshape(w, h);
    }
    if (draw_tw)
        TwEventKeyboardGLUT(key, x, y);
    glutBitmapCharacter(GLUT_BITMAP_8_BY_13, key);
    glutPostRedisplay();
}
Exemplo n.º 17
0
void ram(void) {
	while(1) {
		if (!screen_intro()){
      setTextColor(0xff,0x00);
      return;
    }
		game.rokets = 3;
		game.level = 1;
		game.score = 0;
		init_game();
		screen_level();
		while (game.rokets>=0) {
			////checkISP();
			lcdFill(0x00);
			check_end();
			move_ufo();
			move_shot();
			move_shots();
			move_player();
			move_enemy();
			draw_score();
			draw_ufo();
			draw_bunker();
			draw_player();
			draw_enemy();
			draw_shots();
			//        draw_status();
			lcdDisplay();
			delayms(12);
		}
		if (!screen_gameover())
      setTextColor(0xff,0x00);
      return;
	}
}
Exemplo n.º 18
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    InitUSB();
    init_oc();

    init_display(&i2c3, 0x70, 0x71);
    init_game(&timer1, &timer2, &A[0], &disp1, &disp2);
    init_gun(&D[13], &A[1], &A[2], &timer3);
    init_launcher(&D[5], &D[8], &D[3], &D[4]);
    init_shooter(&D[6], &D[9], &D[1], &D[2], &D[7], &D[0], &oc3, &oc4);
    init_baller(&D[10], &oc2, &timer4, &shooter, &launcher);
    init_pix(&D[11], &timer5, 30, 0.05);
    init_audio(&D[12]);

    uint8_t level = 0;
    uint8_t hit_flag = 0;
    while (1) {
        ServiceUSB(); // usb times out if not checked fast enough :/
        level = run_game(hit_flag);
        ServiceUSB();
        hit_flag = run_gun(level);
        ServiceUSB();
        run_baller(level);
    }
}
Exemplo n.º 19
0
void CLI::apply_option(int option) {
    switch (option) {
        case HUMAN_VS_CPU:
        case CPU_VS_HUMAN:
        case HUMAN_VS_HUMAN:
        case CPU_VS_CPU:
            init_game(option);
            start_game();
            end_game();
            break;
        case LOAD:
            read_load();
            break;
        case SHOW_HELP:
            print_help();
            break;
        case BENCHMARK:
            run_benchmark();
            break;
        case WAC:
            run_wac_test();
            break;
        case SETTINGS:
            read_settings();
            break;
        case QUIT:
            cout << "Thanks for playing...!! Have fun..\n";
            break;
    }
}
Exemplo n.º 20
0
void play_x()
{
	//select=1;
	player = 1;
	   computer = -1;
	   init_game();
}
Exemplo n.º 21
0
int main(void)
{
    TicTacToe game;
    int size;

    printf("This is the game of Tic Tac Toe.\n");
    printf("You will be playing against the computer.\n");

    printf("Enter the size of the board: ");
    scanf("%d", &size);
    printf("The game board is %d by %d.\n", size, size);

    init_game(&game, size); // initialise the board

    int done;
    do {
        print_game(game);
        do {
            done = player_move(&game);
        } while (!done); // loop until valid move
        if(check(&game) != FALSE) break; // was a winner or a draw
        computer_move(&game);
        if(check(&game) != FALSE) break; // was a winner or a draw
    } while (TRUE);

    print_result(game);
    print_game(game); // show final positions

    free_game(&game);

    return 0;
}
Exemplo n.º 22
0
void RemoteServerProxy::join_game(size_t game_id) {
  MessageWriter writer(socket_);
  writer.send_join_game(game_id);

  read_object_id(&object_id_);
  init_game();
  updater_->start();
}
Exemplo n.º 23
0
void Main(void) {
	/* Inicializa controladores */
	sys_init();        // Inicializacion de la placa, interrupciones y puertos
	D8Led_init(); // inicializamos el 8led
	Button_init(0, 9); // inicializamos los pulsadores. Cada vez que se pulse se verá reflejado en el 8led

	init_game();
}
Exemplo n.º 24
0
void test_minimax(Heuristic h, int *score, int *maxtile) {
    Game g = init_game(h);
    if (score != NULL)
        *score = play2048(g);
    if (maxtile != NULL)
        *maxtile = max_tile(g->board);
    game_free(g);
}
Exemplo n.º 25
0
void test_expectation(Heuristic h, int depth, int *score, int *maxtile) {
    Game g= init_game(h);
    if (score != NULL)
        *score = playExpected2048(g, depth);
    if (maxtile != NULL)
        *maxtile = max_tile(g->board);
    game_free(g);
}
Exemplo n.º 26
0
int	main(void)
{
  int	ret;

  init_game();
  combat_test();
  ret = EXIT_SUCCESS;
  return (ret);
}
Exemplo n.º 27
0
bool RemoteServerProxy::start_game(size_t map_id, std::string game_name, int players_size) {
  MessageWriter writer(socket_);
  writer.send_create_game(map_id, game_name, players_size);

  read_object_id(&object_id_);
  init_game();
  updater_->start();

  return true;
}
Exemplo n.º 28
0
/* 
 * main
 *   DESCRIPTION: Play the adventure game.
 *   INPUTS: none (command line arguments are ignored)
 *   OUTPUTS: none
 *   RETURN VALUE: 0 on success, 3 in panic situations
 */
int
main ()
{
    game_condition_t game;  /* outcome of playing */

    /* Randomize for more fun (remove for deterministic layout). */
    srand (time (NULL));

    /* Provide some protection against fatal errors. */
    clean_on_signals ();

    if (!build_world ()) {PANIC ("can't build world");}
    init_game ();

    /* Perform sanity checks. */
    if (0 != sanity_check ()) {
	PANIC ("failed sanity checks");
    }

    /* Create status message thread. */
    if (0 != pthread_create (&status_thread_id, NULL, status_thread, NULL)) {
        PANIC ("failed to create status thread");
    }
    push_cleanup (cancel_status_thread, NULL); {

	/* Start mode X. */
	if (0 != set_mode_X (fill_horiz_buffer, fill_vert_buffer)) {
	    PANIC ("cannot initialize mode X");
	}
	push_cleanup ((cleanup_fn_t)clear_mode_X, NULL); {

	    /* Initialize the keyboard and/or Tux controller. */
	    if (0 != init_input ()) {
		PANIC ("cannot initialize input");
	    }
	    push_cleanup ((cleanup_fn_t)shutdown_input, NULL); {

		game = game_loop ();

	    } pop_cleanup (1);

	} pop_cleanup (1);

    } pop_cleanup (1);

    /* Print a message about the outcome. */
    switch (game) {
	case GAME_WON: printf ("You win the game!  CONGRATULATIONS!\n"); break;
	case GAME_QUIT: printf ("Quitter!\n"); break;
    }

    /* Return success. */
    return 0;
}
Exemplo n.º 29
0
/**
 * \brief Initializes the game.
 */
void tunnel::game::init()
{
  delete m_game;

  init_logger();

  claw::logger << claw::log_verbose << "Initializing game instance."
               << std::endl;

  init_game();
} // game::init()
Exemplo n.º 30
0
void close_server() {
   while (socket_list)
      remove_socket(socket_list);

   online = 0;
   server = 0;
   init_door();
   if (screen == GAME_SCREEN_WORLD)
      init_telegraph();
   init_game(0);
}