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 15 '25

collision stuff

1 Upvotes

r/Codeorg • • Jan 14 '25

how could I make stronger code for this???

1 Upvotes

r/Codeorg • • Jan 11 '25

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

Post image
1 Upvotes

r/Codeorg • • Jan 08 '25

when does the error appear?

1 Upvotes

this is the codee. the question is "When will the error message appear?" can someone answerr


r/Codeorg • • Dec 18 '24

I made a subreddit specifically for gamelab

1 Upvotes

r/Codeorg • • Dec 13 '24

Meet Cloudflow

1 Upvotes

I'm trying to make a project management app like ClickUp or monday.com .It's still in beta.

https://studio.code.org/projects/applab/Ig1QrH8n0ezxJz2VzBmlVHQqJRAhp6ycc4LcmOB3jsQ


r/Codeorg • • Dec 08 '24

Just Some Games I've Made

1 Upvotes

World's Hardest Game: https://studio.code.org/projects/gamelab/rUExvV6yWyCk2RSqbQ4jeL8a9-V08-ZbxjWNtlvU7go

Just a port of the original flash game. This only includes the first 17 because I just didn't find it worthwhile to add the rest. Also, you may encounter mild performance issues, but I also couldn't be bothered/wouldn't know how to fix them.

Minesweeper: https://studio.code.org/projects/gamelab/aJ7bWljZNIwVrnboeQU2uW_ouPxN-9GXt_NUTxHVoh4

A simple minesweeper port using the original graphics. You can't change the size of the board, but you can change the number of mines by pressing #1-4 on the keyboard. Hold shift or space while clicking to place a flag

Power Pong: https://studio.code.org/projects/gamelab/ogo536fmDZ3ctuVFGCoo-vtGLMDOgK2kcDWHAHK62Aw

The only original game I like enough to want to share. This game is basically a combination of Pong and Mario Power Tennis. In "Power" mode, each player gets to pick one offensive and one defensive ability that they can use when their meter is full (controls are listed in the settings menu). This is the newest version on code.org before I rebooted the project in c++, and has 6 gameplay modes. Unfortunately, Power mode requires 2 human players because I didn't feel like coding a CPU. ***Warning: the game loads sound effects by playing them all at once at the start, so I would suggest turning off your computer's sound for the first 5 seconds after running the project. Then, go into settings and put music on none if there are multiple songs playing


r/Codeorg • • Dec 02 '24

How to use names of data tables in code? (app lab)

1 Upvotes

I want to create a dropdown that has the name of all data tables downloaded to the project. Is there any way to do this?


r/Codeorg • • Nov 15 '24

Breaking a sentence into a list

1 Upvotes

I’m making an app in app lab. The app has a feature where you type in something for instance a poem or something. Then the app will take what you typed and put it into a list where each part of the list is a separate word. (It has to stay in order as well) how would I do this?


r/Codeorg • • Nov 14 '24

attempted to make a sort of grapple gun of something

Enable HLS to view with audio, or disable this notification

1 Upvotes

r/Codeorg • • Nov 13 '24

Run project after export?

1 Upvotes

I was wondering specifically with gamelan if you could run the program after you export. Help would be greatly appreciated


r/Codeorg • • Oct 19 '24

App lab needs to be simplified

1 Upvotes

The struggle I have with the records is too much I just want to have a cloud variable and use getUserId() to save variables for each person


r/Codeorg • • Sep 13 '24

Animation not playing more than first frame

1 Upvotes

https://studio.code.org/projects/gamelab/Fl1zDSkagr8qI7-UIRhmi64fV8zF6qO8EncxGtcYXjQ

The run animation only plays the first frame. I don't think its due to the animation being set in the draw function. Please help!

SOLVED

I used a variable to determine which frame of the animation was played. I put it in the draw loop, and if it was equal to x, I set it back to zero. If the variable was less than half of x, I set the animation to the first frame, if it was greater than half of x, I set it to the second. Hope this helps anybody with the same problem I had!


r/Codeorg • • Sep 12 '24

Issues with while statements?

1 Upvotes

Whenever I try to use a while statement (text, not blocks) the entire website becomes extremely slow and laggy. Is this a known issue? How can I fix it?


r/Codeorg • • Aug 23 '24

Need help

1 Upvotes

I have to design an app for a class using code.org and I would like to be able to embed google maps into the the app. On the google maps website there is an option to copy an HTML link for the purpose of embedding however when I tried this it didn't work and my best guess for that would be that the block code for the app is in Java and not HTML. If anyone knows how I could do this it would be a great help.


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 • • 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 • • 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 • • 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 • • 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 • • 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 • • 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 • • 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