- Assistance With Overlap Detection
- 02 Feb 2018 12:36:05 pm
- Last edited by exoRift on 02 Feb 2018 12:50:22 pm; edited 1 time in total
I'm working on Battleship CSE, but I can't seem to figure out how to detect ship overlapping in the editor which is a problem because I need the same system for hit detection in the actual game as well.
DL Link: https://www.dropbox.com/s/eukyg96066i19xc/BATSHIP.8xp?dl=0
The problem is the way the data is stored and I wanted it this way because it's easier and If the ship is gone it's easy to find out where to draw the line. Anyway, this is how it's stored:
L1(1) P1's 6x1's X coord, L1(6) P1's 6x1 Y coord, L1(11) P1's 6x1's rotation indicator (0=Horizontal 1=Vertical). Player 2's same system starts from (16). I hope you can infer the X of the 5x1 is L1(2)
If anyone can supply me with the formula for detection, I'd really appreciate it.
PT_ gave me this but it doesn't exactly work so feel free to use it as a guider.
Code:
Hope I'm not sounding lazy. I genuinely can't figure out how to do this.
People got confused with the storage system so:
https://docs.google.com/spreadsheets/d/1tyAPybIKeHuXX6wJpPAtBPbwQnsRhCwZXP0MOfjBC3I/edit?usp=sharing
DL Link: https://www.dropbox.com/s/eukyg96066i19xc/BATSHIP.8xp?dl=0
The problem is the way the data is stored and I wanted it this way because it's easier and If the ship is gone it's easy to find out where to draw the line. Anyway, this is how it's stored:
L1(1) P1's 6x1's X coord, L1(6) P1's 6x1 Y coord, L1(11) P1's 6x1's rotation indicator (0=Horizontal 1=Vertical). Player 2's same system starts from (16). I hope you can infer the X of the 5x1 is L1(2)
If anyone can supply me with the formula for detection, I'd really appreciate it.
PT_ gave me this but it doesn't exactly work so feel free to use it as a guider.
Code:
For(A,L1(1),L1(1)+5not(L1(9 // Loop through all the X coordinates of the 5x1 ship
For(B,L1(5),L(5)+5L1(9 // Loop through all the Y coordinates of the 5x1 ship
If A>=L1(2) and A<=L1(2)+4not(L1(10)) and B>=L1(6) and B<=L1(6)+4L1(10 // Oh no, there's already a part of the ship at this point
Goto NO
End
End
End
Hope I'm not sounding lazy. I genuinely can't figure out how to do this.
People got confused with the storage system so:
https://docs.google.com/spreadsheets/d/1tyAPybIKeHuXX6wJpPAtBPbwQnsRhCwZXP0MOfjBC3I/edit?usp=sharing