void gameinfo_serve_set(GameInfo *gi, TEAM win) { if (win == BLUE) { ball_init(gi->ball, BLUE); } else { ball_init(gi->ball, RED); } slime_init(gi->slime_blue); slime_init(gi->slime_red); gi->penalty_y = g_random_double_range(120, WIN_HEIGHT - 40); // XXX gi->ball_count = 1; gi->wait_count = 0; gi->state = GS_PLAY; }
static void null_leave(struct state *st, struct state *next, int id) { shad_init(); ball_init(); geom_init(); gui_init(); }
void jess_init_xmms (void) { conteur.burn_mode = 4; conteur.draw_mode = 3; conteur.blur_mode = 3; its_first_time = 1; video = 32; resolution_change = 0; conteur.term_display = OUI; resx = RESX; resy = RESY; printf ("\n\n\n------- JESS First Init ------\n"); printf("\n Create mutex\n"); mutex_one = SDL_CreateMutex(); jess_init(); ball_init(); if (resolution_change == 0) { render_thread = SDL_CreateThread ( (void *) renderer, NULL, NULL); if ( render_thread == NULL) { fprintf (stderr, "Pthread_create error for thread renderer\n"); exit (1); } printf("Pthread_create renderer passed\n"); } }
int main() { // Application init. initscr(); cbreak(); noecho(); halfdelay(1); srand(time(NULL)); int maxX, maxY; getmaxyx(stdscr, maxY, maxX); // Objects init. struct Ball ball[BALL_COUNT]; int i; for(i = 0; i < BALL_COUNT; ++i) { ball_init(&ball[i], maxX, maxY); } // Loop. while(getch() != QUIT_KEY) { // Drawing. erase(); for(i = 0; i < BALL_COUNT; ++i) mvaddch(maxY - 1 - (int)ball[i].y, (int)ball[i].x, getSprite(&ball[i])); mvaddch(maxY - 1, maxX - 1, ' '); refresh(); // System. for(i = 0; i < BALL_COUNT; ++i) ball_process(&ball[i], maxX, maxY); } endwin(); return 0; }
static void null_leave(struct state *st, struct state *next, int id) { mtrl_load_objects(); shad_init(); ball_init(); geom_init(); gui_init(); }
static void null_leave(struct state *st, struct state *next, int id) { part_init(); shad_init(); ball_init(); item_init(); geom_init(); gui_init(); hud_init(); }
void gameinfo_init(GameInfo *gi) { ball_init(gi->ball, BLUE); slime_init(gi->slime_blue); slime_init(gi->slime_red); gi->ball_owner = BLUE; gi->ball_count = 1; gi->wait_count = 0; gi->score_blue = SCORE_INIT; gi->score_red = SCORE_INIT; gi->state = GS_SERVICE_BY_BLUE; }
Game * game_init(struct timeval start_time) { Game *game = malloc(sizeof(Game)); Field *field = field_init(); Player *player = player_init(field, 10); Ball *ball = ball_init(field); game->field = field; game->player = player; game->ball = ball; game->start_time = start_time; return game; }
void data_init() { int i; for(i=0; i<MAX_BALL_NUM; i++) { if (!ballArray[i]) //ballArray[i] = ball_init(rand()%200, rand()%200, 50, CLR_RGB(rand()%256,rand()%256,rand()%256)); ballArray[i] = ball_init(rand()%200, rand()%200, rand()%30+5, CLR_RGB(rand()%256,rand()%256,rand()%256)); } selClr = ball_getClr(ballArray[selBall]); ball_setName(ballArray[selBall], defname); ball_setClr(ballArray[selBall], CLR_RGB(255,0,0)); }
void set_up() { initscr(); /* turn on curses */ noecho(); /* turn off echo */ cbreak(); /* turn off buffering */ srand( getpid() ); /*seed the random num generator*/ signal(SIGINT, SIG_IGN); /* ignore SIGINT */ signal(SIGTERM, SIG_IGN); /* ignore SIGINT */ //Draw the court court_init( 3 ); //Init the scoreboard display ppcourt_geom court_g; court_geom( &court_g ); jmbtrn_init( court_g.top - 1, court_g.left + 1 ); /*Init's clock to 0*/ jmbtrn_display_ball_count( STARTING_BALL_COUNT ); //Init the referee referee_init(); //Init the paddle paddle_init( ); //Init and serve the ball ball_init( ); //Create a sigaction with "handle_tick" as the handler struct sigaction tick_handler; tick_handler.sa_handler = handle_tick; tick_handler.sa_flags |= SA_RESTART; /*Make sure to restart sys calls*/ if ( sigaction( SIGALRM, &tick_handler, NULL ) == -1 ){ perror( "Sigaction" ); exit( 1 ); }else{ if ( set_ticker( 1000 / (TICK_PER_SEC) ) == -1 ){/* send millisecs per tick */ perror( "Error setting ticker" ); exit( 1 ); } } }