We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm new to programming in general, still a beginner, so please excuse the "rough look" of my code and how nonsensical it might appear...still learning....
I'm trying to create my own mini game, and keep it as simple as possible. I'm trying to make the ball that's falling from the top of the screen collide with my image (myDinoHat), where it touches the plate. Basically, I'm trying to make it so that if the ball falling touches the plate, it will disappear and count as a point. How can I do this? Also, I'm trying to make the ball falling from the sky become an image instead, like the image of a skull for example. I got the ball to fall alright, and my image to act as a mouse moving to catch something, but everything else is not working in my favor. May I have some help on this, please? Any help would be greatly appreciated! The code is attached:
Answers
ok, use dist() to check for collision
if so say reset y-pos to random (-44,-22); and x to random(0,width);
also say score ++; then - make a global var score
===
to have an image instead of the ball just load the image and display it where the ball is
dist:::
if (dist(ballx, bally, platex,platey)<51) {
score++;
bally=random(-62, -14);
}
Place this eg. Where you move the ball
Thank you for taking the time to respond! Well, I decided that I need to try and just make everything simple by just having the ball make contact with the plate as a collision. Simply put, I'm trying to make the ball hit the plate as if it were like ping pong. I thought that would be easy to do, by making my image (myDinoHat) become the paddle. But my screen keeps going blank for some reason. Any help on this please?
pastebin.com/p8fB0vbf
we had it that you used paddleX instead of dinox
the same goes for the entire function ballHitPaddle !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
new version (since I don't have the images, there are some changes regarding this, e.g. the function image1 and some checks for null
sorry for answering late, I was busy