PHP 的跳一跳 - V2EX
qinrui
V2EX    PHP

PHP 的跳一跳

  •  
  •   qinrui Dec 31, 2017 7505 views
    This topic created in 3060 days ago, the information mentioned may be changed or developed.
    水平很烂,瞎写的,见笑。

    <?php

    function jump() {
    sleep(2.5);//延迟 2.5 秒,音乐盒、便利店、井盖等站 2 秒加分
    $screenShell = "cd D:\&adb shell /system/bin/screencap -p /sdcard/screenshot.png&adb pull /sdcard/screenshot.png d:jumper/screenshot.png";
    exec($screenShell);//截图

    $i=imagecreatefrompng("d:jumper/screenshot.png");//读取图片
    $point=array();
    for ($y=400;$y<imagesy($i);$y++) {//从第 400 行开始,避开上部内容
    for ($x=0;$x<imagesx($i);$x++) {//横向扫描
    $rgb = imagecolorat($i,$x,$y);//取得颜色
    $point["now"]["r"] = ($rgb>>16) & 0xFF;
    $point["now"]["g"] = ($rgb>>8) & 0xFF;
    $point["now"]["b"] = $rgb & 0xFF;
    if(isset($point["last"]["r"])){
    if(!isset($point["x"]["a"])){
    if( abs($point["now"]["r"]-$point["last"]["r"])>1
    or abs($point["now"]["g"]-$point["last"]["g"])>1
    or abs($point["now"]["b"]-$point["last"]["b"])>1
    ){
    $point["x"]["a"]=$x;
    if(imagesx($i)/2>$x){
    $point["direction"]="left";
    }else{
    $point["direction"]="right";
    }
    $point["a"]=$point["last"];
    }
    }else{
    if($point["now"]==$point["a"]){
    $point["x"]["b"]=$x-1;
    break;
    }
    }
    }
    $point["last"]=$point["now"];
    }
    if(isset($point["x"])){
    break;
    }
    }

    $param["left"] = 3750;
    $param["right"] = 3100;
    $time = pow((abs(imagesx($i)/2-($point["x"]["a"]+$point["x"]["a"])/2)/imagesx($i)),1)*$param[$point["direction"]];

    if($time<400){
    $time+=($param[$point["direction"]]/300);
    }
    $time = round($time,0);
    echo "direction:".$point["direction"];
    echo "\nx.a:".$point["x"]["a"];
    echo "\nx.b:".$point["x"]["b"];
    echo "\ntime:".$time."\n";
    $touchShell = "cd D:\&adb shell input swipe 50 250 250 250 ".$time;
    exec($touchShell);
    imagedestroy($i);
    jump();
    }

    jump();
    2 replies    2018-01-02 17:42:04 +08:00
    xiaome
        1
    xiaome  
       Dec 31, 2017
    城会玩,编程语言补全大赛么。
    medz
        2
    medz  
       Jan 2, 2018
    有一个意见给你,能不能把你的代码格式化一下?
    About     Help     Advertise     Blog     API     FAQ     Solana     3805 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 36ms UTC 04:33 PVG 12:33 LAX 21:33 JFK 00:33
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86