Author |
Message |
Misha
|
Posted: Fri Dec 23, 2005 10:14 am Post subject: game help |
|
|
hi i'm making a game called javanoid. if u never played it before u could try it out at [url]www.javanoid.com [/url] the trouble that i'm having is when u move the paddle at the start of the game the ball should move with it until u start the game. i did that for when u lose then the ball will go back on the paddle and move with it but i can't do the same when u just start the game. this is wat i have for when u lose
code: |
Function StickyBallDead(KeyAscii As Integer)
If KeyAscii = 97 And dead = True Then
paddle1.Move paddle1.Left - 200 'moves paddle left
ball1.Move ball1.Left - 400
ElseIf KeyAscii = 100 And dead = True Then
paddle1.Move paddle1.Left + 200 'moves paddle right
ball1.Move ball1.Left + 400
End If
End Function
|
this works only when u die but not at the beginning when the form loads.
i also have one more problem. to check if the ball hit the bricks i made a control array and put the coordinates of each one to see that if the ball hits between those coordinates than make the brick disappear. the problem with that is i made the ball measure from its radius so if the ball hits at the very corner of the brick the brick want disappear because it didn't touch the balls radius. is there any other way i could do it like in turing u use wat dot colour. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
pavol
|
Posted: Thu Dec 29, 2005 7:24 pm Post subject: (No subject) |
|
|
when you check for your collisions specify also something like this: if ballx + ballradius > brickx -brickradius and ballx + ballradius < brickx + brickradius then
do whatever
this should check that if the corner of the ball is anywhere in the brick it'll do something, so it shouldn't just skim the brick and miss it |
|
|
|
|
![](images/spacer.gif) |
Misha
|
Posted: Fri Dec 30, 2005 12:05 pm Post subject: (No subject) |
|
|
i have the exact same thing and it works except when the ball hits the corner of the block because u r stating that if the balls radius touches the corner of the block. this is the code i have
code: |
If (ball1.Top - 202 >= (block(0).Top - 495) And ball1.Top - 202 <= block(0).Top) And (ball1.Left + 202 >= block(0).Left And ball1.Left + 202 <= (block(0).Left + 1575)) Then
Call cmdBlock_Click(0)
ElseIf (ball1.Top - 202 >= (block(1).Top - 495) And ball1.Top - 202 <= block(1).Top) And (ball1.Left + 202 >= block(1).Left And ball1.Left + 202 <= (block(1).Left + 1575)) Then
Call cmdBlock_Click(1)
End If
If (ball1.Top - 202 >= (block(2).Top - 495) And ball1.Top - 202 <= block(2).Top) And (ball1.Left + 202 >= block(2).Left And ball1.Left + 202 <= (block(2).Left + 1575)) Then
Call cmdBlock_Click(2)
ElseIf (ball1.Top - 202 >= (block(3).Top - 495) And ball1.Top - 202 <= block(3).Top) And (ball1.Left + 202 >= block(3).Left And ball1.Left + 202 <= (block(3).Left + 1575)) Then
Call cmdBlock_Click(3)
End If
If (ball1.Top - 202 >= (block(4).Top - 495) And ball1.Top - 202 <= block(4).Top) And (ball1.Left + 202 >= block(4).Left And ball1.Left + 202 <= (block(4).Left + 1575)) Then
Call cmdBlock_Click(4)
ElseIf (ball1.Top - 202 >= (block(5).Top - 495) And ball1.Top - 202 <= block(5).Top) And (ball1.Left + 202 >= block(5).Left And ball1.Left + 202 <= (block(5).Left + 1575)) Then
Call cmdBlock_Click(5)
End If
If (ball1.Top - 202 >= (block(6).Top - 495) And ball1.Top - 202 <= block(6).Top) And (ball1.Left + 202 >= block(6).Left And ball1.Left + 202 <= (block(6).Left + 1575)) Then
Call cmdBlock_Click(6)
ElseIf (ball1.Top - 202 >= (block(7).Top - 495) And ball1.Top - 202 <= block(7).Top) And (ball1.Left + 202 >= block(7).Left And ball1.Left + 202 <= (block(7).Left + 1575)) Then
Call cmdBlock_Click(7)
End If
If (ball1.Top - 202 >= (block(8).Top - 495) And ball1.Top - 202 <= block(8).Top) And (ball1.Left + 202 >= block(8).Left And ball1.Left + 202 <= (block(8).Left + 1575)) Then
Call cmdBlock_Click(8)
ElseIf (ball1.Top - 202 >= (block(9).Top - 495) And ball1.Top - 202 <= block(9).Top) And (ball1.Left + 202 >= block(9).Left And ball1.Left + 202 <= (block(9).Left + 1575)) Then
Call cmdBlock_Click(9)
End If
|
The if statements are all the same for each index number of the block. as u can see in the if statements i'm saying that if the radius of the ball is between the coorinates of the block than call the procedure i made which deletes the blocks. now this only works if it touches the radius of the ball otherwise it won't work. |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Sat Dec 31, 2005 1:50 am Post subject: (No subject) |
|
|
I don't follow this topic or Visual Basic, but that code looks like it can be shortened a ton by simply using a for loop to iterate over the block array. I suggest definately looking into it. |
|
|
|
|
![](images/spacer.gif) |
Misha
|
Posted: Sat Dec 31, 2005 4:35 pm Post subject: (No subject) |
|
|
thanks for the idea of using a for loop. i tried it out and i got it to work. now i have a lot less lines of code. also i figured out how to make the bricks disapear if the ball hits the very corner of them.
the only problem i'm having now is when the ball is on the paddle at the start of the game and u move the paddle the ball has to move with the paddle. i can't do it without causing the ball to continue moving with the paddle during the game. |
|
|
|
|
![](images/spacer.gif) |
pavol
|
Posted: Sat Dec 31, 2005 9:21 pm Post subject: (No subject) |
|
|
2 questions, 1 are you sure that your code is the same for both cases, because the problem could just be a copy error, and 2 where do you control the value of the variable 'dead' because im thinking that the problem lies with where you make dead true or false. |
|
|
|
|
![](images/spacer.gif) |
Misha
|
Posted: Sun Jan 01, 2006 11:30 am Post subject: (No subject) |
|
|
thanks for all the help but i already figured it out myself ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|