亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? freakout.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// this function tests if the ball has hit a block or the paddle
// if so, the ball is bounced and the block is removed from 
// the playfield note: very cheesy collision algorithm :)

// first test for ball block collisions

// the algorithm basically tests the ball against each 
// block's bounding box this is inefficient, but easy to 
// implement, later we'll see a better way

int x1 = BLOCK_ORIGIN_X, // current rendering position
    y1 = BLOCK_ORIGIN_Y; 

int ball_cx = ball_x+(BALL_SIZE/2),  // computer center of ball
    ball_cy = ball_y+(BALL_SIZE/2);

// test of the ball has hit the paddle
if (ball_y > (SCREEN_HEIGHT/2) && ball_dy > 0)
   {
   // extract leading edge of ball
   int x = ball_x+(BALL_SIZE/2);
   int y = ball_y+(BALL_SIZE/2);

   // test for collision with paddle
   if ((x >= paddle_x && x <= paddle_x+PADDLE_WIDTH) &&
       (y >= paddle_y && y <= paddle_y+PADDLE_HEIGHT))
       {
       // reflect ball
       ball_dy=-ball_dy;

       // push ball out of paddle since it made contact
       ball_y+=ball_dy;

       // add a little english to ball based on motion of paddle
       if (KEY_DOWN(VK_RIGHT))
          ball_dx-=(rand()%3);
       else
       if (KEY_DOWN(VK_LEFT))
          ball_dx+=(rand()%3);
       else
          ball_dx+=(-1+rand()%3);
       
       // test if there are no blocks, if so send a message
       // to game loop to start another level
       if (blocks_hit >= (NUM_BLOCK_ROWS*NUM_BLOCK_COLUMNS))
          {
          game_state = GAME_STATE_START_LEVEL;
          level++;
          } // end if

       // make a little noise
       MessageBeep(MB_OK);

       // return
       return; 

       } // end if

   } // end if

// now scan thru all the blocks and see of ball hit blocks
for (int row=0; row < NUM_BLOCK_ROWS; row++)
    {    
    // reset column position
    x1 = BLOCK_ORIGIN_X;

    // scan this row of blocks
    for (int col=0; col < NUM_BLOCK_COLUMNS; col++)
        {
        // if there is a block here then test it against ball
        if (blocks[row][col]!=0)
           {
           // test ball against bounding box of block
           if ((ball_cx > x1) && (ball_cx < x1+BLOCK_WIDTH) &&     
               (ball_cy > y1) && (ball_cy < y1+BLOCK_HEIGHT))
               {
               // remove the block
               blocks[row][col] = 0; 

               // increment global block counter, so we know 
               // when to start another level up
               blocks_hit++;

               // bounce the ball
               ball_dy=-ball_dy;

               // add a little english
               ball_dx+=(-1+rand()%3);

               // make a little noise
               MessageBeep(MB_OK);

               // add some points
               score+=5*(level+(abs(ball_dx)));

               // that's it -- no more block
               return;

               } // end if  

           } // end if

        // advance column position
        x1+=BLOCK_X_GAP;
        } // end for col

    // advance to next row position
    y1+=BLOCK_Y_GAP;

    } // end for row

} // end Process_Ball

///////////////////////////////////////////////////////////////

int Game_Main(void *parms)
{
// this is the workhorse of your game it will be called
// continuously in real-time this is like main() in C
// all the calls for you game go here!

char buffer[80]; // used to print text

// what state is the game in? 
if (game_state == GAME_STATE_INIT)
    {
    // initialize everything here graphics
    DD_Init(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);

    // seed the random number generator
    // so game is different each play
    srand(Start_Clock());

    // set the paddle position here to the middle bottom
    paddle_x = PADDLE_START_X;
    paddle_y = PADDLE_START_Y;

    // set ball position and velocity
    ball_x = 8+rand()%(SCREEN_WIDTH-16);
    ball_y = BALL_START_Y;
    ball_dx = -4 + rand()%(8+1);
    ball_dy = 6 + rand()%2;

    // transition to start level state
    game_state = GAME_STATE_START_LEVEL;

    } // end if 
////////////////////////////////////////////////////////////////
else
if (game_state == GAME_STATE_START_LEVEL)
    {
    // get a new level ready to run

    // initialize the blocks
    Init_Blocks();

    // reset block counter
    blocks_hit = 0;

    // transition to run state
    game_state = GAME_STATE_RUN;

    } // end if
///////////////////////////////////////////////////////////////
else
if (game_state == GAME_STATE_RUN)
    {
    // start the timing clock
    Start_Clock();

    // clear drawing surface for the next frame of animation
    Draw_Rectangle(0,0,SCREEN_WIDTH-1, SCREEN_HEIGHT-1,200);

    // move the paddle
    if (KEY_DOWN(VK_RIGHT))
       {
       // move paddle to right
       paddle_x+=8;
 
       // make sure paddle doesn't go off screen
       if (paddle_x > (SCREEN_WIDTH-PADDLE_WIDTH))
          paddle_x = SCREEN_WIDTH-PADDLE_WIDTH;

       } // end if
    else
    if (KEY_DOWN(VK_LEFT))
       {
       // move paddle to right
       paddle_x-=8;
 
       // make sure paddle doesn't go off screen
       if (paddle_x < 0)
          paddle_x = 0;

       } // end if

    // draw blocks
    Draw_Blocks();

    // move the ball
    ball_x+=ball_dx;
    ball_y+=ball_dy;

    // keep ball on screen, if the ball hits the edge of 
    // screen then bounce it by reflecting its velocity
    if (ball_x > (SCREEN_WIDTH - BALL_SIZE) || ball_x < 0) 
       {
       // reflect x-axis velocity
       ball_dx=-ball_dx;

       // update position 
       ball_x+=ball_dx;
       } // end if

    // now y-axis
    if (ball_y < 0) 
       {
       // reflect y-axis velocity
       ball_dy=-ball_dy;

       // update position 
       ball_y+=ball_dy;
       } // end if
   else 
   // penalize player for missing the ball
   if (ball_y > (SCREEN_HEIGHT - BALL_SIZE))
       {
       // reflect y-axis velocity
       ball_dy=-ball_dy;

       // update position 
       ball_y+=ball_dy;

       // minus the score
       score-=100;

       } // end if

    // next watch out for ball velocity getting out of hand
    if (ball_dx > 8) ball_dx = 8;
    else
    if (ball_dx < -8) ball_dx = -8;    

    // test if ball hit any blocks or the paddle
    Process_Ball();

    // draw the paddle and shadow
    Draw_Rectangle(paddle_x-8, paddle_y+8, 
                   paddle_x+PADDLE_WIDTH-8, 
                   paddle_y+PADDLE_HEIGHT+8,0);

    Draw_Rectangle(paddle_x, paddle_y, 
                   paddle_x+PADDLE_WIDTH, 
                   paddle_y+PADDLE_HEIGHT,PADDLE_COLOR);

    // draw the ball
    Draw_Rectangle(ball_x-4, ball_y+4, ball_x+BALL_SIZE-4, 
                   ball_y+BALL_SIZE+4, 0);
    Draw_Rectangle(ball_x, ball_y, ball_x+BALL_SIZE, 
                   ball_y+BALL_SIZE, 255);

    // draw the info
    sprintf(buffer,"F R E A K O U T           Score %d             Level %d",score,level);
    Draw_Text_GDI(buffer, 8,SCREEN_HEIGHT-16, 127);
    
    // flip the surfaces
    DD_Flip();

    // sync to 33ish fps
    Wait_Clock(30);

    // check of user is trying to exit
    if (KEY_DOWN(VK_ESCAPE))
       {
       // send message to windows to exit
       PostMessage(main_window_handle, WM_DESTROY,0,0);

       // set exit state
       game_state = GAME_STATE_SHUTDOWN;

       } // end if

    } // end if
///////////////////////////////////////////////////////////////
else
if (game_state == GAME_STATE_SHUTDOWN)
   {
   // in this state shut everything down and release resources
   DD_Shutdown();

   // switch to exit state
   game_state = GAME_STATE_EXIT;

   } // end if

// return success
return(1);

} // end Game_Main

///////////////////////////////////////////////////////////////

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产麻豆免费人成网站| 美脚の诱脚舐め脚责91| 欧美精品一区二区三区四区| 欧美日韩高清不卡| 欧美在线不卡一区| 在线观看日韩一区| 欧美精品在线观看播放| 日韩一级完整毛片| 日韩丝袜情趣美女图片| 久久综合网色—综合色88| 精品精品国产高清a毛片牛牛| 精品成人佐山爱一区二区| 精品少妇一区二区三区在线视频 | 国产日产亚洲精品系列| 国产午夜亚洲精品理论片色戒 | 欧美日韩一区成人| 欧美一区二区免费观在线| 日韩一区二区高清| 久久精品人人做人人综合| 国产精品麻豆一区二区 | 7777精品伊人久久久大香线蕉经典版下载 | 欧美日韩不卡视频| 日韩一区国产二区欧美三区| 久久综合色8888| 国产精品视频看| 日韩理论片中文av| 丝袜美腿亚洲一区二区图片| 国产麻豆午夜三级精品| 99在线视频精品| 欧美探花视频资源| 久久综合成人精品亚洲另类欧美| 国产日韩av一区二区| 一区二区三区四区蜜桃| 蜜桃视频在线一区| 91网站最新网址| 欧美白人最猛性xxxxx69交| 国产精品久久久久四虎| 无吗不卡中文字幕| 成人ar影院免费观看视频| 在线观看免费成人| 国产日韩精品一区| 日韩av一级片| 91亚洲精品一区二区乱码| 欧美一区二区三区视频| 国产精品久线在线观看| 美国十次综合导航| 在线观看日韩av先锋影音电影院| 久久这里只有精品6| 亚洲成av人片一区二区梦乃| 国产激情精品久久久第一区二区| 欧美在线观看一区| 国产精品国产三级国产三级人妇 | 亚洲综合在线免费观看| 精品亚洲porn| 精品视频一区三区九区| 国产精品美女一区二区| 久久99国产精品久久99果冻传媒| 在线观看日产精品| 国产精品久久国产精麻豆99网站| 久久97超碰色| 欧美一区二区久久久| 亚洲第一电影网| 欧美视频中文字幕| 亚洲精品久久久蜜桃| 色综合网色综合| 国产精品成人在线观看| 成人黄色网址在线观看| 久久精品一区二区| 国产露脸91国语对白| 久久一区二区三区四区| 久久爱另类一区二区小说| 日韩欧美成人一区| 另类中文字幕网| 欧美成人a∨高清免费观看| 麻豆久久久久久久| 精品少妇一区二区三区视频免付费 | 亚洲摸摸操操av| 色综合久久综合网97色综合| 成人免费小视频| 色综合天天视频在线观看| 国产精品看片你懂得| 99精品欧美一区二区三区小说| 中文字幕五月欧美| 91亚洲国产成人精品一区二区三 | 欧美日韩在线播放一区| 亚洲影院理伦片| 欧美亚洲日本一区| 首页综合国产亚洲丝袜| 日韩午夜激情视频| 国产一区二区三区国产| 国产精品乱码一区二区三区软件 | 欧美va亚洲va香蕉在线| 紧缚奴在线一区二区三区| 久久嫩草精品久久久精品| 成人性生交大合| 亚洲一二三级电影| 日韩手机在线导航| 菠萝蜜视频在线观看一区| 亚洲资源中文字幕| 欧美tickling网站挠脚心| 成人精品国产福利| 亚洲成在人线免费| 国产清纯白嫩初高生在线观看91| www.日本不卡| 午夜精彩视频在线观看不卡| 日韩一区二区在线观看视频 | 欧美成人免费网站| 波多野结衣欧美| 五月天激情综合| 日本一区二区动态图| 在线观看91视频| 国产成人亚洲综合a∨猫咪| 亚洲精选免费视频| 精品国产成人系列| 欧美午夜一区二区| 国产一区激情在线| 五月激情六月综合| 中文字幕亚洲视频| 久久只精品国产| 911精品国产一区二区在线| 成人禁用看黄a在线| 日本欧美加勒比视频| 亚洲人成网站在线| 久久精品日产第一区二区三区高清版| 91黄视频在线| 国产成人免费视频网站高清观看视频| 舔着乳尖日韩一区| 亚洲精品视频在线观看网站| 久久久久久久久免费| 91精品久久久久久蜜臀| 91影视在线播放| 春色校园综合激情亚洲| 另类小说图片综合网| 亚洲国产一区在线观看| 亚洲日本丝袜连裤袜办公室| 久久久久久久av麻豆果冻| 欧美一级久久久| 欧美性猛交xxxxxxxx| 91影院在线观看| 波多野洁衣一区| 国产乱人伦偷精品视频免下载| 日本欧美加勒比视频| 午夜精品爽啪视频| 五月天激情综合网| 亚洲不卡在线观看| 香蕉乱码成人久久天堂爱免费| 伊人性伊人情综合网| 一区二区三区中文字幕电影 | 亚洲欧美自拍偷拍色图| 久久久精品免费网站| 日韩欧美在线一区二区三区| 欧美日韩免费一区二区三区视频| 欧洲另类一二三四区| 91激情在线视频| 欧美三级电影精品| 欧美日本在线视频| 欧美一区二区三区视频在线 | 欧美狂野另类xxxxoooo| 欧美男同性恋视频网站| 欧美一区二区精品久久911| 在线播放亚洲一区| 日韩欧美在线观看一区二区三区| 精品久久久久久久久久久久久久久 | 亚洲国产精品天堂| 日韩精品亚洲专区| 国产原创一区二区| 99这里都是精品| 欧美唯美清纯偷拍| 精品日产卡一卡二卡麻豆| 久久婷婷国产综合精品青草| 日本一区二区三级电影在线观看 | 国产九九视频一区二区三区| 韩国v欧美v日本v亚洲v| 成人丝袜18视频在线观看| 91蜜桃传媒精品久久久一区二区| 色噜噜狠狠成人中文综合| 精品1区2区3区| 亚洲精品一区二区三区影院| 欧美国产成人在线| 亚洲国产日日夜夜| 国产精品77777竹菊影视小说| 91丝袜高跟美女视频| 日韩一区二区电影| 亚洲视频一二三| 美腿丝袜亚洲三区| 成人精品鲁一区一区二区| 欧美高清www午色夜在线视频| 久久嫩草精品久久久久| 夜夜操天天操亚洲| 国产一区日韩二区欧美三区| 欧美视频在线观看一区| 精品国产网站在线观看| 亚洲精品亚洲人成人网 | 天天综合网天天综合色| 国产一区二区久久| 欧美视频完全免费看| 久久久国产一区二区三区四区小说 | 日韩免费成人网| 亚洲免费观看高清| 高清不卡在线观看av|