Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-29-2005, 10:54 AM   #1
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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!
rspassey is offline   Reply With Quote
Old 10-29-2005, 11:13 AM   #2
Shiro Usagi
Premium Member
 
Cricket's Avatar
 
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
Cricket is offline   Reply With Quote
Old 10-29-2005, 11:18 AM   #3
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
Quote:
Originally Posted by Cricket
I don't think this belongs in the General Discussion forum...might want to post this in the General Software forum.

Cricket
I thought at one time there was a forum about programming, I couldn't find it though... So I thought might as well put it here. Feel free to move it to its correct location.
rspassey is offline   Reply With Quote
Old 10-29-2005, 02:13 PM   #4
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Old 10-29-2005, 02:18 PM   #5
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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?
rspassey is offline   Reply With Quote
Old 10-30-2005, 01:21 PM   #6
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Old 10-30-2005, 02:16 PM   #7
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
Ahh okay - thanks - If i have a chance to work in it tomorrow then I will post back with how that helps.
rspassey is offline   Reply With Quote
Old 10-31-2005, 02:48 PM   #8
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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
rspassey is offline   Reply With Quote
Old 10-31-2005, 02:54 PM   #9
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Old 10-31-2005, 02:58 PM   #10
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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.
doctorgonzo is offline   Reply With Quote
Old 10-31-2005, 03:08 PM   #11
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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.
rspassey is offline   Reply With Quote
Old 10-31-2005, 03:38 PM   #12
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Old 11-01-2005, 02:39 PM   #13
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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.
rspassey is offline   Reply With Quote
Old 11-04-2005, 02:01 PM   #14
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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
will not properly activate a tie. I have made sure that my drawidth and picture box are configured properly to make sure that there is just an off chance that the variables are differnt from the begining and since they move at the same rate they do not ever land on the same spaces... but like I said I have made sure this is not the case.

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
Attached Files
File Type: txt tron code text 3.txt (9.1 KB, 40 views)

Last edited by rspassey; 11-04-2005 at 02:06 PM.
rspassey is offline   Reply With Quote
Old 11-10-2005, 04:56 PM   #15
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
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.
rspassey is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:59 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2