SuperHBob Posted November 5, 2005 Share Posted November 5, 2005 Hey, I usually don't use forums for help, but I seemed to run into a rut that I just can't seem to escape from. I'm hoping the solution is simple and that I just over-looked it. I'm in the process of making a simple tank game. (it's quite simple) and there is a certain part where the user clicks on one of his(/her) tank in hopes that it will move. and I'm wanting (once the tank has been clicked on) all the possible spaces the tank can move to, to highlight themselves. unfortunately, this turns out to be quite a feat (seeing that this is the part that I can't handle) I found out the function to highlight all the surrounding area. The current tank movement range is 4 (just to keep it simple). But the problem is that .... THERE ARE WALLS, and other objects that the tanks can't move over. I need to find the code that detects all the possible _paths_ the tank can take, not just the area if there were no obstacles. Here's the code I used to highlight only the area the tank can move. For $j = 1 To 4 ; four would be the max move range $xdist = $j $ydist = 0 While $xdist >= 0 GUICtrlSetImage($tilepic[19 - $xdist][9 - $ydist], @ScriptDir & "\Move.bmp") GUICtrlSetImage($tilepic[19 + $xdist][9 - $ydist], @ScriptDir & "\Move.bmp") GUICtrlSetImage($tilepic[19 - $xdist][9 + $ydist], @ScriptDir & "\Move.bmp") GUICtrlSetImage($tilepic[19 + $xdist][9 + $ydist], @ScriptDir & "\Move.bmp") $xdist = $xdist - 1 $ydist = $ydist + 1 WEnd Next this also assumed that the tank is at coordinates (19,9) which in the later code would be variables called "$xslot" and "$yslot". so what I was thinking was to figure out where all obstacles are and then have the computer store an array of all possible paths the tank can take. .... if I'm not explaining this right or no one understands what I'm getting at ... I figure I'll just attach the coding and the bad sprites that go along with it. also, there's a "TacticsTankPreview" file. This file contains a little (and not completed) preview of what's supposed to occur in the game. But it's still missing how the tank can desipher and move around obstacles in its path. you shouldn't have to change any code if you keep it all in the same folder (I also use the "scite" editor ... which helps a bundle) if anyone finds a way or knows the code to determine all paths for any number of movement spaces. please post. thanks guys P.S. if you keep thinking that it only loads walls initially, click on "New" under the "file" menu. (but unfortunately it doesn't run yet) 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