El-Trucha Posted February 1, 2005 Share Posted February 1, 2005 Hello every1!! OK, this is what I have: If $goldPos[0] > $bluePos[0] And $goldPos[0] < ($bluePos[1] + 32) And $goldPos[1] > ($bluePos[1] + 32) And $goldPos[1] < ($bluePos[1] + 32) Then ToolTip("PRESSED", 2) That's supposed to make a tooltip on the left side of the screen when I press SPACE and the two 32x32 icons are on top of each other... The thing doesnt work!! well, it works, but not where I want it to!! Here are the variables I used: $goldPos[0] = golden character's LEFT position $goldPos[1] = golden character's TOP position $bluePos[0] = blue character's LEFT position $bluePos[1] = blue character's TOP position I'm making a fighting game with the yellow and blue dragon cursors in %WINDIR%\Cursors... Thanx!! El-Truchahttp://www.truchasoft.tk[url="ftp://tsfc.homeftp.net"]ftp://tsfc.homeftp.net[/url]hotline://tsfc.ath.cx Link to comment Share on other sites More sharing options...
Blue_Drache Posted February 1, 2005 Share Posted February 1, 2005 (edited) Hello every1!! OK, this is what I have:If $goldPos[0] > $bluePos[0] And $goldPos[0] < ($bluePos[1] + 32) And $goldPos[1] > ($bluePos[1] + 32) And $goldPos[1] < ($bluePos[1] + 32) Then ToolTip("PRESSED", 2)That's supposed to make a tooltip on the left side of the screen when I press SPACE and the two 32x32 icons are on top of each other...The thing doesnt work!! well, it works, but not where I want it to!! Here are the variables I used:$goldPos[0] = golden character's LEFT position$goldPos[1] = golden character's TOP position$bluePos[0] = blue character's LEFT position$bluePos[1] = blue character's TOP positionI'm making a fighting game with the yellow and blue dragon cursors in %WINDIR%\Cursors... Thanx!! <{POST_SNAPBACK}>This is baisc "hit detection" right? If Gold intersects Blue we'll fire off a message box.Well, let's put gold at 0,0 to make this easy. We'll also assume you're using a grid of say....... 8x8 instead of 1x1Dim $goldPos[2], $bluePos[2] $goldPos[0] = 0; Gold's X axis $goldPos[1] = 0; Gold's Y axis $bluePos[0] = 64; Blue's X axis $bluePos[1] = 64; Blue's Y axis While 1 $bluePos[0] = $bluePos[0] - 8 $bluePos[1] = $bluePos[0] - 8 If $bluePos[0] <= $goldPos[0] + 32 or _ $bluePos[1] <= $goldPos[1] + 32 then Tooltip() $bailout = 1 ExitLoop Endif Sleep(10) Wend If $bailout = 1 then Msgbox(0,"Intersect","Intersect at: X: " & $bluePos[0] & _ " Y: " & $bluePos[1])This is untested, but it should work without all that complicated AND stuff.The other solution is to DIM your array into 4 parts. Since gold and blue are a fixed size of 32x32, then your X and Y array would look something like:Dim $bluePos[4] $bluePos[0] = 0; Left X $bluePos[1] = 0; Top Y $bluePos[2] = $bluePos[0] + 32; Right X $bluePos[3] = $bluePos[1] + 32; Bottom YAnd check for the intersection of any of those points. Edited February 1, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
El-Trucha Posted February 1, 2005 Author Share Posted February 1, 2005 This worked: If $bluePos[0] <= ($goldPos[0] + 32) And $bluePos[1] <= ($goldPos[1] + 32) And $bluePos[0] >= ($goldPos[0] - 32) And $bluePos[1] >= ($goldPos[1] - 32) then ToolTip("PRESSED", 2) Much thanx for everything!! El-Truchahttp://www.truchasoft.tk[url="ftp://tsfc.homeftp.net"]ftp://tsfc.homeftp.net[/url]hotline://tsfc.ath.cx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now