Over a million developers have joined DZone.

Flying Through Paths: MissileGame in SVG..But No curveto Explosions Yet?

DZone's Guide to

Flying Through Paths: MissileGame in SVG..But No curveto Explosions Yet?

· Web Dev Zone ·
Free Resource

Learn how error monitoring with Sentry closes the gap between the product team and your customers. With Sentry, you can focus on what you do best: building and scaling software that makes your users’ lives better.

Way back in 2004, Damien Clarke wrote the missile game 3d in Flash -- a follow-up to two other Flash games (written by his cousin) and a fun time-sink, with simple mouse control, that roughly simulates Lando's spectacular run in the second Death Star.

It's basically a geometry-heavy collision-detection game, and just as enjoyable as it sounds.

Now Ben Mather has shown his post-Flash mettle and recreated the game in SVG, taking full advantage of Kevin Lindsey's popular 2D geometry JavaScript library for SVG:


KevLinDev's library worries about intersections, projection and reflection, polygon definition, 2d point and vector routines, color picking, bezier morphing, mouse tracking, and loads of other game-geometry and game-GUI problems. And it's a great library for any SVG game development.

But Ben's MissileGame port really shows off the game library's power, and boasts some really nice, complex SVG of its own.

..including some code tantalizingly marked 'EXPLOSION!!!!' but is completely commented out..!:

<!--== EXPLOSION!!!! ========================================================-->
<!--    <path id="explosion"-->
<!--       transform="scale(2,2)"-->
<!--       fill="#f5bd3c"-->
<!--       stroke="#ff2626"       -->
<!--       stroke-width="0.5"-->
<!--       d="m -0.63488,-4.3752-->
<!--          c  0.24879,1.233, 1.1883,2.6366, 1.768,0.69037-->
<!--             0.74264,0.71431, 1.2069,0.6277, 1.6362,-0.5115-->
<!--            -0.034821,1.0871, 0.096633,1.6827, 0.74401,1.7541-->
<!--            -0.091757,1.4249, 0.70746,2.0783, 1.2188,1.8749-->

..plus lots more path curveto commands. (Is there an SVG explosion path generator, btw? I assume he didn't hand-tune all those x-and-y's...)

So try the game itself, first, and then look at the svg source, which points you to all the game-logic JavaScript.

And maybe see what happens if you de-comment the explosions transformation..!

What’s the best way to boost the efficiency of your product team and ship with confidence? Check out this ebook to learn how Sentry's real-time error monitoring helps developers stay in their workflow to fix bugs before the user even knows there’s a problem.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}