아이가 코딩에러를 못잡고 잠을 못자네요
아시는분 봐주시길 부탁드립니다 ㅜ
// Create your variables here
var ground = createSprite(211, 409);
ground.setAnimation("ground_grass_1");
ground .scale = 2;
var bear = createSprite(40, 267);
bear.setAnimation("cuteanimals_bear_1");
bear.scale = 0.3;
// Create your sprites here
var x = 0;
function draw() {
x = randomNumber(1, 500) + 1;
// draw background
background("skyblue");
fill("orange");
rect(0, 314, 400, 100);
var x_velocity_of_bear = 3;
var y_velocity_of_bear = 0;
// update sprites
fill("black");
textSize(20);
text("Hello, I am a Bear!", 120, 50);
text("I love carrot and banana and I hate bugs!", 60, 75);
text("Press space to jump, and right to move!", 25, 100);
if (x <= 3) {
carrot();
} else if ((x >= 4 && x <= 10)) {
banana();
} else if ((x == 100)) {
x = 0;
}
if (keyWentDown("space")) {
bear.velocityY = bear.velocityY - x_velocity_of_bear;
}
if (keyDown("up")) {
bear.velocityY = -3;
bear.y = bear.y - x_velocity_of_bear;
}
if (keyDown("down")) {
bear.y = bear + x_velocity_of_bear;
}
if (keyDown("left")) {
bear.x = bear.x - x_velocity_of_bear;
}
if (keyDown("right")) {
bear.x = bear.x + x_velocity_of_bear;
}
if ((bear.y) <= 120) {
bear.velocityY = y_velocity_of_bear;
}
if (bear.y >= 320) {
bear.velocityY = y_velocity_of_bear;
}
drawSprites();
var score = 0;
var health = 100;
if (health < 0) {
background("black");
fill("green");
textSize(50);
text("Game Over!" , 40, 200);
}
if (score >= 50) {
background("black");
fill("green");
textSize(50);
text("You Win!" , 40, 200);
}
fill("white");
textSize(20);
text("Health:", 280, 30);
text (health, 350, 30);
text("Score:", 280, 50);
text (score, 350, 50);
if (health == 0) {
background("black");
textSize(20);
text("You lose...", 200, 200);
}
if (score > 100) {
background("black");
textSize(20);
text("You win!", 200, 200);
}
if (bear.isTouching(banana)) {
score = score + 1;
}
if (bear.isTouching(carrot)) {
score = score + 1;
}
if (bear.isTouching(bug)) {
health = health - 1;
}
drawSprites();
}
function carrot() {
var food7 = createSprite(700, randomNumber(150, 300));
food7.setAnimation("carrot_1");
food7.scale = 0.7;
food7.velocityX = -2;
}
function banana() {
var food1 = createSprite(900, randomNumber(150, 300));
food1.setAnimation("banana_1_1");
food1.scale = 0.1;
food1.velocityX = -2;
}
function bug() {
var bug = createSprite(1000, randomNumber(150, 300));
bug.setAnimation("bug");
bug.scale = 0.15;
bug.velocityX = -2;
}
첫댓글 chatgpt에 소스 붙여넣기 하고 오류 찾아달라고 하세요
이미 해결 하셨을 것 같지만, 원하는 동작이 무엇이고 오류 동작이 무엇인지는 적어 주셔야 디버깅에 도움이 됩니다.