我不确定我是否正确理解了这一说法。 我试图将代码插入为其指定的空间中,但是草图仍无法打开保险箱。不知道该怎么办。任何建议都很好。我想知道我在哪里做错了 这是我所面临的挑战:
地区律师Torvalds在Console City中享有崇高的公民地位, 法律的执行者。当然,他像他们来时一样歪。我受够了 Sleuth and Co的辛勤工作因他的贿赂和欠款而受到损害。让我们来拿这个 吸盘下来。我碰巧知道,托瓦尔兹(Torvalds)将他的罪魁祸首文件散布在 镇上有几个保险箱。我需要您通过打破规则来稍微弯曲规则 检索关键证据。
第一个保险箱在Torvald的办公室里。通过执行以下操作将其破解:
When any key is pressed:
- Make secureStorageComb_0 equal to 15
When any key is released:
- Make secureStorageComb_0 equal to 41
When the mouse button is released:
- Make secureStorageComb_0 equal to 6
When the mouse button is pressed:
- Make secureStorageComb_0 equal to 14
Whilst the mouse is being dragged:
- Make secureStorageComb_1 equal to 54
When the mouse button is pressed:
- Make secureStorageComb_1 equal to 34
When the mouse button is released:
- Make secureStorageComb_1 equal to 77
有许多调查此案的可能方法,但是您 应该只使用以下命令:
- The assignment operator aka. the equals sign !
//declare the variables
var secureStorageComb_0;
var secureStorageComb_1;
function preload()
{
//IMAGES WILL BE LOADED HERE
}
function setup()
{
createCanvas(512,512);
//initialise the variables
secureStorageComb_0 = 0;
secureStorageComb_1 = 0;
}
///////////////////EVENT HANDLERS///////////////////
//Add your code to these events to open the safe ...
function mouseMoved()
{
secureStorageComb_0 = 0;
secureStorageComb_1 = 0;
console.log("mouseMoved", mouseX, mouseY);
}
function mouseDragged()
{
secureStorageComb_1 = (secureStorageComb_1 + 54);
console.log("mouseDragged", mouseX, mouseY);
}
function mousePressed()
{
secureStorageComb_0 =(secureStorageComb_0 + 14);
secureStorageComb_1 =(secureStorageComb_1 + 34);
console.log("mousePressed");
}
function mouseReleased()
{
secureStorageComb_0 = (secureStorageComb_0 + 6);
secureStorageComb_1 = (secureStorageComb_1 + 77);
console.log("mouseReleased");
}
function keyPressed()
{
secureStorageComb_0 = (secureStorageComb_0 + 15);
console.log("keyPressed", key);
}
function keyReleased()
{
secureStorageComb_0 = (secureStorageComb_0 + 41);
secureStorageComb_1 = (secureStorageComb_1 + 86);
console.log("keyReleased", key);
}
///////////////DO NOT CHANGE CODE BELOW THIS POINT///////////////////
function draw()
{
//Draw the safe door
background(70);
noStroke();
fill(29,110,6);
rect(26,26,width-52,width-52);
//Draw the combination dial
push();
translate(200,height/2);
drawDial(200, secureStorageComb_0, 43);
pop();
//Draw the lever
push();
translate(width - 125,256);
drawLever(secureStorageComb_1);
pop();
}
function drawDial(diameter,num,maxNum)
{
//the combination lock
var r = diameter * 0.5;
var p = r * 0.6;
stroke(0);
fill(255,255,200);
ellipse(0,0,diameter,diameter);
fill(100);
noStroke();
ellipse(0,0,diameter*0.66,diameter*0.66);
fill(150,0,0);
triangle(
-p * 0.4,-r-p,
p * 0.4,-r-p,
0,-r-p/5
);
noStroke();
push();
var inc = 360/maxNum;
rotate(radians(-num * inc));
for(var i = 0; i < maxNum; i++)
{
push();
rotate(radians(i * inc));
stroke(0);
line(0,-r*0.66,0,-(r-10));
noStroke();
fill(0);
text(i,0,-(r-10));
pop();
}
pop();
}
function drawLever(rot)
{
push();
rotate(radians(-rot))
stroke(0);
fill(100);
rect(-10,0,20,100);
ellipse(0,0,50,50);
ellipse(0,100,35,35);
pop();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.js"></script>
答案 0 :(得分:0)
我尝试将代码插入为其指定的空间中,但是草图仍无法打开保险柜
我不确定打开保险柜是什么意思。我相信这项任务只是给您一个鼓舞人心的故事,而不是直言不讳。您的代码中没有安全密码,因此没有任何东西可以解锁。
一个让我着迷的事情是,你正在做这样的事情:
secureStorageComb_0 = (secureStorageComb_0 + 6);
这行代码在secureStorageComb_0
上加了 6 ,但是说明说要将该变量设置为6。请注意,这些说明特别指出您应该只使用{{1} }运算符,而不是=
运算符。
但是无论如何,除了任务说明之外,我认为没有一个可以解锁的保险柜。