Canvas悟空推箱子

我不是費圓發表於2020-09-07

Canvas悟空推箱子

在這裡插入圖片描述

  “學如逆水行舟,不進則退”,工作之餘我總會瀏覽一些先進前端知識以增強自己的知識儲備,偶爾也會試著開發或模仿小遊戲、程式、app 。昨天在 站長之家 發現了這個遊戲,觸動很大,先是玩了一晚上,只過了13關,今天把註釋寫上了,擷取了前40關分享給大家,希望大家在玩耍之餘能抽出時間學習或瞭解前端,前端是門手藝,它會像筷子一樣離不開人們的生活。
  個人能力有限,只能解答博友們一些淺顯的問題,甚至不如百度百科及時、準確,如今前端就業形式一片大好,在一線城市薪資過萬,優秀的前端工程師只需要5年,就可以解決住房問題,讓父母老有所依。希望忙碌的你可以抽出時間多陪伴一下家人,家是自己唯一的港灣,承載著你所有的眷戀。

<!doctype html>
<html lang="en">
    <head>
    <meta charset="GB2312">
    <title>HTML5 canvas小人推箱子小遊戲</title>
    <style>
        *{
            margin:0px;
            padding:0px;
        }
        body{
            overflow:hidden;
        }
        .game{
            position: relative;
            width:560px;
            margin:20px auto;
        }
        .game #msg{
            position: absolute;top:0;
            font:18px/1 華文楷體,華文琥珀;
        }
        .game #btn{
            position: absolute;right:0;bottom:4px;
        }
    </style>
</head>
<body onkeydown="doKeyDown(event)">
    <div class="game">
        <canvas id="canvas" width="560" height="560"></canvas>
        <div id="msg"></div>
        <div id="btn">
            <input type="button" value="上一關" onClick="NextLevel(-1)">
            <input type="button" value="下一關" onClick="NextLevel(1)">
            <input type="button" value="重玩本關" onClick="NextLevel(0)">
            <input type="button" value="遊戲說明" onClick="showHelp()">
        </div>
    </div>
</body> 
<script>
    var can = document.getElementById("canvas");
    var msg = document.getElementById("msg");
    var cxt = can.getContext("2d");
    var w = 35,h = 35;
    var curMap;//當前的地圖
    var curLevel;//當前等級的地圖
    var curMan;//初始化小人
    var iCurlevel = 0;//關卡數
    var moveTimes = 0;//移動了多少次

    //預載入所有圖片
    var oImgs = {
        "block" : "https://img-blog.csdnimg.cn/20200907200323829.gif#pic_center",
        "wall" : "https://img-blog.csdnimg.cn/20200907200352103.png#pic_center",
        "box" : "https://img-blog.csdnimg.cn/20200907200329709.png#pic_center",
        "ball" : "https://img-blog.csdnimg.cn/20200907200309333.png#pic_center",
        "up" : "https://img-blog.csdnimg.cn/20200907200348854.png#pic_center",
        "down" : "https://img-blog.csdnimg.cn/20200907200334961.png#pic_center",
        "left" : "https://img-blog.csdnimg.cn/20200907200340792.png#pic_center",
        "right" : "https://img-blog.csdnimg.cn/20200907200344452.png#pic_center",
    }
    function imgPreload(srcs,callback){
        var count = 0,imgNum = 0,images = {};

        for(src in srcs){
            imgNum++;
        }
        for(src in srcs ){
            images[src] = new Image();
            images[src].onload = function(){
                //判斷是否所有的圖片都預載入完成
                if (++count >= imgNum)
                {
                    callback(images);
                }
            }
            images[src].src = srcs[src];
        }
    }
    var block,wall,box,ball,up,down,left,right;
    imgPreload(oImgs,function(images){
        //console.log(images.block);
        block = images.block;
        wall = images.wall;
        box = images.box;
        ball = images.ball;
        up = images.up;
        down = images.down;
        left = images.left;
        right = images.right;
        init();
    });
    //初始化遊戲
    function init(){
        //InitMap();
        //DrawMap(levels[0]);
        initLevel();//初始化對應等級的遊戲
        showMoveInfo();//初始化對應等級的遊戲資料
    }
    //繪製地板
    function InitMap(){
        for (var i=0;i<16 ;i++ )
        {
            for (var j=0;j<16 ;j++ )
            {
                cxt.drawImage(block,w*j,h*i,w,h);
            }
        }
    }
    //小人位置座標
    function Point(x,y){
        this.x = x;
        this.y = y;
    }
    var perPosition = new Point(5,5);//小人的初始標值
    //繪製每個遊戲關卡地圖
    function DrawMap(level){
        for (var i=0;i<level.length ;i++ )
        {
            for (var j=0;j<level[i].length ;j++ )
            {
                var pic = block;//初始圖片
                switch (level[i][j])
                {
                case 1://繪製牆壁
                    pic = wall;
                    break;
                case 2://繪製陷進
                    pic = ball;
                    break;
                case 3://繪製箱子
                    pic = box;
                    break;
                case 4://繪製小人
                    pic = curMan;//小人有四個方向 具體顯示哪個圖片需要和上下左右方位值關聯
                    //獲取小人的座標位置
                    perPosition.x = i;
                    perPosition.y = j;
                    break;
                case 5://繪製箱子及陷進位置
                    pic = box;
                    break;
                }
                //每個圖片不一樣寬 需要在對應地板的中心繪製地圖
                cxt.drawImage(pic,w*j-(pic.width-w)/2,h*i-(pic.height-h),pic.width,pic.height)
            }
        }
    }
    //初始化遊戲等級
    function initLevel(){
        curMap = copyArray(levels[iCurlevel]);//當前移動過的遊戲地圖
        curLevel = levels[iCurlevel];//當前等級的初始地圖
        curMan = down;//初始化小人
        InitMap();//初始化地板
        DrawMap(curMap);//繪製出當前等級的地圖
    }
    //下一關
    function NextLevel(i){
        //iCurlevel當前的地圖關數
        iCurlevel = iCurlevel + i;
        if (iCurlevel<0)
        {
            iCurlevel = 0;
            return;
        }
        var len = levels.length;
        if (iCurlevel > len-1)
        {
            iCurlevel = len-1;
        }
        initLevel();//初始當前等級關卡
        moveTimes = 0;//遊戲關卡移動步數清零
        showMoveInfo();//初始化當前關卡資料
    }
    //小人移動
    function go(dir){
        var p1,p2;
        switch (dir)
        {
        case "up":
            curMan = up;
            //獲取小人前面的兩個座標位置來進行判斷小人是否能夠移動
            p1 = new Point(perPosition.x-1,perPosition.y);
            p2 = new Point(perPosition.x-2,perPosition.y);
            break;
        case "down":
            curMan = down;
            p1 = new Point(perPosition.x+1,perPosition.y);
            p2 = new Point(perPosition.x+2,perPosition.y);
            break;
        case "left":
            curMan = left;
            p1 = new Point(perPosition.x,perPosition.y-1);
            p2 = new Point(perPosition.x,perPosition.y-2);
            break;
        case "right":
            curMan = right;
            p1 = new Point(perPosition.x,perPosition.y+1);
            p2 = new Point(perPosition.x,perPosition.y+2);
            break;
        }
        //若果小人能夠移動的話,更新遊戲資料,並重繪地圖
        if (Trygo(p1,p2))
        {
            moveTimes ++;
            showMoveInfo();
        }
        //重繪地板
        InitMap();
        //重繪當前更新了資料的地圖
        DrawMap(curMap);
        //若果移動完成了進入下一關
        if (checkFinish())
        {
            alert("恭喜過關!");
            NextLevel(1);
        }
    }
    //判斷是否推成功
    function checkFinish(){
        for (var i=0;i<curMap.length ;i++ )
        {
            for (var j=0;j<curMap[i].length ;j++ )
            {
                //當前移動過的地圖和初始地圖進行比較,若果初始地圖上的陷進引數在移動之後不是箱子的話就指代沒推成功
                if (curLevel[i][j] == 2 && curMap[i][j] != 3 || curLevel[i][j] == 5 && curMap[i][j] != 3)
                {
                    return false;
                }
            }
        }
        return true;
    }
    //判斷小人是否能夠移動
    function Trygo(p1,p2){
        if(p1.x<0) return false;//若果超出地圖的上邊,不通過
        if(p1.y<0) return false;//若果超出地圖的左邊,不通過
        if(p1.x>curMap.length) return false;//若果超出地圖的下邊,不通過
        if(p1.y>curMap[0].length) return false;//若果超出地圖的右邊,不通過
        if(curMap[p1.x][p1.y]==1) return false;//若果前面是牆,不通過
        if (curMap[p1.x][p1.y]==3 || curMap[p1.x][p1.y]==5)
        {//若果小人前面是箱子那就還需要判斷箱子前面有沒有障礙物(箱子/牆)
            if (curMap[p2.x][p2.y]==1 || curMap[p2.x][p2.y]==3)
            {
                return false;
            }
            //若果判斷不成功小人前面的箱子前進一步
            curMap[p2.x][p2.y] = 3;//更改地圖對應座標點的值
            //console.log(curMap[p2.x][p2.y]);
        }
        //若果都沒判斷成功小人前進一步
        curMap[p1.x][p1.y] = 4;//更改地圖對應座標點的值
        //若果小人前進了一步,小人原來的位置如何顯示
        var v = curLevel[perPosition.x][perPosition.y];
        if (v!=2)//若果剛開始小人位置不是陷進的話
        {
            if (v==5)//可能是5 既有箱子又陷進
            {
                v=2;//若果小人本身就在陷進裡面的話移開之後還是顯示陷進
            }else{
                v=0;//小人移開之後之前小人的位置改為地板
            }
        }
        //重置小人位置的地圖引數
        curMap[perPosition.x][perPosition.y] = v;
        //若果判斷小人前進了一步,更新座標值
        perPosition = p1;
        //若果小動了 返回true 指代能夠移動小人
        return true;
    }
    //判斷是否推成功
    //與鍵盤上的上下左右鍵關聯
    function doKeyDown(event){
        switch (event.keyCode)
        {
        case 37://左鍵頭
            go("left");
            break;
        case 38://上鍵頭
            go("up");
            break;
        case 39://右箭頭
            go("right");
            break;
        case 40://下箭頭
            go("down");
            break;
        }

    }
    //完善關卡資料及遊戲說明
    function showMoveInfo(){
        msg.innerHTML = "第" + (iCurlevel+1) +"關 移動次數: "+ moveTimes;
    }
    //遊戲說明
    var showhelp = false;
    function showHelp(){
        showhelp = !showhelp;
        if (showhelp)
        {
            msg.innerHTML = "用鍵盤上的上、下、左、右鍵移動小人,把箱子全部推到小球的位置即可過關。箱子只可向前推,不能往後拉,並且小人一次只能推動一個箱子。";
        }else{
            showMoveInfo();
        }
    }

    //克隆二維陣列
    function copyArray(arr){
        var b=[];//每次移動更新地圖資料都先清空再新增新的地圖
        for (var i=0;i<arr.length ;i++ )
        {
            b[i] = arr[i].concat();//連結兩個陣列
        }
        return b;
    }

//地圖,可修改
var levels=[];
levels[0]=[
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,2,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0],
[0,0,0,0,1,1,1,3,0,3,2,1,0,0,0,0],
[0,0,0,0,1,2,0,3,4,1,1,1,0,0,0,0],
[0,0,0,0,1,1,1,1,3,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,2,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];

levels[1]=[
[0,0,0,0,0,0,0,0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,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];


levels[40]=[
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0],
[0,0,0,0,1,1,1,1,1,0,0,0,1,0,0,0],
[0,0,0,0,1,0,2,2,0,3,1,0,1,0,0,0],
[0,0,0,0,1,0,1,2,5,0,0,0,1,0,0,0],
[0,0,0,1,1,0,5,2,1,3,0,1,1,0,0,0],
[0,0,0,1,0,3,0,0,3,0,0,1,0,0,0,0],
[0,0,0,1,0,0,0,1,1,0,4,1,0,0,0,0],
[0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
</script>
</html>

  程式碼開源,但需要有一定JS語音基礎方可閱讀。我明白“ 授人以魚不如授人以漁 ”的道理,所以程式碼中常常只留下自定義註釋,方便大家修改,但不能憑此參透其中的奧妙,我並沒有藏拙,好學的人自然會想辦法尋找答案,自學也是人生的一門必修課。


推薦閱讀以下內容:

Canvas線條動畫
CSS旋轉魔方
JS迷你鍵盤
CSS逼真小象

相關文章