【无标题】通过webrtc通道传送远程自动绘图脚本

这篇博客介绍了一种通过WebRTC通道来传送远程自动绘图脚本的方法。首先启动画图应用,设置画布大小为1920x1080,然后创建一个JavaScript玩家对象,该对象包含速度、方向、位置等属性,并实现了移动鼠标、获取向量等功能。接着,定义了边界并绘制,最后进入游戏环节,当玩家位置超出边界时游戏结束。整个过程展示了如何利用编程控制远程绘图。
摘要由CSDN通过智能技术生成

通过webrtc通道传送远程自动绘图脚本typingSpeed(0,0); //type as fast as possible
layout("GB"); //language layout

//Start paint
// waitLEDRepeat(NUM);
press("GUI R");
delay(1000);
type("mspaint\n"); //no need to press ENTEr, encoded in '\n'
delay(2000);
//Maximize paint
press("GUI UP"); 
//Set canvas size to 1920x1080
press("CTRL E"); //open properties
delay(2000);
type("1920");
press("TAB");
type("1080");
press("ENTER");
//create JavasCript player object
var player = {
    speed: 4.0/1920.0,
    dir: 0.0,
    pos: {"x": 0.5, "y":0.5},
    border: {"lx": 0.2, "ly":0.2, "hx": 0.8, "hy": 0.8},
    pressed: false,
    step : function() {
        v = this.getVec();
        this.pos.x += v.x;
        this.pos.y += v.y;
        if (this.pos.x < this.border.lx || 
            this.pos.x > this.border.hx ||
            this.pos.y < this.border.ly ||
            this.pos.y > this.border.hy) 
            return false;
        this.moveMouseToPos();
        return true;
    }
    getVec : function() {
        x = Math.sin(this.dir) * this.speed;
        y = Math.cos(this.dir) * this.speed;
        return {"x": x, "y":y};
    }
    moveMouseToPos : function() {
        moveTo(this.pos.x, this.pos.y)
    }
    toggleButton : function() {
        if (this.pressed) button(BT1);
        else button(BTNONE);
        
        this.pressed = !this.pressed;
    }
};
//draw border (delays only for visual fx)
delay(500);
moveTo(player.border.lx, player.border.ly);
button(BT1);
moveTo(player.border.hx, player.border.ly); delay(500);
moveTo(player.border.hx, player.border.hy); delay(500);
moveTo(player.border.lx, player.border.hy); delay(500);
moveTo(player.border.lx, player.border.ly); 
button(BTNONE);

//game, exits when player position is outside border (absolute mouse positioning)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值