Computer Science Canada how to make ball start on paddle. |
Author: | gergysun [ Tue Dec 04, 2007 9:18 pm ] |
Post subject: | how to make ball start on paddle. |
Heyu guys, ive changed my menu alot and it would be nice if the user to press spacebar to start the ball, with its beginning possition on the paddle...ive looked at other pong games, and most of them dont have it I was wondering of how to do so... Can anyone help me out? |
Author: | HeavenAgain [ Tue Dec 04, 2007 9:29 pm ] |
Post subject: | RE:how to make ball start on paddle. |
its really easy..... just add , if the input key down is space then your game code here, else if input key down is left, then move the ball + the paddle left, else if input key down is right, then move the ball + the paddle right, simple? yes! ![]() |
Author: | gergysun [ Tue Dec 04, 2007 9:54 pm ] |
Post subject: | Re: how to make ball start on paddle. |
ok, im moving the paddle with the mouse, does that make any difference..to what u just said? im not sure how to start off the Input.Keydown thing, concidering ive never looked at it before. what would i type? |
Author: | HeavenAgain [ Wed Dec 05, 2007 11:30 am ] | ||
Post subject: | RE:how to make ball start on paddle. | ||
Quote: ok, im moving the paddle with the mouse, does that make any difference..to what u just said? nope, no big difference
i copyed this straight from the f10 help, all you have to change is make the t into space, and replace "put "the T key is pressed" with your game code. and elsif check mouse's x position, and move your paddle + ball |
Author: | gergysun [ Wed Dec 05, 2007 2:37 pm ] |
Post subject: | Re: how to make ball start on paddle. |
![]() the only thing is that i have to hold down the space bar to continue the game...like what i mean is that the ball wont start until i press the spacebar (good) but i have to keep holding it for the game to run smoothly....im not sure if i explained that correctly or not... |
Author: | HeavenAgain [ Wed Dec 05, 2007 7:34 pm ] |
Post subject: | RE:how to make ball start on paddle. |
you have to keep on holding it? thats odd, you just have to add that if statment before the WHOLE game code, not somewhere in the game code So it acts as a "gate keeper" before the player can acually start the game, is that they must press space at the beginninng, before they enter the game, get what i mean? |
Author: | gergysun [ Wed Dec 05, 2007 8:29 pm ] |
Post subject: | Re: how to make ball start on paddle. |
well, i got it somewhat fixed..i dont have to hold up arrow anymore, but what is done now is when you press it, it resets the ball into the centre...what i want it to do it that when i start the game, the ball is on the paddle and i have to press up arrow to start the ball moving. Using your method, how would i do that? here is my code, if it makes u understand what i just said a bit better... Code edited out at OP's request. |
Author: | HeavenAgain [ Wed Dec 05, 2007 8:47 pm ] | ||
Post subject: | RE:how to make ball start on paddle. | ||
ok, i have no idea why the up arrow is there in the first place, i mean, you dont even need to use up arrow to play pong.... so.... errr ok, i wont look through your code, because i am lazy ![]()
|
Author: | gergysun [ Wed Dec 05, 2007 8:57 pm ] | ||
Post subject: | Re: how to make ball start on paddle. | ||
alright. And the reason i put the up arrow in there cause i 2 was lazy...to find the text for the spacebar ![]() and when u say mouse, u mean ( from my code) .......x - 40 and x + 40? so.. like this..?
|
Author: | HeavenAgain [ Wed Dec 05, 2007 9:11 pm ] |
Post subject: | RE:how to make ball start on paddle. |
nop nop nop , that doesnt give you anything, you are checking for where the mouse is, i think the code is mousewhere, and check if the x value of the mouse changed from the orginal paddle's position, get the idea? |
Author: | gergysun [ Wed Dec 05, 2007 9:22 pm ] | ||
Post subject: | Re: how to make ball start on paddle. | ||
sooo i use
and i dont understand what you mean by "check if the x value of the mouse changed from the orginal paddle's position" my paddle does not show up in my same spot everytime the game starts, it whereever ur cursor is on the window. |
Author: | HeavenAgain [ Wed Dec 05, 2007 10:02 pm ] |
Post subject: | RE:how to make ball start on paddle. |
OHH, well in that case... i have made some silly mistake in explainning... first, obviously you gotta draw out the stuffs.... and whenever mouse position changes, you have to update the paddle, if this makes more sense to you.... implement it in your code and see what happens; try first then if you dont understand then ask ![]() ![]() |
Author: | Nick [ Wed Dec 05, 2007 10:38 pm ] | ||
Post subject: | RE:how to make ball start on paddle. | ||
|
Author: | gergysun [ Thu Dec 06, 2007 3:21 pm ] | ||
Post subject: | Re: how to make ball start on paddle. | ||
ok, so do i put the key down thing before or after the mouswhere below? and what would i tpye for "mouse moved" in the below code?
Does oldy and oldx have to be present anywhere else in the code? |
Author: | HeavenAgain [ Thu Dec 06, 2007 5:26 pm ] |
Post subject: | RE:how to make ball start on paddle. |
if you are using mouse to play the game, there isnt much point for input key down, cept for the starting part (which i hope you get it) and as for the old and new x and y, you certain will live without the old, because you are simply drawing the paddle base on your mouse's x and y right? (thats how i understands it) so just check mouse where, and draw the paddle according to the x and y, simple as that |
Author: | gergysun [ Thu Dec 06, 2007 5:53 pm ] |
Post subject: | Re: how to make ball start on paddle. |
ok , i still dont get it... wouldnt the code have to involve the ball cordinates in any way..since what i want is u press a button to launch the launch when beginning game. so what would i put? oh and another thing... ive looked at the rectagnle collision tutorial but it doesnt work for me because i want the paddles to not go past my border...what do i do? |
Author: | HeavenAgain [ Thu Dec 06, 2007 6:10 pm ] |
Post subject: | RE:how to make ball start on paddle. |
yes, the ball moves with the paddle BEFORE the game starts, and for paddle passing the boarder, you gotta find out your window's size, and your paddle's size, and if it go below 0 then stop moving it... seriously man, you have to try out different things, asking lots of questions is great, but it wont get you anywhere if you dont try ![]() |
Author: | gergysun [ Thu Dec 06, 2007 6:45 pm ] | ||||||||
Post subject: | Re: how to make ball start on paddle. | ||||||||
is that what u mean? Ive tried it and it doesnt work, so there must be something wrong in there. and for the border tingy, lets say the window dimentions is
|
Author: | HeavenAgain [ Thu Dec 06, 2007 6:52 pm ] |
Post subject: | RE:how to make ball start on paddle. |
ok, im very ashamed to put this, but, i did some kind game like this around 2 years ago, and you can have a look at it, and see, http://compsci.ca/v3/viewtopic.php?p=118271#118271 bascailly what i did was press space bar, start the game, and before that you can move left and right with keyboard, you just have to imagine that, before game starts, the ball is always on top of the paddle, so ball and paddle are treated as one picture. and for your out of bound code.... arrr , think of it like, if it x and y is inside the window, 0 < x,y < max x and y. then it can move, else dont bother it |
Author: | gergysun [ Thu Dec 06, 2007 8:33 pm ] |
Post subject: | Re: how to make ball start on paddle. |
Wow, you have skill ! I cant do that good if my life depended on it ![]() |
Author: | HeavenAgain [ Thu Dec 06, 2007 9:35 pm ] |
Post subject: | RE:how to make ball start on paddle. |
Thank you, altho that is definitely not the way you should do it, there are a lot of better pong games in the turing submission. I just hope it helps you with the starting paddle thing, other than that, its just crap |
Author: | gergysun [ Thu Dec 06, 2007 9:47 pm ] |
Post subject: | Re: how to make ball start on paddle. |
lol, it aint crap..mine is crap and can u write what u said 2 posts earlier about the boreder thing in code? cause its kinda confusing and by the way, thank you so much for helping me ![]() ![]() |
Author: | HeavenAgain [ Thu Dec 06, 2007 9:58 pm ] | ||
Post subject: | RE:how to make ball start on paddle. | ||
something like that? if you got more question, just pm me, lets not spam the fourm back and forth :\ |
Author: | CodeMonkey2000 [ Thu Dec 06, 2007 10:56 pm ] |
Post subject: | Re: RE:how to make ball start on paddle. |
HeavenAgain @ Thu Dec 06, 2007 6:52 pm wrote: ok, im very ashamed to put this, but, i did some kind game like this around 2 years ago, and you can have a look at it, and see, http://compsci.ca/v3/viewtopic.php?p=118271#118271
This is offtopic, but wow that code was inefficient. I expect more from you HeavenAgain. |
Author: | HeavenAgain [ Fri Dec 07, 2007 11:35 am ] |
Post subject: | Re: how to make ball start on paddle. |
![]() ![]() |
Author: | gergysun [ Fri Dec 07, 2007 12:35 pm ] |
Post subject: | Re: how to make ball start on paddle. |
that doesnt matter, we all make mistakes...anyways, i did get the boundry paddle thingy to work... now i just need to get the press a button OR click button to start the ball. |
Author: | gergysun [ Fri Dec 07, 2007 5:51 pm ] | ||
Post subject: | Re: how to make ball start on paddle. | ||
ok, i got the border thing down pat ....ive tried to do the input keydown thing to start the ball on the ball, but it didnt work, so i tried using the mouse, i managed to get some of it working. here is what i have so far, for the mouse click thing. The only problem is that i cant figure out how to make the ball appear on the paddle then mouseclick and it launches. What do i do?
|
Author: | CodeMonkey2000 [ Fri Dec 07, 2007 9:49 pm ] |
Post subject: | RE:how to make ball start on paddle. |
You really need to do some independent thinking. We can't solve everything for you. Go through what should happen step by step. And then code it. |
Author: | gergysun [ Sat Dec 08, 2007 12:47 am ] |
Post subject: | Re: how to make ball start on paddle. |
k, im trying different things...and how would i do speed...like what i mean is, when the person hits the paddle 5 times then the speed of the ball increases, ive been reading through the tutorials of that and in order to do so, u have to type a hugwe kick "A" code. In there a shorter way? |