|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
~ Ryan ~
|
Need a little VB 6.0 help.
Okay, in school we have been working with Visual Basic 6.0.
I am currently working on a Tron Light Cycles 2-d game. Everything works great, all the collision work by using : Picture1.point (x 2 value, y 2 value) = RGB (color of opposite player). I am drawing the line with the Picture1.line ( x2, y2) - (x1, y2) = RBG (player color) for each player, and updating the x2, and y2 points with a timer every 50 ms. After drawing the line, x1 and y1 take the values of x2 and y2, and a new line is drawing between the points. Additionally; all turning and the boarders work, yet I have one problem. When player blue hits himself I cannot register this by using If Picture1.Point (playerblueX2, playerblueY2) = RBG (0, 0, 255) Then Timer1.enabled = False Response = MgsBox ("Blue Loses") exit Sub End If Instead of registering when he hits himself, automatically upon starting the game, i get the pop up "Blue Loses" ... I have tried that code before and after updating locations, before drawing the lines, after drawing and I get the same thing. Would someone be able to help me out? If needed, I can email you the files for it. TIA, Ryan124712
__________________
RiotCats.com, an internet domain specifically fabricated and visually erected for the appreciation of the feline kingdom! |
|
|
|
|
|
#2 |
|
Shiro Usagi
Premium Member
Join Date: Sep 1999
Location: Kaneohe, Hawaii
Posts: 34,002
|
I don't think this belongs in the General Discussion forum...might want to post this in the General Software forum.
Cricket
|
|
|
|
|
|
#3 | |
|
~ Ryan ~
|
Quote:
|
|
|
|
|
|
|
#4 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Step through the code using the F8 key. You can also start execution by using F8 instead of F5 or the arrow button. This should give you a good idea of why this condition is evaluated.
|
|
|
|
|
|
#5 |
|
~ Ryan ~
|
Then should I return the RGB value of the point at each step in a label - then see where it is that the point is not the same color and add in the code?
|
|
|
|
|
|
#6 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
I'm not sure I understand what you are asking.
What I was saying was to start execution of your program using the F8 key and continue stepping through it using F8 until you find out why your "blue loses" message box is displaying at startup. |
|
|
|
|
|
#7 |
|
~ Ryan ~
|
Ahh okay - thanks - If i have a chance to work in it tomorrow then I will post back with how that helps.
|
|
|
|
|
|
#8 |
|
~ Ryan ~
|
I tried that, but I still couldnt get it too work, it was like everytime no matter what the action it get the "blue dies" at start up. I even made sure my draw width was smaller than the amount I moved the x and y points for each movement - would you like me to email you the app so you can see what I mean?
Open to any other suggestions too. Ryan124712 |
|
|
|
|
|
#9 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Did you try putting a breakpoint on the "blue dies" message box display?
This way when you get to the line when your program starts, you can see what all the conditions are in your immediate/watches window. |
|
|
|
|
|
#10 |
|
Professional gadfly
|
What are the starting values of "playerblueX2" and "playerblueY2"? I'm guessing that at the very beginning of the game, the values are such that Picture1.Point (playerblueX2, playerblueY2) does equal blue. Perhaps the first thing you do on startup is draw a blue point at that location? If so, then the check will be true and show the "Blue dies!" message.
|
|
|
|
|
|
#11 |
|
~ Ryan ~
|
Well the subprogram only starts after the player1x2 and player1y2 are repositioned within the timer like this in the timer1
if directionplayer1 = dir_up then player1y2 = player1y2 - 3 draw Which is the subprogram which draws the lines end if And this repeats for each posible direction that the tron light cycle is moving. And in draw I have the code to check if blue dies before it lines is connected, so the x and y values are somwhere on a black point and have yet to be made blue. |
|
|
|
|
|
#12 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Seriously, try the breakpoint... I think this will be instrumental in diagnosing the problem. You can look at all the current values and review the call stack to see exactly what function calls were made.
VB has first class debugging tools... take advantage of it. |
|
|
|
|
|
#13 |
|
~ Ryan ~
|
You can be happy to know that I got it working. Thanks so much you guys.
I just have to wrap up the graphics on it, include a score keeping part, and write the code for head on "ties". (shouldn't take me too long) Thanks again all - I don't know what I would do w/o PCMECH. |
|
|
|
|
|
#14 |
|
~ Ryan ~
|
I have run into one more problem - for some reason this code
Code:
'TIE '
If player1x1 = player2x1 And player1y1 = player2y1 Then
response = MsgBox(" TIE ")
Timer1.Enabled = False
Timer2.Enabled = False
Exit Sub
End If
I cannot figure out how or where I should put the "Tie" code ... Any help would be apreaciated - I will attach a copy of the entire code incase that helps. TIA (again) Ryan124712 Last edited by rspassey; 11-04-2005 at 02:06 PM. |
|
|
|
|
|
#15 |
|
~ Ryan ~
|
No Worries - I moved the code to the timers and changed from linse to Pset and everything works great now - Im going to a little over the top and making obstacles and mazes and different maps now. I might over the weekend add in a 3rd player which can be a bot or computer player and try to give it some AI so it doesnt crash into something right away.
Thanks for the help. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|