Hardpoints
BlitzMax Forums/BlitzMax Programming/Hardpoints
| ||
Asbtract of course. Thinking about it, how would one put in a hardpoint on your virtual ship. What I did was create the coordinates which the projectile originates from originally. So I have two missiles flying out from two different parts. and created the start point of each by going. hardpoint1= ship.x -15 hardpoint2= ship.y -15 hardpoint3= ship.x + 15 hardpoint4= ship.x -15 missile1.x= hardpoint1 missile1.y= hardpoint2 missile2.x= hardpoint3 missile2.y= hardpoint4 so according to the ship graphic, while its flying straight from bottom to top and facing that orientation it comes out. But If i rotate the ship, obviously the missiles fire from another area of the ship graphic. Because theres nothing making it remain on the area of the ship I wanted the weapons to originate from. how would one going about getting a physical hardpoint on the area of the ship, or can it still be done abstract like what I was trying. |
| ||
Here's a little code from my project, which I believe does exactly what you're after:shot._x = _x + yOff * Cos(_rotation) + xOff * Sin(_rotation) shot._y = _y + yOff * Sin(_rotation) - xOff * Cos(_rotation) The code gives the shot initial x/y coordinates. _x and _y and _rotation are the ship's coordinates and rotation, and yOff and xOff describe the hardpoint offset from the center of the ship. Hope this helps. |
| ||
where the yOff variable is getting a value from what calculation? and I assume the rotation is from a field in your ship type if I read you correctly. |
| ||
rofl for some reason this works Local Torpedo1HP=ship.x + 15 * Cos(ship.angle) + 15 * Sin(ship.angle) Local torpedo2HP=ship.y + 15 * Sin(ship.angle) - 15 * Cos(ship.angle) Local Torpedo3HP=ship.x - 15 * Cos(ship.angle) + 15 * Sin(ship.angle) Local torpedo4HP=ship.y - 15 * Sin(ship.angle) - 15 * Cos(ship.angle) hp1&2 are for the first torpedo object 3&4 are for the second. my offset is 15 so i didnt feel i needed to create a variable for it. if i need to later because of different ships fine, but right now, 15 15, gets it off to the areas I want. |
| ||
I did the same thing by storing everything as an angle and a distance. Then x = shipX + cos(shipRot + offAngle) * offDistance |
| ||
I know this isn't exactly do to with your problem, but shouldn't you be putting those hardpoints in an array :P |
| ||
or IMO a list |
| ||
Maybe, but I'm assuming the number of hardpoints isn't going to change, at least not very often, so I think an array would be better. |