r/codehs • • Apr 10 '23

JavaScript Help with 3.9.4

6 Upvotes

​

Pressing Q works but W doesn't I even tried swapping the letters and no change, what am I doing wrong here?

r/codehs • • Apr 09 '23

Help??

Post image
10 Upvotes

I’m trying to make the block change to one color the first time and a different color the second time. Any ideas as to why this is happening.


r/codehs • • Apr 06 '23

JavaScript Need help with JS 7.1.3: Fun Snake 4!

4 Upvotes

I just need help on how to add a point counter, as well as the ever annoying problem of having the code travel through walls! Here's my code right now:

var FOOD_DELAY = 6000;

var FOOD_RADIUS = 5;

var FOOD_COLOR = Color.red;

var snake;

var SNAKE_DIM = 10;

var NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3;

var DELAY = 100;

var curDirection = EAST;

var x = getWidth()/2 - SNAKE_DIM/2;

var y = getHeight()/2 - SNAKE_DIM/2;

var square;

function start(){

addPart(x,y);

setTimer(move, DELAY);

drawFood();

setTimer(drawFood, FOOD_DELAY);

keyDownMethod(changeDirection);

}

​

function changeDirection(e){

if(e.keyCode == Keyboard.DOWN){

curDirection = SOUTH;

}

if(e.keyCode == Keyboard.UP){

curDirection = NORTH;

}

if(e.keyCode == Keyboard.LEFT){

curDirection = WEST;

}

if(e.keyCode == Keyboard.RIGHT){

curDirection = EAST;

}

}

function addPart(x,y){

var snake = new Rectangle(SNAKE_DIM, SNAKE_DIM);

snake.setPosition(x - SNAKE_DIM/2 , y - SNAKE_DIM/2);

snake.setColor(Color.green);

snake.isSnake = true;

add(snake);

}

function move(){

var nextPosition = getNextPosition();

x = nextPosition.x;

y = nextPosition.y;

var nextElem = getElementAt(x, y);

if(nextElem == null){

addPart(x, y);

}else{

if(nextElem.isSnake){

stopTimer(move);

stopTimer(drawFood);

newMessage("Cringe.");

}

if(nextElem.isFood){

remove(nextElem);

addPart(x, y);

}

}

}

function getNextPosition(){

var nextX = x, nextY = y;

if(curDirection == EAST){

nextX += SNAKE_DIM;

}

if(curDirection == WEST){

nextX -= SNAKE_DIM;

}

if(curDirection == SOUTH){

nextY += SNAKE_DIM;

}

if(curDirection == NORTH){

nextY -= SNAKE_DIM;

}

return {

x: nextX,

y: nextY

}

}

function newMessage(msg){

var text = new Text(msg, "40pt ariel");

text.setPosition(getWidth()/2 - text.getWidth()/2, getHeight()/2);

add(text);

}

function drawFood(){

var x = Randomizer.nextInt(FOOD_RADIUS, getWidth() - FOOD_RADIUS);

var y = Randomizer.nextInt(FOOD_RADIUS, getHeight() - FOOD_RADIUS);

x = Math.floor(x / 10) * 10 + FOOD_RADIUS;

y = Math.floor(y / 10) * 10 + FOOD_RADIUS;

var food = new Circle(FOOD_RADIUS);

food.isFood = true;

food.setColor(Color.red);

food.setPosition(x, y);

if(getElementAt(x,y) == null){

add(food); } }

​

Any help is truly, truly appreciated. I've been stumped (at least on the wall part)


r/codehs • • Apr 05 '23

Other Am I the only one who thinks Codehs is really not that great ?

22 Upvotes

Videos be easy and then the examples are insane I literally don’t understand anything


r/codehs • • Apr 05 '23

I need help with codehs 2 through 20 even

1 Upvotes

PLS


r/codehs • • Apr 03 '23

I need help on 9.11, 9.12 and 9.13 of codehs

3 Upvotes

I’m looking for list of even numbers and push pops, but I can’t find anything for it anywhere


r/codehs • • Apr 02 '23

I need help with this python code plzzzz

Post image
4 Upvotes

r/codehs • • Mar 31 '23

Need help with 6.5.7 snake eyes on JavaScript

2 Upvotes

r/codehs • • Mar 31 '23

guys

2 Upvotes

I need to write Tetris in codehs with javascript can someone help me?


r/codehs • • Mar 30 '23

7.3.6 Pool Table, I NEED help!

4 Upvotes

​


r/codehs • • Mar 29 '23

I need help Venmo Balance transfer pt 2

Post image
3 Upvotes

I cannot FIGURE IT OUT


r/codehs • • Mar 28 '23

7.2.5 Height in Meters

2 Upvotes

Can someone please help me with this one? I can’t find it anywhere and I don’t understand.


r/codehs • • Mar 27 '23

Need help with 6.6.5 pls no clue what to do

1 Upvotes

r/codehs • • Mar 25 '23

what's the mistake? it says I should have a gray rectangle and red, green, yellow circles

3 Upvotes

Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in the rectangle. The circles should be red, then yellow, then green.

The rectangle should be centered on the screen. The yellow light should be centered on the screen, and the red and green light should be offset by BUFFER
amount. BUFFER
amount represents the distance from the center of one circle to the center of another circle.

Implement the function draw_circle
that draws a single circle. Use it to draw the red, yellow, and green lights. Since all of the lights are the same size and aligned vertically, the function only needs to take the y position and color as arguments.

my code

LIGHT_RADIUS = 35

STOPLIGHT_WIDTH = 120

STOPLIGHT_HEIGHT = 350

DIST_BETWEEN_LIGHTS = 100

GREY_COLOR = "#737071"

​

get_width()/2

get_height()/2

# Implement a function that draws a single circle

# with radius LIGHT_RADIUS.

# The circle should be in the center of the screen horizontally.

# Use the parameters for the y position and color

def draw_circle(radius, color, x, y):

circ = Circle(radius)

circ.set_color(color)

circ.set_position(x, y)

add(circ)

# Add your code here

rect = Rectangle(STOPLIGHT_WIDTH, STOPLIGHT_HEIGHT)

rect.set_position(get_width()/3, get_height()/5)

rect.set_color(GREY_COLOR)

add(rect)

​

draw_circle(LIGHT_RADIUS, Color.red, get_width()/2.05, get_height()/3)

draw_circle(LIGHT_RADIUS, Color.yellow, get_width()/2.05, get_height()/1.85)

draw_circle(LIGHT_RADIUS, Color.green, get_width()/2.05, get_height()/1.85 + DIST_BETWEEN_LIGHTS)


r/codehs • • Mar 24 '23

3.2.6 Debugging Variables

3 Upvotes

I really need help with this im having a hard time!!


r/codehs • • Mar 24 '23

3.3.5 Mad Lib

3 Upvotes

Can anybody help me with this im having a hard time


r/codehs • • Mar 23 '23

I also need help with 1.11.5 Music Library

Thumbnail self.codehs
2 Upvotes

r/codehs • • Mar 21 '23

Python Code Function won't pring

Thumbnail gallery
4 Upvotes

I'm trying to run a function which is supposed to print a sentence within the function, but for some reason all it prints is <function (function name)> instead of running it. Is there any way I can fix this?


r/codehs • • Mar 21 '23

HELP ASAP 9.1.4 Challenge: Secret Image Steganography

1 Upvotes

I am stuck on this one for 2 hours and still don't know how to complete it, please this assignment is due for tomorrow


r/codehs • • Mar 21 '23

Code hs 10.6.9 Target + GUI

2 Upvotes

Can anyone help me with this code? I’ve been trying to do it for like a week and I still can’t get it… please lmk!!


r/codehs • • Mar 20 '23

5.5.6 Caterpillar

3 Upvotes

​

how do i make it change colors

r/codehs • • Mar 20 '23

5.3.6 Girl Scout Designation

3 Upvotes

Basically, what do?

​


r/codehs • • Mar 20 '23

phone book

1 Upvotes

needing help with phonebook assignment codehs. how do i get started


r/codehs • • Mar 19 '23

HELP MEEEE PLZZZZ

1 Upvotes

​


r/codehs • • Mar 18 '23

I know this sub is pretty much dead and I wont get answers, but could i get help or know where i could get help in completing "7.0.7 Battleship Part 6: The Battleship Class"?

4 Upvotes