Sketch 不会在家庭作业游戏作业中安全打开
Sketch won't open safe in homework game assignment
我不确定我是否正确理解了分配。
我试图将我的代码插入为其指定的 space 中,但草图仍然无法打开保险箱。不知道该怎么办。任何建议 wellcome.I 想知道我哪里做错了
这是我正在努力应对的挑战:
地区检察官 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>
I tried to insert my code in the space designated for it, but still the sketch does not makes open the safe
我不确定你说的打开保险箱是什么意思。我相信作业只是给你一个激励人心的故事,而不是字面意思。您的代码中没有保险箱,因此无法解锁任何东西。
让我印象深刻的一件事是你正在做这样的事情:
secureStorageComb_0 = (secureStorageComb_0 + 6);
这行代码 将 6 添加到 secureStorageComb_0
,但说明说要将变量设置为等于 6。请注意,说明明确指出您应该只使用=
运算符,而不是 +
运算符。
但无论如何,除了作业描述之外,我不认为会有一个可以解锁的保险箱。
我不确定我是否正确理解了分配。 我试图将我的代码插入为其指定的 space 中,但草图仍然无法打开保险箱。不知道该怎么办。任何建议 wellcome.I 想知道我哪里做错了 这是我正在努力应对的挑战:
地区检察官 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>
I tried to insert my code in the space designated for it, but still the sketch does not makes open the safe
我不确定你说的打开保险箱是什么意思。我相信作业只是给你一个激励人心的故事,而不是字面意思。您的代码中没有保险箱,因此无法解锁任何东西。
让我印象深刻的一件事是你正在做这样的事情:
secureStorageComb_0 = (secureStorageComb_0 + 6);
这行代码 将 6 添加到 secureStorageComb_0
,但说明说要将变量设置为等于 6。请注意,说明明确指出您应该只使用=
运算符,而不是 +
运算符。
但无论如何,除了作业描述之外,我不认为会有一个可以解锁的保险箱。