{"id":90,"date":"2026-09-01T20:25:50","date_gmt":"2026-09-01T20:25:50","guid":{"rendered":"https:\/\/robinclapworthy.com\/?p=90"},"modified":"2026-09-01T20:30:35","modified_gmt":"2026-09-01T20:30:35","slug":"i-wanted-one-of-those-shields-from-gorf","status":"publish","type":"post","link":"https:\/\/robinclapworthy.com\/?p=90","title":{"rendered":"I Wanted One of Those Shields From Gorf"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One of the things I remember from old arcade games is the curved shield in Gorf.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And while working on Galactic Gladiators, I had one of those thoughts that is becoming increasingly dangerous:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Could I do something like that in Visual FoxPro?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not just display a picture of a shield.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I wanted a curved energy barrier that could actually be damaged. Fire at it and part of the shield disappears. Fire through the resulting hole and the missile should pass straight through.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I had absolutely no idea whether this was practical.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I decided to try it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Starting with an arc<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The first experiment was ridiculously simple.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Could Visual FoxPro draw a curved line?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using VFP&#8217;s drawing functions and a little trigonometry, I generated points around part of a circle and joined them together.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And there it was.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A very thin, very unimpressive black arc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But it was an important little black arc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It meant the shield didn&#8217;t have to be a bitmap or a pre-drawn animation. FoxPro could generate the geometry itself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I increased the line thickness, adjusted the size and started experimenting with the shape.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original circular arc was too tall, so I changed it into an ellipse by using different horizontal and vertical radii.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Suddenly it began to look much more like a barrier stretching across the playfield.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can you shoot holes in it?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This was the bit I was really interested in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I divided the arc into 20 separate sections and gave each section a simple state: it either exists or it doesn&#8217;t.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Conceptually, it&#8217;s little more than:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ThisForm.aShield&#91;1] = .T.\nThisForm.aShield&#91;2] = .T.\nThisForm.aShield&#91;3] = .T.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and so on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a section is <code>.T.<\/code>, FoxPro draws it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If it&#8217;s <code>.F.<\/code>, it doesn&#8217;t.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I manually switched one section off.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There was a hole.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then I switched three separate sections off.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Three holes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then three adjacent sections.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That produced something that actually looked like a chunk had been blown out of the barrier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At this point I was getting rather excited.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Making it look less like mathematics<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The shield worked, but it still looked like a thick line drawn on a form.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I tried drawing the same geometry three times.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First a thick dark-blue line, then a narrower brighter blue line, and finally a very thin pale-blue centre.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That simple trick gave the shield something resembling an energy glow.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It was still sitting on an ugly white FoxPro test form, but I could already imagine what it would look like against the scrolling starfield in Galactic Gladiators.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There was now just one rather important question.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can a missile actually hit it?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Drawing a damaged shield is one thing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Having the game understand that a missile has hit a particular part of a curved shield is another.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is where the maths became somewhat more interesting than I was expecting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The collision code takes the position of the missile relative to the centre of the ellipse and determines where it has crossed the shield.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From that, it can calculate which of the 20 shield sections the missile has encountered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first proper test produced:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>HIT SECTION 6<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That was a rather satisfying moment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The missile had travelled up the screen and stopped exactly when it reached the curved barrier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I made section 6 disappear.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now came the test that really mattered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If I fired another missile through the resulting hole, would the collision detection understand that there was no longer any shield there?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After a little debugging \u2014 including discovering that my first collision calculation was treating the shield more like a circle than the ellipse I&#8217;d actually drawn \u2014 it worked.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A missile hitting an intact section stops.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That section can be destroyed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And a subsequent missile can travel through the hole.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">That&#8217;s a game mechanic<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There are plenty of things still to do.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the moment the amount of damage is based on shield sections rather than the actual width of the projectile. The broken edges need to look damaged rather than perfectly clean. I&#8217;d like them to flicker or spit energy, and the whole thing needs integrating properly into the game&#8217;s existing update loop.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But those aren&#8217;t really experiments any more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They&#8217;re implementation and polish.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The experiment was:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can Visual FoxPro generate a curved energy shield, detect where a missile hits it, damage that particular area and subsequently allow missiles through the hole?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apparently it can.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Which is slightly ridiculous.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And exactly why I&#8217;m enjoying building this game.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image-1024x683.png\" alt=\"\" class=\"wp-image-91\" srcset=\"https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image-1024x683.png 1024w, https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image-300x200.png 300w, https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image-768x512.png 768w, https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image.png 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>One of the things I remember from old arcade games is the curved shield in Gorf. And while working on Galactic Gladiators, I had one of those thoughts that is becoming increasingly dangerous: Could I do something like that in Visual FoxPro? Not just display a picture of a shield. I wanted a curved energy &#8230; <a title=\"I Wanted One of Those Shields From Gorf\" class=\"read-more\" href=\"https:\/\/robinclapworthy.com\/?p=90\" aria-label=\"Read more about I Wanted One of Those Shields From Gorf\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-galactic-gladiators"],"_links":{"self":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":1,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":92,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions\/92"}],"wp:attachment":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}