Help with brick breaker!
Author |
Message |
Lounia
|
Posted: Mon Jun 07, 2010 8:38 pm Post subject: Help with brick breaker! |
|
|
What is it you are trying to achieve?
Making a brick breaker game.
What is the problem you are having?
1) I can't move the ball without having it get stuck.
2) I can't let the ball move by itself after pressing the up button.
3) Everything goes off screen and never comes back again.
Describe what you have tried to solve this problem
Google, turing handbook.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
4.1.1
Description: |
|
Download |
Filename: |
hjljt.t |
Filesize: |
3.06 KB |
Downloaded: |
204 Time(s) |
Description: |
|
Download |
Filename: |
hjljt.t |
Filesize: |
3.06 KB |
Downloaded: |
155 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cezna
|
Posted: Mon Jun 07, 2010 8:59 pm Post subject: Re: Help with brick breaker! |
|
|
The reason the ball is gettting stuck is because you are setting it to 19 every time before you have the if statement to move it up.
So it is actually going up, then going down again, you just can't tell because it's x co-ordinate isn't changing.
I would recommend using setscreen ("offscreenonly"), cls and View.Update (or View.UpdateArea), as this will eliminate the flashing that you see when running the program.
Also, you have the line
code: |
Input.KeyDown (chars)
|
multiple times, when it is only needed once, above all of the if statements.
To make the ball move by itself, you will need to have a variable for x velocity and y velocity, and you would add these values to the x and y co-ordinates every time you go through the loop, and set them to a certain value when the ball hits the paddle (setting y velocity to positive, I mean, and x velocity to a value that simulates a bounce).
As for the stuff going off screen, just set the ball to only move if it will not go off the edge, otherwise it's velocity is multiplied by a negative 1, making it rebound (and possibly some arbitrary transfer rate to determine speed lost in collisions).
|
|
|
|
|
|
Lounia
|
Posted: Mon Jun 07, 2010 9:14 pm Post subject: RE:Help with brick breaker! |
|
|
I don't think I understand what you mean by "setting it to 19 every time before I have the if statement to move it up".
What do I need to change?
Thanks for your help by the way, I appreciate it
|
|
|
|
|
|
copthesaint
|
Posted: Mon Jun 07, 2010 10:47 pm Post subject: Re: Help with brick breaker! |
|
|
:/ so the ball can equal 19 or 24 thats nice thats what he means.
|
|
|
|
|
|
supaphreek
|
Posted: Mon Jun 07, 2010 10:53 pm Post subject: RE:Help with brick breaker! |
|
|
I havent actually looked at the code but based on the post above, im assuming that all this is in a loop and the code above is what is in it....
Therefore when the loop starts, your saying f = 19... and if you press up, f = 24... the loop is done, and it begins again (bcz its a loop) so f = 19 again and then f = 24 if you press up. This continues BECAUSE you are declaring a value for f INSIDE the loop. What you actually need to do is set f = 19 outside the loop that way when they press f, it would go 24, 29, 34, 39 and so on
|
|
|
|
|
|
Cezna
|
Posted: Tue Jun 08, 2010 5:20 am Post subject: RE:Help with brick breaker! |
|
|
Every cycle of the loop, you have
You need to take this out of the loop and put it at the beginning.
By the way, copthesaint, how do you have the code show up in the proper format on your post like that?
Are you just individually tagging everything? (seems like a lot of work if you are)
|
|
|
|
|
|
Lounia
|
Posted: Tue Jun 08, 2010 7:13 am Post subject: RE:Help with brick breaker! |
|
|
Ah okay I see! Thanks guys, I'll give you some bits but I apologize; I don't have much so I can't give you a lot
|
|
|
|
|
|
Lounia
|
Posted: Tue Jun 08, 2010 12:39 pm Post subject: RE:Help with brick breaker! |
|
|
Okay when I change the code to setscreen ("offscreenonly"), the program won't start. What am I doing wrong?
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Tue Jun 08, 2010 12:41 pm Post subject: Re: Help with brick breaker! |
|
|
when you use offscreenonly, nothing gets drawn until you call View.Update
|
|
|
|
|
|
Cezna
|
Posted: Tue Jun 08, 2010 5:04 pm Post subject: RE:Help with brick breaker! |
|
|
You have to put View.Update after you draw everything, and cls before you draw everything (or after View.Update)
|
|
|
|
|
|
supaphreek
|
Posted: Tue Jun 08, 2010 10:14 pm Post subject: Re: RE:Help with brick breaker! |
|
|
Cezna @ Tue Jun 08, 2010 5:20 am wrote: Every cycle of the loop, you have
You need to take this out of the loop and put it at the beginning.
By the way, copthesaint, how do you have the code show up in the proper format on your post like that?
Are you just individually tagging everything? (seems like a lot of work if you are)
Hes using the Turing Syntax bbcode which starts off as
(syntax="Turing")
and ends
(/syntax)
replace the ( with [ and ) with ]
|
|
|
|
|
|
Cezna
|
Posted: Wed Jun 09, 2010 6:57 pm Post subject: RE:Help with brick breaker! |
|
|
Thanks supaphreek.
I recently found out how to do it by clicking 'quote' on a post with the syntax formatting in order to see the actually text and figure out what the tags were.
I have used it multiple times since figuring it out, but it usually use (code="Turing") and (/code), due partially to less typing required, but primarily due to the fact that I have to think about it every time I spell syntax (as evidenced to myself by the fact that every single time I used the word in this post, I spelled it wrong and had to go back and fix it)
|
|
|
|
|
|
|
|