Exemplo n.º 1
0
//アニメーションさせる
bool XModel::Animate(int anim, float speed)
{
	Animation[anim]->time += speed;
	AnimateFrame();
	AnimateVertex();
	//アニメーション時間が次で終わりまでいきそうかどうか
	if(Animation[anim]->GetMaxTime() < Animation[anim]->time + speed)	return true;
	return false;
}
Exemplo n.º 2
0
// This function draws to the screen
static void RenderScreen(){

    AnimateFrame();  //animate the objects in the frame

    
    if( (screen_dirty) || (frame_counter<1) ){ 
        //Full background rect clearing
        //SDL_FillRect(screen, NULL, grass_color);
		SDL_BlitSurface(grassField, &screen_rect, screen, &screen_rect);

        
        //draw the goal posts
        SDL_BlitSurface(goalPost, NULL, screen, &right_goal_rect);
        SDL_BlitSurface(goalPost, NULL, screen, &left_goal_rect);
        
        //Reset screen dirty flag
        screen_dirty = 0;     
    }
    else{    
        //Debug ball clear rect
        //SDL_FillRect(screen, &ball_clear_rect, debug_color);
        
        //clear old ball rect
        //SDL_FillRect(screen, &ball_clear_rect, grass_color);
        SDL_BlitSurface(grassField, &ball_clear_rect, screen, &ball_clear_rect);

        //draw the goal posts
        SDL_BlitSurface(goalPost, NULL, screen, &right_goal_rect);
        SDL_BlitSurface(goalPost, NULL, screen, &left_goal_rect);
        
        //Clear old character rect

        //SDL_FillRect(screen, &yellow_guy_clear_rect, grass_color);
		SDL_BlitSurface(grassField, &yellow_guy_clear_rect, screen, &yellow_guy_clear_rect);

        //SDL_FillRect(screen, &purple_guy_clear_rect, grass_color);
		SDL_BlitSurface(grassField, &purple_guy_clear_rect, screen, &purple_guy_clear_rect);
        


        //debug the character clear rects
        //SDL_FillRect(screen, &yellow_guy_clear_rect, debug_color);
        //SDL_FillRect(screen, &purple_guy_clear_rect, debug_color);
    }
	 
    //----------------------
    //Draw the soccer ball
    //----------------------
    DrawBall(ball.frame, ball.x, ball.y);


    //----------------------
    //Draw the goal posts
    //----------------------

    //Redraw the left goal post when the ball is near by
    //if(ball.x < 22 ){
    SDL_BlitSurface(goalPost, NULL, screen, &left_goal_rect);
    //}
    
    //Redraw the right goal post when the ball is near by
    //if((ball.x+ball.w) > (screen->w-22) ){
    SDL_BlitSurface(goalPost, NULL, screen, &right_goal_rect);
    //}
    
    
    //----------------------
    //Draw the characters
    //----------------------
    SDL_BlitSurface(purple_player.image, NULL, screen, &purple_guy_rect);
    SDL_BlitSurface(yellow_player.image, NULL, screen, &yellow_guy_rect);



    //-------------------------
    //Update the screen
    //-------------------------
    
    /* Make sure everything is displayed on screen */
    SDL_Flip(screen);
    
    /* Don't run too fast */
    #ifdef _WIN32
    SDL_Delay(15);
    #endif

    #ifdef __sgi
    SDL_Delay(1);
    #endif
    
    SDL_Delay(1);
    
    
    //increment the current frame number
    frame_counter++;
    
    //Save the settings from the previous frame
    SavePrevious(); 
}