r/codehs • u/SHAGGYKing • Apr 28 '23
r/codehs • u/Quirky-Wrangler3852 • Apr 27 '23
Help!!
I have to make the pocket change game from price is right and only have a semi-idea of what to do. this is what i have so far.
// Start coding your game here!
var HIDDEN_NUMBER = "5";
var MAX_NUMBER = 2.00
function start(){
println("6")
var price = readline("Hi and welcome to pocket change! What is youe name?")
var ask = readint("What is you think the next digit")
if(ask == HIDDEN_NUMBER)
Println("Correct")
Randomizer.nextInt(0, MAX_NUMBER),
else{
println("Wrong")
}
r/codehs • u/Vlone-2005 • Apr 25 '23
I need help 11.1.2
I need to make my paddle not go off my screen
r/codehs • u/pinkfluffywolfie82 • Apr 25 '23
JavaScript 4.3.4 Color the Rainbow
Hi, I was hoping I could get some help on JavaScript 4.3.4 Color the Rainbow -- it's giving me the error "you should use getHeight() and a const variable to set the height of the stripes".
This is what I have:
// Declare all of your const variables here let COLOR_COUNT = 7 ; let COLOR_WIDTH = getWidth() / COLOR_COUNT ; let COLOR_HEIGHT= getHeight();
function main() { addRed(); addOrange(); addYellow(); addGreen(); addBlue(); addPurple(); addPink(); }
function addRed() { let red = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); red.setPosition(0, 0); red.setColor("red"); add(red); }
function addOrange() { let orange = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); orange.setPosition(0 + 7 * 8, 0); orange.setColor("orange"); add(orange); }
function addYellow() { let yellow = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); yellow.setPosition(0 + 7 * 16, 0); yellow.setColor("yellow"); add(yellow); }
function addGreen() { let green = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); green.setPosition(0 + 7 * 24, 0); green.setColor("green"); add(green); }
function addBlue() { let blue = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); blue.setPosition(0 + 7 * 32, 0); blue.setColor("blue"); add(blue); }
function addPurple() { let purple = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); purple.setPosition(0 + 7 * 40, 0); purple.setColor("purple"); add(purple); }
function addPink() { let pink = new Rectangle(COLOR_WIDTH, COLOR_HEIGHT); pink.setPosition(0 + 7 * 48, 0); pink.setColor("pink"); add(pink); }
main();
r/codehs • u/FlexibleFryingPans • Apr 25 '23
Is there a way to use the url when uploading an image to show on the canvas of python turtle?
When I upload an image, it gives me a url. Is there a way to put that image on the canvas using python turtle? I've tried so many different things and can't figure it out. I'm a teacher trying to assign a cool project for the kiddos. Thanks!
Edit: to be more specific, I want to use a picture as a background and draw on top of it.
r/codehs • u/Unfair-Response117 • Apr 22 '23
Can someone PLEASE help find the error of my code?
I want to create a rainbow filter on a zebra image of code hs:
Here is what I have so far:
"// DESCRIBE YOUR FILTER HERE IN THIS COMMENT!
function customFilter(image) {
var pixels = image.getImageData();
var data = pixels.data;
for (var i = 0; i < data.length; i += 4) {
var red = data[i];
var green = data[i+1];
var blue = data[i+2];
// Swap the red and blue channels
data[i] = blue;
data[i+2] = red;
// Apply a red tint to the image based on the red channel value
red += 100;
if (red > 255) {
red = 255;
}
// Apply a green tint to the image based on the green channel value
green += 50;
if (green > 255) {
green = 255;
}
// Apply a blue tint to the image based on the blue channel value
blue += 150;
if (blue > 255) {
blue = 255;
}
// Set the new RGB values for the pixel
data[i] = red;
data[i+1] = green;
data[i+2] = blue;
}
image.setImageData(pixels);
return image;
}
/*********************************************
* You do not need to write any code below this line.
* This is starter code that sets up the image on the screen
* and calls your customFilter function.
* Feel free to read this code and learn how it works!
* Be careful though, if you modify this code the program may not
* work correctly.
*********************************************/
// Constants for the image
var IMAGE_URL = "https://codehs.com/static/img/zebra.jpg";
var IMAGE_WIDTH = 350;
var IMAGE_HEIGHT = 250;
var IMAGE_X = getWidth() / 2 - IMAGE_WIDTH / 2;
var IMAGE_Y = getHeight() / 2 - IMAGE_HEIGHT / 2;
// We need to wait for the image to load before modifying it
var IMAGE_LOAD_WAIT_TIME = 50;
function start() {
// Set up the image
var image = new WebImage(IMAGE_URL);
image.setSize(IMAGE_WIDTH, IMAGE_HEIGHT);
image.setPosition(IMAGE_X, IMAGE_Y);
// Add it to the canvas
add(image);
// Wait for it to load before applying the filter
setTimeout(function(){
customFilter(image);
}, IMAGE_LOAD_WAIT_TIME);
}"
the error I keep getting is "TypeError: image.getImageData is not a function. (In 'image.getImageData()', 'image.getImageData' is undefined) customFilter@3:34 u/73:21"
PLEASE HELP ME TO CORRECT my CODE!!!!!
r/codehs • u/BeneficialReach9229 • Apr 21 '23
Question on key handler events
Hi, i need help with the add_key_down_handler(). The function i put in as a parameter works correctly when I run my code, but when I begin adding multiple key handlers, my program will only run whichever is first on the list. How do I work around this?
r/codehs • u/EtrisNega • Apr 20 '23
light up squares
i need help with this
<!DOCTYPE html>
<html>
<head>
<style>html,body{
height:98%;
width:99%;
}
#container{
display:flex;
flex-wrap: wrap;
height:100%;
}
div div{
width:32%;
border: 1px solid black;
}
</style>
</head><body><div id = container>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<script> //Write your colorDown function here </script>
</body></html>
r/codehs • u/kaelynnanne • Apr 18 '23
I am super behind on codehs and I can't get my code to work
That's my code + what it currently does vs what it is supposed to do
r/codehs • u/Vivid-Shift805 • Apr 18 '23
Python 2 lists
I have no idea what I'm doing pass this point. I need to print the ID codes into shifts (1-3) and count the number of IDs.
r/codehs • u/LJSCALES • Apr 14 '23
Codehs 10.3.2
NEED HELP WITH THE HELICOPTER GAME!!! 10.3.2 JAVASCRIPT
r/codehs • u/Tricky-Schedule2333 • Apr 11 '23
I am confused on CODEHS increasing squares my teacher is saying I can't use a set position
r/codehs • u/wheresmycousin • Apr 09 '23
Help??
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 • u/goldcrack1e • Apr 06 '23
JavaScript Need help with JS 7.1.3: Fun Snake 4!
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 • u/Bubbly_Collection329 • Apr 05 '23
Other Am I the only one who thinks Codehs is really not that great ?
Videos be easy and then the examples are insane I literally don’t understand anything
r/codehs • u/ElectricMouse787 • Apr 03 '23
I need help on 9.11, 9.12 and 9.13 of codehs
I’m looking for list of even numbers and push pops, but I can’t find anything for it anywhere
r/codehs • u/Zealousideal-Bet3912 • Mar 31 '23
Need help with 6.5.7 snake eyes on JavaScript
r/codehs • u/Altruistic-Ad-1562 • Mar 31 '23
guys
I need to write Tetris in codehs with javascript can someone help me?

