Skip to content
The Chat Archive
gpt-3.5-turbo-0301· OpenAI WildChat-4.8M (AI2)

function scene1() { background(0); image(img1, width / 2, height / 2);//场景背景1 if…

  1. User

    function scene1() { background(0); image(img1, width / 2, height / 2);//场景背景1

    if (showImage1) {//左右键控制的变量,具体控制小人运动 if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) {//限制小人不走出画外 cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y);//一直到这里,作用同上 } if (showImage3) { text(currentText, width / 2, height * 0.8);//墙上提示词,不按时 }else if(showImage4){ image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8);//放大图,和缩小提示词 } if (showImg8) { //激活显示图片的开关 image(img8, width / 2, height / 2); } img7X = cRen.x; img7Y = cRen.y;//有关小人走路的变量,不动

    fill(255); text(text3, 1720, 350);//门上提示词 }

    function mouseClicked() { // 每次点击开关状态取反 showImg8 = !showImg8; textIndex = 0; textLoading = true; if (T > 0){ textFont(“Simsun”); textSize(20); text(“哈喽,还记得你的童年是什么样子的嘛?”,width * 0.7, height * 0.7); T– } }

    function mousePressed(){ T = 120; } 帮我修改这段代码使得点击鼠标后文字可以一直显示

  2. Assistant

    以下是修改后的代码,将mouseClicked()函数替换为mousePressed()函数即可实现一直显示文字:

    function scene1() { background(0); image(img1, width / 2, height / 2);

    if (showImage1) { if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y); }

    if (showImage3) { text(currentText, width / 2, height * 0.8); } else if (showImage4) { image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8); }

    if (showImg8) { image(img8, width / 2, height / 2); }

    img7X = cRen.x; img7Y = cRen.y;

    fill(255); text(text3, 1720, 350);

    if (T > 0) { textFont("Simsun"); textSize(20); text("哈喽,还记得你的童年是什么样子的嘛?", width * 0.7, height * 0.7); T--; } }

    function mousePressed() { showImg8 = !showImg8; textIndex = 0; textLoading = true; }

  3. User

    fill(255); text(text3, 1720, 350);

    if (T > 0) { textFont(“Simsun”); textSize(20); text(“哈喽,还记得你的童年是什么样子的嘛?”, width * 0.7, height * 0.7); T–; } }

    function mousePressed() { showImg8 = !showImg8; textIndex = 0; textLoading = true; }帮我修改这段p5.js的代码,使得再次点击鼠标后出现“童年所经历的一切,都会在时光里发酵成甜蜜的回忆。”这句话

  4. Assistant

    以下是修改后的代码,实现了再次点击鼠标后出现新的一句话:

    let T1 = 0; //用于计数,限制文字显示时间 let T2 = 0; //用于计数,限制新文字显示时间

    function scene1() { background(0); image(img1, width / 2, height / 2);

    if (showImage1) { if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y); }

    if (showImage3) { text(currentText, width / 2, height * 0.8); } else if (showImage4) { image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8); }

    if (showImg8) { image(img8, width / 2, height / 2); }

    img7X = cRen.x; img7Y = cRen.y;

    fill(255); text(text3, 1720, 350);

    if (T1 > 0) { textFont("Simsun"); textSize(20); text("哈喽,还记得你的童年是什么样子的嘛?", width * 0.7, height * 0.7); T1--; } else if (T2 > 0) { textFont("Simsun"); textSize(20); text("童年所经历的一切,都会在时光里发酵成甜蜜的回忆。", width * 0.7, height * 0.7); T2--; } }

    function mousePressed() { if (T1 === 0 && T2 === 0) { showImg8 = !showImg8; textIndex = 0; textLoading = true; T1 = 60; } else if (T1 === 0) { T2 = 60; } }

  5. User

    let T1 = 0; //用于计数,限制文字显示时间 let T2 = 0; //用于计数,限制新文字显示时间

    function scene1() { background(0); image(img1, width / 2, height / 2);

    if (showImage1) { if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y); }

    if (showImage3) { text(currentText, width / 2, height * 0.8); } else if (showImage4) { image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8); }

    if (showImg8) { image(img8, width / 2, height / 2); }

    img7X = cRen.x; img7Y = cRen.y;

    fill(255); text(text3, 1720, 350);

    if (T1 > 0) { textFont(“Simsun”); textSize(20); text(“哈喽,还记得你的童年是什么样子的嘛?”, width * 0.7, height * 0.7); T1–; } else if (T2 > 0) { textFont(“Simsun”); textSize(20); text(“童年所经历的一切,都会在时光里发酵成甜蜜的回忆。”, width * 0.7, height * 0.7); T2–; } }

    function mousePressed() { if (T1 === 0 && T2 === 0) { showImg8 = !showImg8; textIndex = 0; textLoading = true; T1 = 60; } else if (T1 === 0) { T2 = 60; } }帮我修改这段代码使得第一段文字出现后就不再出现

  6. Assistant

    以下是修改后的代码,将T1的初始值设为-1,点击鼠标时先判断T1是否为-1,如果是则执行显示文字的操作,并将T1设为60,这样可以保证第一段文字只显示一次:

    let T1 = -1; let T2 = 0;

    function scene1() { background(0); image(img1, width / 2, height / 2);

    if (showImage1) { if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y); }

    if (showImage3) { text(currentText, width / 2, height * 0.8); } else if (showImage4) { image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8); }

    if (showImg8) { image(img8, width / 2, height / 2); }

    img7X = cRen.x; img7Y = cRen.y;

    fill(255); text(text3, 1720, 350);

    if (T1 === 0) { T2 = 60; } else if (T1 > 0) { textFont("Simsun"); textSize(20); text("哈喽,还记得你的童年是什么样子的嘛?", width * 0.7, height * 0.7); T1--; } else if (T2 > 0) { textFont("Simsun"); textSize(20); text("童年所经历的一切,都会在时光里发酵成甜蜜的回忆。", width * 0.7, height * 0.7); T2--; } }

    function mousePressed() { if (T1 === -1) { showImg8 = !showImg8; textIndex = 0; textLoading = true; T1 = 60; } else if (T1 === 0) { T2 = 60; } }

  7. User

    let T1 = -1; let T2 = 0;

    function scene1() { background(0); image(img1, width / 2, height / 2);

    if (showImage1) { if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y); }

    if (showImage3) { text(currentText, width / 2, height * 0.8); } else if (showImage4) { image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8); }

    if (showImg8) { image(img8, width / 2, height / 2); }

    img7X = cRen.x; img7Y = cRen.y;

    fill(255); text(text3, 1720, 350);

    if (T1 === 0) { T2 = 60; } else if (T1 > 0) { textFont(“Simsun”); textSize(20); text(“哈喽,还记得你的童年是什么样子的嘛?”, width * 0.7, height * 0.7); T1–; } else if (T2 > 0) { textFont(“Simsun”); textSize(20); text(“童年所经历的一切,都会在时光里发酵成甜蜜的回忆。”, width * 0.7, height * 0.7); T2–; } }

    function mousePressed() { if (T1 === -1) { showImg8 = !showImg8; textIndex = 0; textLoading = true; T1 = 60; } else if (T1 === 0) { T2 = 60; } }帮我修改这段代码,使得第一段文字不再出现后,第二段文字可以指出现一次

  8. Assistant

    以下是修改后的代码,将T2的初始值设为-1,点击鼠标时先判断T1是否为-1,如果是则执行显示第一段文字的操作,并将T1设为60,如果T1为0,则执行显示第二段文字的操作并将T2设为60,这样可以保证第一段文字只出现一次,第二段文字只出现一次:

    let T1 = -1; let T2 = -1;

    function scene1() { background(0); image(img1, width / 2, height / 2);

    if (showImage1) { if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y); }

    if (showImage3) { text(currentText, width / 2, height * 0.8); } else if (showImage4) { image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8); }

    if (showImg8) { image(img8, width / 2, height / 2); }

    img7X = cRen.x; img7Y = cRen.y;

    fill(255); text(text3, 1720, 350);

    if (T1 === 0) { if (T2 === -1) { T2 = 60; } } else if (T1 > 0) { textFont("Simsun"); textSize(20); text("哈喽,还记得你的童年