shield arcs

BlitzMax Forums/BlitzMax Beginners Area/shield arcs

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

What is the dimensions of the left and right shield arc images?
What is the dimensions of the top and bottom shield arc images?
What is the dimensions of the ship image?

Since you aren't using square shield arc images, and since the arc within its image is not at the edge of a square but rather just the arc by itself, you have TWO levels of offsets to add to the handle.

Let's deal with the LEFT shield arc. The handle has to be the distance from the top left corner of the shield arc across and down to the center of the ship. You might understand it better if you FIRST create a handle that is centered on the shield arc. So if your shield arc image is, say, 10 width by 50 height, the handle would be 5,25. This centers on the shield arc. Then you need the difference between that position and the center of the ship. Let's say you want the center of the left shield arc to be 50 pixels to the left of the ship, you now add 50 to the handle position for the arc. so it would be 5+50,25 = 55,25.

You do the same with the right arc except now you subtract 50 from x instead of add it.

For the top arc find the middle of the arc image, then add the distance from the ship center to the y handle for the arc, e.g. 25,5+50

Then do the same for the bottom arc but subtract the difference between the ship center and the arc center ie 25,5-50

Then when you do the rotate thing they should all rotate around the ship center as if you have rods going out in a + formation from the ship center, attached to the center of each arc.

SetImageHandle(shield_front, ImageWidth(shield_front)/2,(ImageHeight(shield_front)/2)+50)

SetImageHandle(shield_aft,ImageWidth(shield_aft)/2,(ImageHeight(shield_aft)/2)-50)

SetImageHandle(shield_left, (ImageWidth(shield_left)/2)+50, ImageHeight(shield_left)/2)

SetImageHandle(shield_right, (ImageWidth(shield_right)/2)-50,ImageHeight(shield_right)/2)

                'SetAlpha 0.0
                'draw shield arcs around player ship
                DrawImage shield_front, x,  y  
                DrawImage shield_aft,   x , y 
                DrawImage shield_left,  x , y
                DrawImage shield_right, x , y 

I think that should work.

Bare in mind that you only need to set the image handles ONCE upon loading the images, you don't have to set them every time you draw them.

Also if you put the handle setting into a function, you could pass a `closeness` value which is your `50` or whatever, which you can call any number of times with different values to animate the shield arcs moving closer to or further away from the ship, or reacting to an impact, etc. You also might want to use floats e.g. 50.0