Computer Science Canada Box movement help |
Author: | 1337.Billy [ Wed Jun 08, 2005 6:49 pm ] | ||
Post subject: | Box movement help | ||
Hey everyone, I beleive this is my first post so Hi. Im working on my final project for computer class. Im making a paddle ball game. I need help moving the box, and im not sure how to make it move My code do far:
Thanks in advance whoever helps me |
Author: | vagyb [ Wed Jun 08, 2005 9:10 pm ] |
Post subject: | |
well u are moving only the X2 coordinate, u have to move both the x1 and x2 coordiantes (when u draw the box). and cls too |
Author: | 1337.Billy [ Thu Jun 09, 2005 2:34 pm ] | ||
Post subject: | |||
Thanks for helping i was able to make the paddle move but now im not sure how to get a ball in there and make it hit the sides and bounce and such. I have looked at the collision detection tutorials but have not been successful, so can someone please help. My new code is below:
Thanks to who helps me |
Author: | 1337.Billy [ Thu Jun 09, 2005 8:39 pm ] |
Post subject: | |
Anyone, please I really need help on this one part. |
Author: | MysticVegeta [ Thu Jun 09, 2005 8:44 pm ] |
Post subject: | |
Press F10 -> Music.PlayFile -> Look at example number 2. You will see they have a star bouncing off the edges. I cant tell you anything more because i haven;t taken Grade 10 math trignometry. (cos, tan, sin) |
Author: | vagyb [ Thu Jun 09, 2005 8:49 pm ] |
Post subject: | |
well easiest thing for u would be to use whatdotcolor so first get a picture of ur ball, import it in turing, give X and Y variables, give Height and Width variables to it. then use whatdotcolor so for example if whatdotcolor (x, y) = red then put code here for w/e direction u want to go. to make the bounce angle the same as real life is very hard, so i'm guessing u should just do a 45 degree angle bounce off. |
Author: | 1337.Billy [ Thu Jun 09, 2005 8:55 pm ] |
Post subject: | |
Well, Im just drawing a circle but i want it to bounce of any where in the screen and off the paddle and somehow get a counter to keep track of their score, Im not trying to make anyone giving me source code just some help on these parts. |
Author: | Cervantes [ Fri Jun 10, 2005 3:20 pm ] | ||
Post subject: | |||
Assuming you've got x and y coordinates of the ball that correspond to the centre of the ball:
Mind you, that whatdotcolour collision isn't too good. If you want to improve it, you should use a for loop to check a range of values a certain distance below the ball.y. The values checked range from (ball.x - ball.radius, ball.y) to (ball.x + ball.radius), ball.y). |
Author: | 1337.Billy [ Fri Jun 10, 2005 3:40 pm ] |
Post subject: | |
Well this is diffucult stuff for me because our teacher neer taught us this stuff. Well ive tried to add a ball but look what happens. O and im not sure how to do that range thing. |
Author: | Drakain Zeil [ Fri Jun 10, 2005 3:55 pm ] |
Post subject: | |
My teacher didn't teach a lot of stuff like this... a lot of this you need to think about for yourself. Thinking is more or less asking a lot of questions of how things would work, and answering them - the problem is, answers lead to questions! Not that I'm saying you don't think, I'm saying people today in general don't criticaly think. |
Author: | 1337.Billy [ Fri Jun 10, 2005 7:48 pm ] |
Post subject: | |
I know what you mean but I/ve tried everything but I dont know how to get that flickering out of my program. |
Author: | 1337.Billy [ Sat Jun 11, 2005 9:39 am ] |
Post subject: | |
Here is an update on what i have done, I just need help with 4 things. Why does it it flicker, why doesnt the background stay black, should i stay with whatdotcolour collision detection and how can i tabulate a score when the ball hits the paddle. What I have done so far is attached below |
Author: | Cervantes [ Sat Jun 11, 2005 9:48 am ] |
Post subject: | |
I haven't downloaded your project, because I didn't feel like downloading 300kb (dial-up) and because that's about the size of a zipped turing-made .exe. If that's the case, you'll get more/better help by posting the source code. 1.) I suspect it flickers because you're using View.Update incorrectly or not at all. Check the walkthrough for a link. 2.) Have you got colourback (black) in conjunction with cls? Note that the colourback should be outside the loop. 3.) If whatdotcolour is working for you, I suggest you stay with it. On the other hand, it wouldn't hurt to try another way, for educational purposes. 4.) If the ball hits the paddle (if statement with whatdotcolour to detect this collision) then add one to the score. The score is a global variable. |