Tuesday, November 1, 2016

Updated Projects Page

Took some time today updating our projects page. This page contains a number of learning applications that are public so you can see what we did to create these apps. We just added two new applications: Camping Directory and Windup Wars. These are my own first forays into iOS development using Swift. Thanks to Ray Wenderlich for the great game tutorial.

Friday, October 28, 2016

Simple About Box in Swift

Here is a really simple example of how to create an about box from a UIAlertController in iOS using Swift. The box displays the application icon, the current version and some text about the application:

        let alertMessage = UIAlertController(title: "Camping Directory", message: "", preferredStyle: .alert)
        
        // Application Icon
        let image = UIImage(named: "AppIcon40x40")
        
        let imageView = UIImageView(frame: CGRect(x: 115, y: 48, width: 40, height: 40))
        imageView.image = image
        imageView.layer.cornerRadius = 8.0
        imageView.clipsToBounds = true
        
        alertMessage.view.addSubview(imageView)
        
        // Application Version
        let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
        
        // Description
        var message = "\n\n\nVersion " + version! + "\n\n"
        message += "This program is..."
        
        alertMessage.message = message
        
        let action = UIAlertAction(title: "OK", style: .default, handler: nil)
        alertMessage .addAction(action)
        
        self.present(alertMessage, animated: true, completion: nil)

Sunday, April 5, 2015

Exploring libGDX for Game Development

I just started exploring game development again to give myself a break from my daily work as a data architect.  First I had to find tools that would run on a Mac and create games for Android as well as iOS.

After an extensive search, I chose libGDX as my base game graphics and physics library. It is cross-platform, open source, and provides decent performance. Since libGDX works with Java, I was able to choose my favorite IDE from IntelliJ, Android Studio. The combination runs without issue on OSX.

Next, I needed a mapping tool for which I selected Tiled. Tiled gives me a standardized system and a flexible tool that allows me to focus on game development. With Tiled, I was able to take a few tilesets, create my levels, and get on with coding my game.  It is perfect for 2D game development.

Another important part of game development is creating sprite sheets. Although libGDX comes with a basic sprite packer, I chose the commercial tool TexturePacker. TexturePacker makes one more productive when managing sprite sheets. Just drag your sprite images and drop them into TexturePacker and publish your sprite sheet in one of many game engine formats.

Tiled and TexturePacker support more than just libGDX which is a plus if I want to try another game engine. This means I won't have to replace my entire toolset.

I just finished my first game using these tools. It isn't anything to write home about, just a basic runner game (Monster Run). It was a good introduction to using libGDX without a lot of complex coding. I usually have more code content in my posts. This post was just a quick note to readers as to what I have been working on lately.

Saturday, July 5, 2014

Critters - Free One Pet Account

Critters Personal Pet Health Records has changed the one pet plan from paid to free. No credit card is necessary to sign up for this account and it is yours to use as long as you want.

Sign up at https://www.critterhealthrecords.com today!

Wednesday, May 28, 2014

Google Maps Example Using Geolocation

Here is a really simple script for using Geolocation with the new Google Maps API V3. The code is pretty self explanatory:

<script src="https://maps.googleapis.com/maps/api/js?libraries=places&v=3&sensor=true"></script> 

<script type="text/javascript">
    // Note: This example requires that you consent to location sharing when
    // prompted by your browser. If you see a blank space instead of the map, this
    // is probably because you have denied permission for location sharing.

    var map;
    var infowindow;
    var service;

    function initialize() {

        var mapOptions = {
            zoom: 13
        };

        map = new google.maps.Map(document.getElementById('map'),
                mapOptions);

        // Try HTML5 geolocation
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position) {
                var pos = new google.maps.LatLng(position.coords.latitude,
                        position.coords.longitude);

                var marker = new google.maps.Marker({
                    map: map,
                    position: pos,
                    title: "You are here!",
                    icon: 'https://maps.google.com/mapfiles/ms/icons/green-dot.png'

                });

                var request = {
                    location: pos,
                    radius: 10000,
                    query: 'Veterinarian' // The query for what to find near your location
                };

                map.setCenter(pos);

                doSearch(request);
            }, function() {
                handleNoGeolocation(true);
            });
        } else {
            // Browser doesn't support Geolocation
            handleNoGeolocation(false);
        }
    }

    function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
            var content = 'Error: The Geolocation service failed.';
        } else {
            var content = 'Error: Your browser doesn\'t support geolocation.';
        }

        var options = {
            map: map,
            position: new google.maps.LatLng(60, 105),
            content: content
        };

        var infowindow = new google.maps.InfoWindow(options);
        map.setCenter(options.position);
    }

    function doSearch(request) {
        infowindow = new google.maps.InfoWindow();

        service = new google.maps.places.PlacesService(map);
        service.textSearch(request, callback);
    }

    function callback(results, status) {
        if (status === google.maps.places.PlacesServiceStatus.OK) {
            for (var i = 0; i < results.length; i++) {
                createMarker(results[i]);
            }
        }
    }

    function createMarker(place) {
        var placeLoc = place.geometry.location;
        var marker = new google.maps.Marker({
            map: map,
            position: place.geometry.location
        });

        var request = {reference: place.reference};
        service.getDetails(request, function(details, status) {
            google.maps.event.addListener(marker, 'click', function() {
                if (details != null) 
                    infowindow.setContent('<a target="_blank" href="' + details.url + '">' + details.name + "</a><br />" + details.formatted_address + "<br />" + details.formatted_phone_number);
                else
                    infowindow.setContent(place.name);
                infowindow.open(map, this);
            });
        });
    }

    google.maps.event.addDomListener(window, 'load', initialize);
</script>