#Collision Detection Falling Game
116 messages · Page 1 of 1 (latest)
@cursive minnow I swear I have seen a video of Dan's where there is rain and you are catching the drops. Let me Google.
Here it is.
Same concepts. You just need to decide what it looks like.
Learning Processing Dan's book is very good. It's not a video but you will see some good starter ideas.
Ok tysm!
I don't do the rain catching in this processing course, but the section on object interaction with dist() coudl be useful! https://youtu.be/4JzDttgdILQ?t=16909
Choo choo! Welcome aboard to the world of creative coding! Join me in this beginner-friendly video series learning to code with Processing! https://thecodingtrain.com/tracks/learning-processing/processing
🚀 Watch this video ad-free on Nebula! https://nebula.tv/videos/codingtrain-beginners-guide-to-creative-coding-with-processing-full-course
W...
Thank you Dan, I’ll take a look on it
Let's say If I wanted to put a tally like a ratio for example: Caught: 2, Missed: 7 would I put a decision structure? how could I do this sorry I'm a little new but I've been working on some progress with Dan's book.
You need 2 variables. 1 to hold caught and 1 to hold missed.
Then you simply do the math.
Total = caught + missed.
Missed/total= percentage of missed.
Caught/total = percentage of caught.
Percentage of missed + percentage of caught = 100%
There is no decision involved. Just math.
theoretically at least 😉 built-in rounding might not agree with you on that 100% for certain ratios xD
True depending on the data type.
I think even then? 0.333333333333 get's rounded at some point I assume
not sure how doubles handle that, honestly never tried
RLLY?
So it was that easy..
Yep, don't overcomplicate things :D
sometimes things are just way easier than they seem
if you're using processing, you could just do it in the draw loop?
might be a bit inefficient though
by ratio like the image i sent u can see
everytime the catcher touches one object it adds up, and then if the object reachs to the bottom then it adds 1 to miss.
hold up lemme write a text rq
wdym display lol
as in, write this on the screen
?
you wanted to that no?
yes but like caught extacyl 2
and missed exactly 7
Like I want it start on zero ofc and then tally up to depending how much I caught and missed
yeah you can totally do that, just replace the 2 with the value of your caught variable, and the 7 with the value of the missed variable!
Gotcha!
If you use an int data type it will just drop any decimal numbers
You can do it 
Thank you! 🙏
You got this. Check in for advice.
@cursive minnow Here is how I do it in the game I am working on.java efficiency = (enemies_killed/enemy_count)*100;
I display it to the screen like this.java text("EFFICIENCY", column_1, row_3); text(int(efficiency), column_2, row_3);
I convert it to int() so it drops the decimals without rounding. Calculation is done with floats. You cannot get a percentage without being able to have .65. To do that you use a double or a float data type.

I see now thx!
What’s does row 3 and Columns for etc?
I basically did like every time I catcher something, I would do a ‘’if statement’s’
I will show you let me get on my laptop.
guessing those variables correlate to certain x and y values on the screen
Alr no worries take your time but
Yeah I just got confused 😅
column_1 = width/4+100;
column_2 = width*.750-250;
row_1 = height/4 + 100;
row_2 = height/4 + 150;
row_3 = height/2;
row_4 = height/4 + 200;
row_5 = height/2 + 50;```
@cursive minnow correct. I just named them instead of having confusing numbers.
Putting text on a screen is kinda trial and error.
Ok have a nice day.
U too
Just the function part inside the text confused me
Understandable. No biggie. Check back if you need help.
Will do 
Mick you know the rain drop game
How could I turn the catcher not from mouse x and y and into void key presses like left and right
I just wanna move the catcher catching rain drops not by mouse but by keys
save the x location of the basket in a global variable, then when a certain key is pressed, you either add or remove a bit from that variable. Then just draw the basket at a fixed y coordinate with that x variable
Can you show me an example i don’t get@it
@cursive minnow You want a switch statement nested in an if statement. java if(keyPressed){ switch(key){ case 'a' : move left break; case 's' etc.... } }
I'ma t work on my phone, but look up. keyPressed, keyCode and key in the processing reference. You will see how the keyboard inputs are used in Processing.
I will be home after 4pm EST. I will show you how I handle it in my game.
Also the above is not working code. I used words instead of expressions for understanding.
Ok Ty!
I’ll see you at 4 pm then I’ll prob need that help
@cursive minnow I am going to rake for a bit until it gets dark so I will have my phone but not my laptop. I will give you some thing to look at for a minute.
//Moves ship
void move(ArrayList<Actor> actors) {//argument is the ArrayList containing the ship and asteroids
if (keyPressed) {//boolean is true when any key is //pressed
switch(key) {//looks at WHAT key was pressed
case 'w':
case 'W'://north Character that moves up in a -y //direction. Will accept upper and lower //case letter. Each case down, left, etc.
y -= y_speed;
break;
case 's':
case 'S'://south
y += y_speed;
break;
case 'a':
case 'A'://east
x -= x_speed;
break;
case 'd':
case 'D'://west
x += x_speed;
break;
case 'q':
case 'Q'://northwest
x -= x_speed;
y -= y_speed;
break;
case 'e':
case 'E'://northeast
x += x_speed;
y -= y_speed;
break;
case 'z':
case 'Z'://northwest
x -= x_speed;
y += y_speed;
break;
case 'c':
case 'C'://northwest
x += x_speed;
y += y_speed;
break;
case 'x'://This is a button I can use to test a //method to see if it works before I //control it.
case 'X':
//Test method goes here
break;
case ' '://fire s_bullet. This is the space bar key
add_S_bullet();
break;
}
}
}```
I made some comments that explain what is going on. If you have any questions, I can explain in more detail.
Based on this you would only need cases for A and D east and west.
Ye[p
@amber oracle Maybe could you implement in the rain drop code?
be much easier to understnad
http://learningprocessing.com/examples/chp10/example-10-10-rain-catcher-game Could you maybe put this in an 'A' and 'D' key so I could understand because I'm a lil confused
So the catcher would be moved by A and D left and right
It is implemented. The ship is the rain catcher. Show me what you have coded so far.
I was you a year ago. I started with Learning Processing. First the PDF on line. I did end up getting a hard copy on Thrift Books.
Start with just a square. Learn different ways to move the square. This isn't an overnight process.
Start on Chapter 1 instead of 10.
ohh
I will do that rn,
If you have any questions about what you are reading I can help you if you are stuck, but just giving you the method won't necessarily help you understand.
I love this book.

@amber oracle could I see like your sound part? For the game
Because I wanna add some sounds to my game, every time I catch and then a sound when I miss to catch it
It is on my to-do list, but I haven't implemented anything. I have played with the sound examples but for a day. No digging in yet.
OH
Saturday I was working on getting it to save a score and display it back when the game is started
I have it working on the serial monitor.
Mhm i see
@cursive minnow I think I updated my repository. When I get something done I upload so I have the last working version.
Here is the repo.
https://github.com/mwilke19/Space_shooter
This is the source code if you want to look at it.
Score tab is there so I did upload what I accomplished.
??? If lc
I see
Thanks I'll work on that when I have the time