Matlab 版 (精华区)

文件名是snake_run.m
以下是文件内容

while w<1;
    filll(t(1,:),t(2,:),'w');
    xV=t(1,1)+real(D);
    yV=t(2,1)+imag(D);
    xV=mod(xV,N);
    yV=mod(yV,N-1);
    pu=[xV;yV];
    qt=t(1,:)+t(2,:)*i;
    qt=qt-pu(1)-pu(2)*i;
    if min(abs(qt))<0.2;
        set(hf,'string','Game oVer')
        set(tx,'string','the snake is already dead')
        break;
        break;
    end    
    if xV+yV*i==Z;
        t=[pu,t];
        K=K+1;
        set(hd,'string',num2str(K))
        S=S+1;
        Z=round((N-1)*rand(1))+round((N-2)*rand(1))*i;
        py=t(1,:)+t(2,:)*i-Z;
        while min(abs(py))<0.2
            Z=round((N-1)*rand(1))+round((N-2)*rand(1))*i;
            py=t(1,:)+t(2,:)*i-Z;
        end
%         filll(real(Z),imag(Z),'r');
        filll(real(Z),imag(Z),rand(1,3));
    else
        t(:,2:end)=t(:,1:end-1);
        t(:,1)=pu;
    end
    filll2(t(1,:),t(2,:),'g');
    if St==0;
        break;
        break;
    end
    pause(tp);
end
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.326毫秒