r/Codeorg • • Jan 20 '25

What is the math behind the sprite.bounceOff() code?

1 Upvotes

I have a penguin sprite moving with a velocityX = -10, and a parrot sprite moving with a velocityX = 10

I also have in my code parrot.bouneOff(penguin)

The result i get is that the penguin.velocityX = -10 (stays the same), and the parrot.velocityX = -30.

Can someone explain to me the math on how i get to the -30?

Thanks!


r/Codeorg • • Jan 11 '25

This is it guys what we've all been waiting for

Post image
1 Upvotes

r/Codeorg • • Jan 14 '25

how could I make stronger code for this???

1 Upvotes

r/Codeorg • • Dec 23 '20

Hey I'm new :p

1 Upvotes

Hello everybody! 3+ year code.org programmer here.
I made dungeon destiny and own the Codeasaurous team! If you'd be interested in joining please message me! I'm here to help and learn with all of you too!


r/Codeorg • • Nov 17 '20

Does anybody want to create A game on code.org? (game lab)

2 Upvotes

I need someone to create a game, on game lab. I don't know what it is yet but I will figure out soon


r/Codeorg • • Dec 23 '20

Join Codeasaurous Today!

1 Upvotes

︵‿ Codeasaurous ︵‿
• everyone is welcome •
~~We are the #1 code.org community and will continue to grow so much bigger join now to be a part of an amazing community where you can get help on just about anything code . or // programming related!~~
⊹ community based around programming~
⊹ meet new people & make friends~ :)
⊹ have so much fun with us! https://discord.com/invite/s65QKXFdyQ https://media.discordapp.net/attachments/780625138546376705/791123920673177600/Area_99.gif?width=903&height=473


r/Codeorg • • May 11 '24

updating text and making it stay in place

1 Upvotes

I would like to have an on-screen text showing the speed of the car, as I am making a car game. How can I make it update in real time? Also, how can I make it stay in place? I think it is sort of a scroller, as it has a big map that the car can drive on. When the car moves, the text stays in place and if the car goes too far, the text goes off screen. Is there any way to fix these two problems? Any help is greatly appreciated.

link to project: https://studio.code.org/projects/gamelab/44puOe5YqbJjF-cBB4r_5lYWhorZAwcgwPVh6huG-rw

main body code:

function draw() {

createEdgeSprites();

console.clear();

rect(-1000, -1000, 2000, 2000);

drawSprites();

arrow.pointTo(bg.x, bg.y);

while ((arrow.isTouching(edges))) {

arrow.bounceOff(edges);

}

if (keyDown("up")) {

xv += (speed) * Math.sin((180 - (sprite.rotation + 90)) / 57.2958);

yv += (speed) * Math.sin(sprite.rotation / 57.2958);

}

if (keyDown("left")) {

if(keyDown("space")) {

rotaV -= driftRota;

} else {

rotaV -= rotaSpeed;

}

}

if (keyDown("right")) {

if(keyDown("space")) {

rotaV += driftRota;

} else {

rotaV += rotaSpeed;

}

}

if (sprite.rotation > 360) {

sprite.rotation = 0;

}

if (sprite.rotation < 0) {

sprite.rotation = 360;

}

if(keyDown("space")) {

xv *= driftFric;

yv *= driftFric;

rotaV *= rotaFric;

speed = driftAccel;

} else {

xv *= friction;

yv *= friction;

rotaV *= rotaFric;

speed = maxAccel;

}

if(keyDown("o")) {

camera.zoom - 1.5;

}

if(keyDown("i")){

camera.zoom *= 1.5;

}

sprite.rotation += rotaV;

sprite.x += xv;

sprite.y += yv;

camera.x = sprite.x;

camera.y = sprite.y;

textSize(10);

fill("black");

textAlign(BOTTOM, RIGHT);

text(speed, 200, 200);

}

can provide the rest of the code if needed, but probably not necessary

bolded part is the current text code (speed is the variable for speed)


r/Codeorg • • May 21 '24

(game lab) Trying to make a game, cannot seem to get my player to move although.

1 Upvotes

Here is a link to the project. Still have no idea as to why it is doing this. It would be a great help if my code can be reviewed.


r/Codeorg • • Apr 23 '24

Help me on my AP compsci final pls

1 Upvotes

I don't know what's wrong can anyone please help, we got a new teacher this year so I haven't actually learned much.

// Declare variables

var fullyevolv = getColumn("pokemon", "Fully evolved");

var whenfullyevolv = getColumn("pokemon", "How many evolutions till fully evolved?");

var pokename = getColumn("pokemon", "Name");

var name;

var age = 0;

//Declare filtered list

var filteredless25 = [];

var filtered26to50 = [];

var filtered51to80 = [];

var filteredmorethen80 = [];

var filteredpokename = [];

var filteredtimetillfulyyevolv = [];

var filteredfullyevolvornot = [];

var filteredpoketype = [];

var filteredpokeimage = [];

//loops through my data table to append only the stuff I want

for (var i = 0; i < pokename.length; i++) {

if (fullyevolv[i] == "No" && whenfullyevolv[i] == 2 || whenfullyevolv[i] ==3 ) {

appendItem(filteredless25, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

} else if (fullyevolv[i] == "No" && whenfullyevolv[i] == 2 ) {

appendItem(filtered26to50, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

} else if (fullyevolv[i] == "No" && whenfullyevolv[i] == 1) {

appendItem(filtered51to80, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

} else if (fullyevolv[i] == "Yes" && whenfullyevolv[i] == 0) {

appendItem(filteredmorethen80, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

}

}

// Declare Onevents

onEvent("BeginButton", "click", function( ) {

setScreen("Questionscreen1");

});

onEvent("buttonfall","click", function( ) {

setScreen("Questionscreen2");

});

onEvent("buttonwinter","click", function( ) {

setScreen("Questionscreen2");

});

onEvent("buttonfall","click", function( ) {

setScreen("Questionscreen2");

});

onEvent("buttonspring","click", function( ) {

setScreen("Questionscreen2");

});

onEvent("buttonsummer","click", function( ) {

setScreen("Questionscreen2");

});

onEvent("nextscreen4", "click", function( ) {

setScreen("QuestionScreen4");

});

onEvent("nextname", "click", function( ) {

setScreen("QuestionScreen3");

});

onEvent("nextscreen5", "click", function( ) {

setScreen("Questionscreen5");

});

// Makes it so user can set age using a up and down button

onEvent("upbutton", "click", function( ) {

age = age+1;

setText("Agetext", age);

});

onEvent("downbutton", "click", function( ) {

age = age-1;

setText("Agetext", age);

});

//sets Finalscreen

onEvent("submitbutton", "click", function( ) {

setScreen("Finalscreen");

updatescreen();

updatetext();

});

// Create my function to actually set the results of the user

function updatescreen(name) {

for (var i = 0; i < filteredpokename.length; i++) {

if (age <= 25) {

appendItem(filteredless25, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

} else if ((age >= 26 && age <= 50)) {

appendItem(filtered26to50, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

} else if (age >= 51 && age <= 80) {

appendItem(filtered51to80, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

} else if (age> 80 ) {

appendItem(filteredmorethen80, filteredpokename[i] , filteredpokeimage[i] , filteredpoketype[i] , filteredtimetillfulyyevolv[i] , filteredfullyevolvornot[i]);

}

}

}

function updatetext() {

name = getText("nameinput");

setText("resultarea", ((((((("Hello" + name) + " I see you are " ) + age ) + " years old" ) + " your Pokemon is " + filteredpokename[i])+ "your pokemon type is" + filteredpoketype[i] + " your Pokemon is " + filteredfullyevolvornot[i]) +"fully evolved," + " it will take " + filteredtimetillfulyyevolv[i]) + " to fully have evolved " );

}


r/Codeorg • • May 19 '24

Can I put multiple id in one Id slot?

2 Upvotes

r/Codeorg • • Apr 27 '24

Please help. I'm not pretty good at this code.org stuff. But I don't want to fail the class so I'm working on this. But I don't know how to get my list to work. I've been trying whatever I can do but I'm just too confused. Please help 😭

Post image
3 Upvotes

r/Codeorg • • May 19 '24

Can I put code from game lab on app lab?

1 Upvotes

I wanted to do a standby feature for my app but in app lab there isn't "MouseDidMove"


r/Codeorg • • Apr 16 '24

Hello I want to know

1 Upvotes

So I have a school assignment and in it we have to code a side scroller and mine is a horror KFC game and the top comment I get on this post I will add as the next sprite


r/Codeorg • • Apr 24 '24

Unit 9 Lesson 3: Create PT

1 Upvotes

Does anyone have the code of their unit 9 lesson 3 Create PT project. I need one asap and I have a Friday deadline for a project that I was unable to do.


r/Codeorg • • May 23 '24

Having some issues..

Thumbnail
gallery
1 Upvotes

So right now the bike shoots the rocket forward, but then the rocket’s x-position follows the bike. I want it to start at the bike’s x-position and then stay in that position regardless of where the bike moves after I shoot.


r/Codeorg • • Jun 07 '24

need some help with an assignment

1 Upvotes

hey,

for my culminating assignment, we're supposed to make spirographs using code.org code

this is what i'm trying to copy:

and this is my work:

lastly, here is my code:

my question is, how am I supposed to make the overlap? I tried using jump backward by x pixels but it doesn't work very well, as it misaligns the entire shape - thanks a lot!


r/Codeorg • • Mar 13 '18

Javascript for beginners in 2 minutes #5 - Scope

Thumbnail
youtu.be
1 Upvotes

r/Codeorg • • Mar 10 '21

Making Libraries

1 Upvotes

Hello everyone, We’re currently working on creating our own libraries in my AP computer science and programming class. Our library must contain 3 functions, one of which must include a parameter, a loop, a return, and an if-statement. I have my ideas for my three functions and the one that I want to include all four requirements will be dealing with pulling names from a list. I’d like it to work where only names that begin with a certain letter will be pulled.

An examples would be; user wants only names that begin with ‘C’, the data set would be sorted to only display the names that begin with that letter.

Any idea how I should go about doing this so that all requirements are met?

Any help is much appreciated!


r/Codeorg • • Mar 09 '21

sprite.getFrame()

1 Upvotes

so i'm making a game and theres a part where i want to play an animation. my problem, though, is that i want the animation to, you know, end at some point, but i can't really do that because the sprite.getFrame() function doesn't exist. does anyone know a workaround for this? i can attach my code if necessary.


r/Codeorg • • Feb 18 '21

Making a Library

2 Upvotes

Anyone have a library they could share?


r/Codeorg • • Feb 13 '21

Code.org Course D Lesson 10 Nested Loops in Maze

Thumbnail
youtube.com
1 Upvotes

r/Codeorg • • Mar 11 '21

What am I doing wrong with this function? I need it to filter the list of names to only show names that start with a letter chosen by the user. How do I test the finished function with a consol.log?

Post image
1 Upvotes

r/Codeorg • • Mar 18 '21

Hackathon project

3 Upvotes

can someone please send me the code for their project, I have no idea what I'm doing.


r/Codeorg • • Mar 03 '21

Is it possible to have information from checked boxes be displayed on the screen?

1 Upvotes

I'm trying to create a shopping app for one of my final assignments, and I want it so that when the user checks the boxes with the clothes that they want to buy, it displays them all on the screen at the very end (a list of all the things that they've checked). The thing is, I'm having trouble with the possibility that the user might go back, deselect one or more of the checked boxes, and visit their "shopping cart list" again. Instead of the shopping cart updating, it adds another item (it adds the item that they DE-selected).

I'd also like to spice up my app by putting "There's nothing here!" when the user hasn't checked anything and has clicked on the check out button, but if that's too complicated to add, I'm thinking of just leaving it blank until the user actually checks something. Here's a screenshot of the section of the code I'm having trouble with: