I’m cleaning up a Swift project and wanted a time saving tool to show me all of the unused variables and funcs. This smarty, Paul Taykalo, created a Ruby script that works like a charm.
Here’s his Medium article on the subject.
Here’s the GitHub repo to download.
Here’s some sample output from the project I’m working on:
Today’s game tasks included a fun algebra formula that we all learned in grade school. Fun you say? Well, yes! The Distance Formula computes the distance between two points. Here it is –
Pretty easy to follow. Take the x position of first and second points and the y position of the first and second points and plug them into the equation, then take the square root of the result.
Why am I employing this equation in the DuneTraveller game? Well, I want the player to “search” around his current location to look for hidden clues and items. To know where to search he has to have been told to search somewhere OR he could just be hitting the “S” key on his own in a shotgun approach to finding stuff.
When the current level loads, I read and cache all of the hidden search points and when the player hits the “S” key (“S” is for search!) I loop through the cache and compute the distance from the player to each one of the search area points. If the distance is less than or equal to the declared radius then the item is revealed. It could be a hidden note, or maybe even some loot.
The problem I encountered is the rather dearth of conversion functions in Swift. The second problem is that the output of some of the built in math functions is inconsistent. “pow” which is used to compute something like “what is 4 squared?” outputs a decimal. However “sqrt” takes a double. Turns out there is no direct conversion in Swift.
Thanks to this post on Stack Overflow the code looks like this –
You will also notice I still wasn’t finished with my conversion party after getting the square root. I had to cast the searchRadius (which is an integer) into a double before performing the comparison.
It’s fun learning a new language’s quirks.
Since leaving Match.com in March 2020, I have not been sitting around watching TV and playing video games – I’ve been writing one.
The week after I resigned, I –
I’m excited about everything I’ve learned because it seems like I’m making real progress.
I’m happy to report that although I did not have much time this weekend to devote to game development, I was able to create a new SpriteKit Scene file, lay down a new tile map grid, and position my character sprite in the new level.
The player sprite I made with Aseprite which is a very cheap yet very capable sprite editor. I had to watch this video on how to make it transparent. Teach yourself!