Your videos are amazing. They took me from knowing nothing to actually programming some stuff. Can you make a video on checking the distance between a rectangle and a circle? For example, in a brickbreaker game?
i figured out by myself how to make the colission detection for an array of ps as a challenge. I overrided the dist function with a custom of mine as a challenge. Now i need to add the physics of ellastic collitions to the system. And add a method to predict if theres a collision in the next frame to prevent jittering and missed events. Thank you for being a teacher of my internet school i love your videos.
This a video on Javascript, not Java. Everytime someone mixes the two, a recently graduated engineer dies. (Also color is a function of the library p5, no native from JavaScript. I recommend you to always have the reference of p5.js open : p5js.org/reference/)
I'm in the UK. 15 years ago I made it a habit to use US spelling in all development I did from then on apart from any visible UI content. It's probably saved me weeks of debugging effort since then!
as a Brazilian who doesn't speak any dialect of English natively I'm much happier with "color". It makes more sense from a pronunciation standpoint, I'd rather learn the word "color" than "colour".
ha nice dude. i love maths and i love coding, but i've just done front end websites for 10 years, i haven't needed to do triangle maths for ages. now im making a game with canvas and trying to remember how this all works - the distance and the triangle you drew just helped me link it up in my head, npnp lol. starting to think of crazy shit i can code now lol seeing the fkn world like the matrix 😂😂 i remember this when i used to do flash too lol
Hi mister Shiffman, i have been trying to figure out how, i could , check if and object is touching, a particular color, like in scratch software, if color red is touched ,then do something. thanks
if in case i dont wanna check if they are overlapping, i wanna check if they are colliding, i would need to make the distance the sum of the two radius, right?
Hi Daniel, really love your tutorials, I wanted to know if you have a walkthrough for the agent modelling example from nature of code. The example from the bottom window at 0:55 seconds into the video.
I sure enjoy being American and being able to say "Color" in my code and not getting error messages saying "Colour is not defined". (Also, when I type this, the "Colour" is underlined in red.)
thanks this video was very helpful i was trying to make my first game(it is very simple but still a game) but i couldn't figure out how to tell if two object collided, i tried a bunch of diferent things but nothing worked until now, yippee.
I recently started making my own platformer game but I’m struggling to code the collision for the platforms What would be the code for a rect not an a ellipse Edit: I know that the dist() works on rect but the majority of the time it would just pass write brought obviously
Hi there, I really appreciate your videos. But this is only helpful in the event that I am using a really easy shape like a circle. How could I test intersection between, say, a triangle and some random quadrilateral? Thanks.
Hey, loving all of your vides here during lock down. Building a tetris inspired game with stacking items in a certain orientaiton and wondered if you'd done a video explaining rotation of image sprites? i.e. when you rotate a rectangle (testing it with simple object right now), the world flips.. i.e. if I set my objects rotation using PI/2 it should rotate 90 degrees, which it does, but the x and y axis are also rotated.. Ideally all I need is a means to flip the visual asset as the geometry and the physics are find using the gravity information from the flappy bird tutorial and the collider scrips from this video. Any tips or pointers for spinning that image asset or animated sprite by 90 degrees?
Apologies, trying to get these all fixed up, can you file an issue here: github.com/CodingTrain/website/issues The code is buried somewhere in the repo.
Can you post the code you end up with for these videos? There's a glitch in the current p5 library that wasn't letting me translate objects, and I think there's another problem here, too. I've compared mine character for character, but I still can't get the change.Color function to work. I've commented it out and know it's specifically the function, but can't tell what's going on.
+Michelle Sherman This one is here. github.com/shiffman/Video-Lesson-Materials/tree/master/code_p5.js/6.9_p5.js_checking_objects_intersection_1 Yes, I know that translate() bug, it's been fixed in more recent versions of p5.js, if you are stuck on an older one, you can add push() as the first line of draw() and pop() as the last to fix it temporarily. Hope this helps!
If any1 knows the answer to my question please respond asap... can i import a image in getgraphics() and make just certain parts uncollidable, cuz i really dont know how to make an house with a collidable door... thanks
Would you mind asking at discourse.processing.org/! It's a better platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.
i think you are looking for ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-GY-c2HO2liA.html but there's a newer one! ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5Q9cA0REztY.html
@@TheCodingTrain can this be done in python? if so can you teach me please :( i need to make 1000 independent circles to change color when they interact with each other, AND they have to move in a random direction and speed as well. also, how can I make sure ithey maintain an 80% chance of touching each other. I'm new to this my mind is at capacity already hahaha. so far I've only managed tomake 1000 circles which are useless because they aren't independent from each other, so when I set them to motion they move together. :(
DamianTLG I found a way to do it, but it is kinda messy and works terrible. I used the dist() but I checked the X and Y separately so it checked in a square radius. It will detect multiple objects intersecting perfectly, but bouncing an object off of the square is a lot more difficult and sometimes doesn't work for the corners. But I managed to make it work for a rectangle any size you want, as long as it is thicker than the speed the 2 objects are touching each other.
@@funwithariyan7347 . I am happy to say that I was able to figured out/understand how to approach this problem a few days after posting this question. I code from time to time for fun always at a basic level with shiffmans books None the less, you have no idea how much I appreciate your response to my old question. I hope it helps someone just starting !
it just doesnt work for me i will give u the link sir, can u say the mistake hers the link - editor.p5js.org/Caleb2009/sketches/BRFDoC6Pj i just want the pink rect to touch the food to make it respawn again
Surekha i read your code and i think you don't understand how to use constructor function in JavaScript. For example in Pix.js - constructor(x, y, p) { this.x = 200 this.y = 200 this.p = 12 } Here why are you accepting arguments? you don't need to accept any argument here and then in sketch.js line number 36 - thePix = new Pix(this.x, this.y, this.p, this.p); First what is this.x, this.y ..??? and second your Pix class doesn't require any parameter. If i'm not wrong you are trying to create a snake game or something like that. If you wanna run first you have to learn how to walk. So my suggestion is go and learn JavaScript first and then come back and learn p5.js