茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    html5彈跳球示例代碼
    來源:易賢網(wǎng) 閱讀:1544 次 日期:2016-07-13 14:00:31
    溫馨提示:易賢網(wǎng)小編為您整理了“html5彈跳球示例代碼”,方便廣大網(wǎng)友查閱!

    彈跳球使用html5實現(xiàn),不必驚訝,使用html5完全可以實現(xiàn),具體的截圖及代碼如下,感興趣的朋友可以參考下哈,希望對大家有所幫助

    代碼如下:

    <html>

    <head>

    <meta charset=utf-8>

    <title>跳跳球</title>

    <script>

    //box

    var box_x=0;

    var box_y=0;

    var box_width=300;

    var box_height=300;

    //注意:定位球采用球的中心

    var ball_x=10;

    var ball_y=10;

    var ball_radius=10;

    var ball_vx=5;

    var ball_vy=3;

    var box_bound_left=box_x+ball_radius;

    var box_bound_right=box_x+box_width-ball_radius;

    var box_bound_top=box_y+ball_radius;

    var box_bound_bottom=box_y+box_height-ball_radius;

    //ball

    //context

    var ctx;

    function init()

    {

    ctx=document.getElementById('canvas').getContext('2d');

    ctx.lineWidth=ball_radius;

    ctx.fillStyle="rgb(200,0,50)";

    move_ball();

    setInterval(move_ball,100);//note

    }

    function move_ball()

    {

    ctx.clearRect(box_x,box_y,box_width,box_height);

    move_and_check();

    ctx.beginPath();

    ctx.arc(ball_x,ball_y,ball_radius,0,Math.PI*2,true);

    ctx.fill();

    ctx.strokeRect(box_x,box_y,box_width,box_height);

    }

    function move_and_check()

    {

    var cur_ball_x=ball_x+ball_vx;

    var cur_ball_y=ball_y+ball_vy;

    if(cur_ball_x<box_bound_left)

    {

    ball_vx=-ball_vx;

    cur_ball_x=box_bound_left;

    }

    if(cur_ball_x>box_bound_right)

    {

    ball_vx=-ball_vx;

    cur_ball_x=box_bound_right;

    }

    if(cur_ball_y<box_bound_top)

    {

    ball_vy=-ball_vy;

    cur_ball_y=box_bound_top;

    }

    if(cur_ball_y>box_bound_bottom)

    {

    ball_vy=-ball_vy;

    cur_ball_y=box_bound_bottom;

    }

    ball_x=cur_ball_x;

    ball_y=cur_ball_y;

    }

    </script>

    </head>

    <body onLoad="init()">

    <canvas id="canvas" width="400" height="400"/>

    </body>

    </html>

    更多信息請查看網(wǎng)頁制作
    易賢網(wǎng)手機網(wǎng)站地址:html5彈跳球示例代碼
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇剩?/div>

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)