none
Continuation of the last thread on range - target mode this time

    Question

  • Hi all, half the battle for range has been solved, the next half is to sort the selected attack sprite to show the squares that is is able to attack. 

    Simply what I want the attack sprite to do is highlight squares 2/3 square spaces forward from it to show when a sprite is in that highlighted space it can be attacked otherwise it can't

    Here are some comments from the last thread. 

    Were getting somewhere T. 

    Progress after a long while of 2 weeks. 

    We succeeded it into selecting the sprite, highlights it and indicates that the target is out of range. 


    WRA

    Saturday, April 15, 2017 3:05 PM

Answers

  • So the highlighted tank i Selected it can attack vertically.

    If you mean that it can attack any square that is 1, 2 or 3 squares immediately above it, then the squares you need to check are the squares with the same column number as the current square, but with a row number of the current square minus 1, current square minus 2, and current square minus 3.

    If that's the same for all tanks then nothing is needed for the class.  But if different tanks can be N S E or W then you will need something in the class to indicate that, and the calculation will vary accordingly.

    • Marked as answer by Waliur Rahman Tuesday, April 18, 2017 11:39 AM
    Monday, April 17, 2017 12:42 PM

All replies

  • But one problem Tommy, it won't allow me to select from sprite to sprite such as select another sprite other than the one I just selected as seen with the screenshots. 

    How would I just using your example adjust it to select from sprite to sprite?


    WRA


    Well thats looking better Wali.

    I am not sure what problem you are having. I dont have the code.

    My example allows you to keep picking the target as I recall. If an invalid target is selected the example gives a message and awaits selection of a valid target.

    After the attack sprite is set the example only selects target unless you add code to reset. ie AttackPicturebox = nothing. Otherwise you can keep selecting targets at that stage.

    So whatever you use to determine what stage you are at, ie in my example if AttackPicturebox is not nothing then choose target, I use AttackPicturebox as my flag, just reset the flag to step 1 or whatever.

    You may need to add a cancel button. Or use rmb for cancel etc. Or if target not in range then reset target select or whatever.


    WRA

    Saturday, April 15, 2017 3:05 PM
  • Simply what I want the attack sprite to do is highlight squares 2/3 square spaces forward from it to show when a sprite is in that highlighted space it can be attacked otherwise it can't

    Then you need to spell out in much more detail what this means:

        '2/3 square spaces'  Is that 2 or is that 3?   It can't be both.

        'forward'   How does your sprite know which direction is forward? 

    You know how to highlight a square, so if you get your problem description down to the right level of detail then the code should follow.

    Saturday, April 15, 2017 10:53 PM
  • OOh I like that so I have manage to get it to shade the region of the selected tank now I just have to use the same example to be able to implement how it will show where it can attack. 

    WRA

    Sunday, April 16, 2017 11:02 AM
  • @Tommy

    There is a question in one of my other threads to do with a certain building being destroyed to determine the winner. Feel free to check it out. 

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/edd44471-9c20-4785-8328-ea57d7e92803/how-can-i-determine-the-winning-player-as-soon-as-the-headquarters-is-destroyed?forum=vbgeneral


    WRA

    Sunday, April 16, 2017 11:59 AM
  • @Acamar

    I get what you mean, I think I will explain through a screenshot is better off. 

    Previously we manage to get the highlighting process working What if I want to do is as soon as the target sprite is selected then it will show a msgbox "where to aim" then I assign it can attack a tank if it is in the positions from (3, 5) to (5, 5)



    WRA

    Sunday, April 16, 2017 6:54 PM
  • I get what you mean, I think I will explain through a screenshot is better off. 

    A screenshot is not a suitable way to explain.

    Your comment '2/3 square spaces' means '1, 2 or 3 squares starting at a square adjacent to the sprite and proceeding in a straight line'. 

    Now you need to determine how you know that the tank is pointing in a particular direction - down the screen in this example - so you know what 'forward' is.  Is the tank always pointing in that direction (that makes it easy).  Or are your going to add something to the sprite class to indicate the direction that it is currently pointing.   Or is it determined by the way that the user indicates that the tank should shoot (A, S, W, Z keys are typical).  Or should the direction be selected automatically based on what targets are available?

    Sunday, April 16, 2017 9:52 PM
  • This is the best thing about these forums pool of ideas and that is the flexibility that I love about this: it helps shape my ideas. All the tanks that I select will only go in one direction not pointing to the south north west or east. So the highlighted tank i Selected it can attack vertically. 

    Perhaps I will have to declare a new variable in my sprite class called "damage" which will show the areas that the tank can attack.


    WRA

    Monday, April 17, 2017 11:12 AM
  • So the highlighted tank i Selected it can attack vertically.

    If you mean that it can attack any square that is 1, 2 or 3 squares immediately above it, then the squares you need to check are the squares with the same column number as the current square, but with a row number of the current square minus 1, current square minus 2, and current square minus 3.

    If that's the same for all tanks then nothing is needed for the class.  But if different tanks can be N S E or W then you will need something in the class to indicate that, and the calculation will vary accordingly.

    • Marked as answer by Waliur Rahman Tuesday, April 18, 2017 11:39 AM
    Monday, April 17, 2017 12:42 PM
  • Ahhh I see so no need to declare a new variable in the sprite class I just gotta set out what I would like to do with the code in the select target event and use the paint form to help carry out in doing so.

    WRA

    Monday, April 17, 2017 1:51 PM
  • After a while finally solved the range issue, I am able to highlight the attacking sprite and show when a tank is out of range therefore not highlighting it otherwise if the tank is in range it will show message that the tank is in range and can be attacked. 

    WRA

    Tuesday, April 18, 2017 11:40 AM
  • @Acamar and Tommy

    I have a new question in the next thread which is the very last part in my project to be done and that is all there is to it. This time I have provided an example of what I am talking about 

    https://social.msdn.microsoft.com/Forums/en-US/af9f3ad4-098d-4532-b1e7-4020eff1fbf1/drag-drop-feature-to-implement-tanks-buildings-and-turrets?forum=vbgeneral


    WRA

    Tuesday, April 18, 2017 2:05 PM
  • Afternoon Tommy, I have real bad news :( my program today (the one where I solved the range issue) has crashed and it shows that the file fails to load, thus I had to delete the program. 

    I am not able to solve this problem because it has taken me hours to retrace the steps. Could you possibly send me an example (using those blocks where the user can select from square block to square block to indicate it is the attacking unit then it will shade the region where if any block is in those squares it can be attacked otherwise it is out of range. 

    This puts into a nutshell what I manage to successfully did but now that the program crashed and have no backups I have to do this all over again. 

    Therefore I was wondering if you have an example for this and I may as well re learn it for experience


    WRA

    Saturday, April 22, 2017 11:36 AM
  • Afternoon Tommy, I have real bad news :( my program today (the one where I solved the range issue) has crashed and it shows that the file fails to load, thus I had to delete the program. 

    I am not able to solve this problem because it has taken me hours to retrace the steps. Could you possibly send me an example (using those blocks where the user can select from square block to square block to indicate it is the attacking unit then it will shade the region where if any block is in those squares it can be attacked otherwise it is out of range. 

    This puts into a nutshell what I manage to successfully did but now that the program crashed and have no backups I have to do this all over again. 

    Therefore I was wondering if you have an example for this and I may as well re learn it for experience


    WRA

    Huh?

    :)

    Well that's a drag. Makes you lean to backup when that happens.

    I save a copy of my entire project folder before and after a major change. And most everyday regardless. And now and then copy to DVD. Copy to other computers. Keep a copy in my truck etc.

    Do you still have a problem? I see another post after this saying you have it working?

    As far as the yellow range rectangle, you just need to draw the rect in the paint event, just like highlighting the selected sprite. But first you need the rect. Drawing it is simple. If you know the 3 squares or whatever then you just draw a rect with yellow fill for each square. Just like the ellipse when we highlight the attack sprite. But now we just fill the square. After converting from grid square to screen drawing pixels of course.

    Saturday, April 22, 2017 1:13 PM
  • Now that rings a bell thanks T and I am definitely going to make backups because I am not willing to take that risk again because that just took the piehole. 

    WRA

    Saturday, April 22, 2017 1:20 PM