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

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

?? freakout.cpp

?? 《Windows游戲編程大師技巧》代碼
?? 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一区二区三区免费野_久草精品视频
奇米777欧美一区二区| 免费的国产精品| 手机精品视频在线观看| 国产精品996| 欧美日韩大陆一区二区| 国产精品成人免费精品自在线观看| 日韩色视频在线观看| 国产无人区一区二区三区| 亚洲第一电影网| 97久久超碰精品国产| 欧美电视剧免费观看| 亚洲国产精品精华液网站| 国产91精品免费| 日韩一级视频免费观看在线| 亚洲一卡二卡三卡四卡| 99麻豆久久久国产精品免费| 精品99一区二区| 日本不卡的三区四区五区| 欧美日韩色综合| 亚洲黄色小视频| 色综合久久综合中文综合网| 国产精品传媒视频| 亚洲精品一区二区三区在线观看 | 亚洲男人的天堂在线aⅴ视频| 久久91精品国产91久久小草| 欧美日韩大陆在线| 一区二区三区在线播| 波多野结衣在线一区| 精品区一区二区| 精品一区二区在线观看| 精品国产91久久久久久久妲己| 日本亚洲最大的色成网站www| 欧美久久久久中文字幕| 同产精品九九九| 91精品欧美久久久久久动漫| 免费欧美高清视频| 日韩三级.com| 国产一区二区三区精品视频| 久久五月婷婷丁香社区| 粉嫩在线一区二区三区视频| 国产精品国产三级国产三级人妇| 成人精品鲁一区一区二区| 国产精品福利一区| 91农村精品一区二区在线| 亚洲精品中文字幕乱码三区| 欧美视频你懂的| 日韩av一二三| 国产欧美一区二区三区在线看蜜臀 | 偷拍一区二区三区| 欧美老女人第四色| 极品瑜伽女神91| 国产精品久久久久精k8| 欧美在线小视频| 久久精品国产色蜜蜜麻豆| 久久久噜噜噜久噜久久综合| 97超碰欧美中文字幕| 亚洲777理论| 国产三级精品在线| av网站一区二区三区| 亚洲欧美在线另类| 在线免费观看视频一区| 蜜桃视频在线一区| 国产精品嫩草99a| 欧美日韩免费一区二区三区 | 欧美日韩国产系列| 国产一区二区三区精品视频| 国产精品麻豆网站| 欧美日韩精品一区二区在线播放 | 久久综合久久综合九色| 一本久久综合亚洲鲁鲁五月天| 日韩不卡一二三区| 国产精品久久久久久久久久久免费看| 欧美三级日韩在线| 国产高清精品久久久久| 亚洲成在线观看| 日本一区免费视频| 日韩欧美一级特黄在线播放| 99久久伊人久久99| 久久国产精品99久久久久久老狼| 亚洲精品网站在线观看| 精品美女在线观看| 欧美在线一区二区| www.亚洲国产| 黄一区二区三区| 日日夜夜精品视频免费| ...xxx性欧美| 国产色综合一区| 3atv一区二区三区| 91激情在线视频| 成人一二三区视频| 国产毛片一区二区| 久久超碰97人人做人人爱| 亚洲一二三四在线观看| 国产精品乱码一区二区三区软件| 日韩精品在线网站| 91精品国产乱码久久蜜臀| 色婷婷精品久久二区二区蜜臂av| 国产一区三区三区| 蜜臀99久久精品久久久久久软件| 亚洲成av人片一区二区梦乃| 一区二区欧美视频| 亚洲欧美日韩一区二区| 国产精品污网站| 久久久久久免费网| 久久久久99精品一区| 精品国精品国产| 精品国产91亚洲一区二区三区婷婷 | 日韩综合一区二区| 亚洲国产欧美日韩另类综合| 亚洲精品v日韩精品| 国产精品私人影院| 中文在线一区二区| 欧美高清一级片在线观看| 久久精品一区二区三区四区 | 制服丝袜亚洲播放| 欧美一区二区视频免费观看| 91精品国产乱| 26uuuu精品一区二区| 国产午夜精品一区二区三区视频| 久久久久久久免费视频了| 国产日韩欧美不卡在线| 国产精品你懂的在线欣赏| 亚洲欧洲无码一区二区三区| 自拍偷拍国产精品| 一区二区三区av电影| 午夜精品一区二区三区电影天堂 | 亚洲精选一二三| 亚洲国产综合91精品麻豆| 亚洲不卡一区二区三区| 日本女优在线视频一区二区| 国内精品写真在线观看 | 九九在线精品视频| 国产一区二区h| 91色porny| 91精品蜜臀在线一区尤物| 久久综合狠狠综合| 国产精品久久99| 亚洲成a人在线观看| 蜜臀va亚洲va欧美va天堂| 国产成人一区二区精品非洲| 99re热视频精品| 91精品福利在线一区二区三区| 欧美精品一区二区在线观看| 一区在线播放视频| 日韩电影一区二区三区四区| 国产成人亚洲综合a∨婷婷 | 国产精品综合在线视频| 99久久精品99国产精品| 欧美肥胖老妇做爰| 欧美经典一区二区| 亚洲一区自拍偷拍| 国产美女一区二区| 欧美日韩黄色影视| 国产偷v国产偷v亚洲高清| 亚洲一区二区四区蜜桃| 国产一区不卡视频| 欧美三级一区二区| 国产精品视频一区二区三区不卡| 夜夜嗨av一区二区三区网页| 国产美女视频一区| 欧美美女激情18p| 成人欧美一区二区三区黑人麻豆 | 性久久久久久久| 成人福利视频网站| 日韩亚洲欧美综合| 欧美日韩你懂得| 日韩影视精彩在线| 国产麻豆视频一区二区| 在线精品观看国产| 国产色综合一区| 蜜桃视频第一区免费观看| 99久久精品国产麻豆演员表| 精品国产一区a| 日本伊人色综合网| 欧美在线免费观看视频| 国产亚洲一区二区三区| 久久精品二区亚洲w码| 欧美色视频在线观看| 专区另类欧美日韩| 国产91综合一区在线观看| 日韩欧美电影在线| 日韩电影免费一区| 欧美性猛交xxxxxx富婆| 亚洲精品美腿丝袜| 99re亚洲国产精品| 中文字幕一区二区三区在线播放| 国产精品资源在线看| 精品国产伦一区二区三区观看方式 | 久久精品水蜜桃av综合天堂| 日韩成人一级大片| 欧美日韩激情一区二区| 亚洲国产欧美在线| 欧美日韩亚洲高清一区二区| 一区二区三区四区亚洲| 一本大道av一区二区在线播放 | 国产69精品久久99不卡| 久久精品男人的天堂| 国产自产v一区二区三区c| 精品国产3级a| 国产成人免费视频网站高清观看视频|