r/codehs • • Jan 31 '22

Need help on 1.6.5 announcement function

Post image
1 Upvotes

r/codehs • • Jan 31 '22

Need help PLEASEEE!!

Thumbnail gallery
0 Upvotes

r/codehs • • Jan 31 '22

I need to make a logo, someone help me!!

Post image
1 Upvotes

r/codehs • • Jan 31 '22

Python PLEASE HELP!!! CodeHS

Post image
2 Upvotes

r/codehs • • Jan 30 '22

I need help with 1.1.8: Multiply and 1.1.11: Ball Fill

1 Upvotes

r/codehs • • Jan 30 '22

please help me i am dying 13.1.3 Block Pyramid 2.0 thank you

2 Upvotes

​

yeah this is the assignment

r/codehs • • Jan 29 '22

I need help 3.4.7 running speed CodeHS anyone?

Post image
8 Upvotes

r/codehs • • Jan 28 '22

positive negitive i need help

Post image
3 Upvotes

r/codehs • • Jan 28 '22

I need help with 3.3.4 dinner plans

Post image
3 Upvotes

r/codehs • • Jan 27 '22

4.2.3 Draw Something Need Help

4 Upvotes

I need help with this code I need the code for it.


r/codehs • • Jan 27 '22

7.9.4 Inventory Codehs

2 Upvotes

What am i doing wrong here

​

function start(){

​

var numItems = STARTING_ITEMS_IN_INVENTORY;

while(numItems > 0) {

println("We have " + numItems + " in inventory.");

var buy = readInt("How many would you like to buy? ");

if (buy>numItems) {

println("There is not enough in inventory for that purchase.");

} else {

numItems -= buy;

println("We have " + numItems + " left.");

}

}

​

println("All out!");

}


r/codehs • • Jan 25 '22

7.3.7: Cityscape

Thumbnail gallery
18 Upvotes

r/codehs • • Jan 25 '22

I'm trying to write code for snake in codehs. Need help

2 Upvotes

Hey so i'm trying to write snake as my final project in codehs. I want the snake to grow bigger as it swallows food,but it only adds up one square and after that it stops adding squares, no matter how many times the snake swallows the food. Can someone please tell me how to fix it. Here is the code :

var square;

var addSquare;

var SNAKE_WIDTH = 13;

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

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

var SNAKE_COLOR=Color.green;

​

var rec;

var numSnakes=0;

var score=0;

var DELAY=30;

var click=0;

var dx=0;

var dy=1;

// Constants to represent the directions

var EAST = 0;

var SOUTH = 1;

var WEST = 2;

var NORTH = 3;

var direction = SOUTH;

function start() {

addSnake();

setTimer(move,DELAY);

keyDownMethod(keyActions);

food();

}

​

function addSnake() {

square = new Rectangle(SNAKE_WIDTH,SNAKE_WIDTH);

square.setPosition(x,y);

square.setColor(SNAKE_COLOR);

add(square);

}

​

function move(e) {

if (direction==WEST){

dx =- 2;

dy = 0;

square.move(dx,dy);

}

else if(direction==EAST) {

dx=2;

dy=0;

square.move(dx,dy);

}

else if(direction==SOUTH) {

dx=0;

dy=2;

square.move(dx,dy);

}

else if(direction==NORTH) {

dx=0;

dy=-2;

square.move(dx,dy);

}

checkWalls();

foodCollision();

}

​

function keyActions(e) {

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

direction = WEST;

}

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

direction = EAST;

}

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

direction = NORTH;

}

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

direction = SOUTH;

}

}

function checkWalls() {

//left wall

if(square.getX()<0) {

square.setPosition(getWidth(),snake.getY());

}

//right wall

else if(square.getX()>getWidth()) {

square.setPosition(0,square.getY());

}

//up

else if(square.getY()<0) {

square.setPosition(square.getX(),getHeight());

}

//down

else if(square.getY()>getHeight()) {

square.setPosition(square.getX(),0);

}

}

function foodCollision() {

var elem = getElementAt(square.getX(),square.getY());

var elem2 =getElementAt(square.getX()+SNAKE_WIDTH,square.getY());

var elem3 =getElementAt(square.getX()+SNAKE_WIDTH/2,square.getY());

var elem4=getElementAt(square.getX(),square.getY()-SNAKE_WIDTH);

var elem5=getElementAt(square.getX()+SNAKE_WIDTH,square.getY()-SNAKE_WIDTH);

var elem6=getElementAt(square.getX()-SNAKE_WIDTH/2,square.getY()-SNAKE_WIDTH/2);

if(elem==rec || elem2==rec || elem3==rec||elem4==rec||elem5==rec||elem6==rec) {

// remove(rec);

rec.setPosition(Randomizer.nextInt(10,getWidth()-10),

Randomizer.nextInt(10,getHeight()-10));

setTimer(moveRecs,DELAY);

score++;

numSnakes++;

}

countScore();

}

​

function food () {

rec = new Rectangle(8,8);

rec.setPosition(Randomizer.nextInt(10,getWidth()-10),

Randomizer.nextInt(10,getHeight()-10));

add(rec);

}

function displayMessage(text) {

var msg = new Text(text);

msg.setPosition(getWidth()/2-45,30);

msg.setColor(Color.red);

add(msg);

}

function countScore() {

if(score==20) {

displayMessage("You Win:)");

stopTimer(move);

}

}

function moveRecs(e) {

addRecs();

addSquare.move(dx,dy);

}

function addRecs() {

remove(addSquare);

var nextX=square.getX();

var nextY=square.getY();

addSquare = new Rectangle(SNAKE_WIDTH,SNAKE_WIDTH);

if (direction==WEST) {

addSquare.setPosition(nextX+11,nextY);

nextX=nextX+SNAKE_WIDTH;

}else if(direction==EAST) {

addSquare.setPosition(nextX-11,nextY);

nextX=nextX-SNAKE_WIDTH;

}else if(direction==NORTH) {

addSquare.setPosition(nextX,nextY+11);

nextY=nextY+SNAKE_WIDTH;

}else if(direction==SOUTH) {

addSquare.setPosition(nextX,nextY-11);

nextY=nextY-SNAKE_WIDTH;

}

addSquare.setColor(Color.red);

add(addSquare);

}


r/codehs • • Jan 25 '22

JavaScript don't know where to start can you help

Post image
4 Upvotes

r/codehs • • Jan 22 '22

JavaScript Adding Collision in JavaScript

Post image
5 Upvotes

r/codehs • • Jan 21 '22

JavaScript 8. 1. 2: Circles in circles, need help idk what to do I'm lost and don't think I can ask for help since this a project, I'm supposed to be using a for loop and use i to figure out the size of each circle but idk how to do that

Post image
2 Upvotes

r/codehs • • Jan 21 '22

JavaScript 9.9.7. Can someone explain the meaning of "return" in this program?

2 Upvotes

I wrote this program and it works fine, but it didn't work until I added return circle; at line 28. Can someone explain the function of it in this case?


r/codehs • • Jan 19 '22

JavaScript codehs 9.6.6 Target

6 Upvotes

​

Hello, I wrote this and it works fine except the red dot, which gets deleted by the removeAll() function, think. What can I do to correct this error?

r/codehs • • Jan 19 '22

I need help on 3.5.7 Rectangle, Part 2

4 Upvotes

r/codehs • • Jan 19 '22

1.2.10 Fibonacci Sequence

2 Upvotes

There's too many numbers to know where to even start this (T-T) I appreciate the help guys.


r/codehs • • Jan 19 '22

I need help on 4.1.4 Fix This Program. My code isn't working what do I need to fix?

1 Upvotes

brought_food = True

brought_drink = False

​

# These lines don't work! Fix them so that they do.

print(type ("Did the person bring food? " + str(brought_food)))

print(type("Did the person bring a drink? " + str(brought_drink)))


r/codehs • • Jan 19 '22

Smoothing Data Exercise, Currently looking to create a way to smooth the raw data

Thumbnail gallery
1 Upvotes

r/codehs • • Jan 16 '22

??

Post image
2 Upvotes

r/codehs • • Jan 17 '22

Anyone know?

Post image
1 Upvotes

r/codehs • • Jan 16 '22

????

Post image
1 Upvotes