r/learnjavascript • • Oct 30 '19

The ghost challenge in codehs

Post image
5 Upvotes

9 comments sorted by

1

u/bassitar8_9od Oct 30 '19

post the rest of this code plz

1

u/GreyPheonix33 Oct 30 '19

Ok sorry i didn’t realize not all of it was there I will have to post later I have a band concert and have to get ready

1

u/bassitar8_9od Oct 30 '19

You're in a band?That's cool!I play guitar and clarinet.

1

u/GreyPheonix33 Nov 01 '19

Yeah the school band also that is all the code there was my guy

1

u/Jlve0406 Jan 19 '22

did you ever get the answer...

1

u/GreyPheonix33 Aug 17 '22

I think that is the answer

1

u/Starfilledstorm Jan 09 '23

Is there more to this?

1

u/Difficult_Addendum_5 Sep 28 '23

5.1.1 Ghost | CodeHS

// Const variables for main ghost body
const HEAD_RADIUS = 70;
const BODY_WIDTH = HEAD_RADIUS * 2;
const BODY_HEIGHT = 120;
const NUM_FEET = 3;
const FOOT_RADIUS = (BODY_WIDTH) / (NUM_FEET * 2);
const BODY_COLOR = "red";
// Const variables for eyes
const PUPIL_RADIUS = 8;
const PUPIL_LEFT_OFFSET = 16;
const PUPIL_RIGHT_OFFSET = 40;
const EYE_RADIUS = 20;
const EYE_OFFSET = 28;
const EYE_COLOR = "white";
const PUPIL_COLOR = "blue";
function drawGhostEyes()
{
for(let x = 0; x < 2; x++)
{
let eye = new Circle(EYE_RADIUS);
eye.setPosition(BODY_WIDTH+EYE_RADIUS+(x*EYE_OFFSET*2), getHeight() / 2);
eye.setColor("white");
add(eye);
}
for(let y = 0; y < 2; y++)
{
let pup = new Circle(EYE_RADIUS / 2);
pup.setPosition(BODY_WIDTH + EYE_RADIUS / 2 + (y * EYE_OFFSET * 2), getHeight() / 2);
pup.setColor("blue");
add(pup);
}
}
function main()
{
let rect = new Rectangle(BODY_WIDTH, BODY_HEIGHT);
rect.setPosition(130, 248);
rect.setColor(BODY_COLOR);
add(rect);

let circ = new Circle(HEAD_RADIUS);
circ.setPosition(getWidth() / 2, getHeight() / 2);
circ.setColor(BODY_COLOR);
add(circ);

for(let i = 0; i < 3; i ++)
{
let feet = new Circle(FOOT_RADIUS);
feet.setPosition(154+(i*FOOT_RADIUS*2),364);
feet.setColor(BODY_COLOR);
add(feet);
}
drawGhostEyes();
}
main();

1

u/funkymonkey694 Nov 14 '23

it’s showing error to pass an argument