Apple Swift Playgrounds is Here!

I really enjoy using apps that allow you to see your code changes in real time.  I think they are fun for teaching.  I like ICE hosted on http://gamingjs.com/ice/ and W3School ‘s Try it Editor http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_basic . Now Apple has a great looking Swift editor called Playground. Check it out here: http://www.macrumors.com/2016/09/13/apple-releases-swift-playgrounds/

Swift-Playgrounds-800x558

Facebook is launching its own PC gaming platform

Check this out. Tune up on Unity!

The 2 key features I see are:

 It has “a new export feature baked into Unity that allows a studio to publish directly to Facebook”.

 Comes with “Integrating tools that provide effortless access to Facebook’s network”. Which has been sketchy in other platforms.

Read about it here on ENGADGET:

https://www.engadget.com/2016/08/18/facebook-is-launching-its-own-pc-gaming-platform/

Old School Form: Windows Form that is.

I threw together a little app to calculate local time in another time zone. It is based on C Sharp, ListBox, TimeZoneInfo, XML, Windows Forms and a WebService.

It is a little quick and dirty but it works, no elegant OOP for now. A few of the elements to note are it has a ListBox whose DataSource is GetSystemTimeZones(). The Time is pulled from an internet time server as XML. The local time zone is selected on the ListBox at the start. Picking from the ListBox will update the selected time zone data. There is a refresh button to update the time. Local Time is updated whenever a new selection is made or selection has been refreshed. It is pretty simple but there is a fair amount of wrestling with types. Retrieving the ListBox SelectedItem as a TimeZoneInfo type was not working for me, so I hit it with a bigger hammer.

 

Here is the solution zipped: Scott Skarbowski Problem28

using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace TimeZone
{
public partial class Form1 : Form
{
// SCOTT SKARBOWSKI TIMEZONE APP

//Time server url – NOTE: Central Time Zone!
public string url = @”http://webservice.theknot.com/Time/GetTime.asmx/currentTime”;
public DateTime ServerTime;
public TimeZoneInfo ServerTimeZone = TimeZoneInfo.FindSystemTimeZoneById(“Central Standard Time”);
public TimeZoneInfo newServerTimeZone;

public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
lbxTimeZones.DataSource = TimeZoneInfo.GetSystemTimeZones();
///// set ListBox Selected to user’s current time zone on start
lbxTimeZones.SelectedIndex = lbxTimeZones.FindStringExact(GetLocalTimeZone().ToString());

lblErrorMessage.Text = “”; // errorbox is clear
lblLocalTime.Text = TimeZoneInfo.ConvertTime(GetTime(), ServerTimeZone, GetLocalTimeZone()).ToLongTimeString(); //local time (long time string)
lblSelectedTimeZone.Text = GetLocalTimeZone().StandardName; // starts on local timezone
lblLocalTimeZone.Text = GetLocalTimeZone().StandardName; // stays local
lblSelectedTime.Text = TimeZoneInfo.ConvertTime(GetTime(), ServerTimeZone, GetLocalTimeZone()).ToString(); //original time
lblSelectedTimeZoneExt.Text = lbxTimeZones.SelectedItem.ToString(); //Extended text to match ListBox selection
}
public TimeZoneInfo GetLocalTimeZone()
{
///system determines user’s timezone
TimeZoneInfo localZone = TimeZoneInfo.Local;
return localZone;
}
public DateTime GetTime()
{
/// fetch current time from internet time service
//Receive xml response from time sever return as string
XmlDocument myXMLDocument = new XmlDocument();
try
{
myXMLDocument.Load(url);
// ServerTime DateTime —- change class to return datetime
ServerTime = DateTime.Parse(myXMLDocument.DocumentElement.InnerText.ToString());
}
catch (WebException webExcp)////////////check for errors in transmission
{
WebExceptionStatus status = webExcp.Status;
if (status == WebExceptionStatus.ProtocolError)
{
// Get HttpWebResponse so that you can check the HTTP status code.
HttpWebResponse httpResponse = (HttpWebResponse)webExcp.Response;
lblErrorMessage.Text = ((int)httpResponse.StatusCode + ” – ” + httpResponse.StatusCode).ToString();
}
else
{
lblErrorMessage.Text = “Sorry there has been an error- please check your internet connection.”; /// if not Http related
}
}
return ServerTime;
}

private void btnRefresh_Click(object sender, EventArgs e)
{
lblLocalTime.Text = TimeZoneInfo.ConvertTime(GetTime(), ServerTimeZone, GetLocalTimeZone()).ToLongTimeString(); //local time (long time string)
newServerTimeZone = ((TimeZoneInfo)lbxTimeZones.SelectedItem);
lblSelectedTimeZone.Text = newServerTimeZone.StandardName;
lblSelectedTime.Text = TimeZoneInfo.ConvertTime(GetTime(), ServerTimeZone, newServerTimeZone).ToString(); //refresh selected time
}

private void lbxTimeZones_SelectedIndexChanged(object sender, EventArgs e)
{
lblLocalTime.Text = TimeZoneInfo.ConvertTime(GetTime(), ServerTimeZone, GetLocalTimeZone()).ToLongTimeString(); //local time (long time string)
newServerTimeZone = ((TimeZoneInfo)lbxTimeZones.SelectedItem);
lblSelectedTimeZone.Text = newServerTimeZone.StandardName;
lblSelectedTime.Text = TimeZoneInfo.ConvertTime(GetTime(), ServerTimeZone, newServerTimeZone).ToString(); //refresh selected time
lblSelectedTimeZoneExt.Text = lbxTimeZones.SelectedItem.ToString(); //display TimeZoneInfo as viewed in ListBox for clarity
}
}
}

Mini Explosion code sample for Corona SDK

I have a nice easy example of Sprite Animation with sound for the Corona SDK.

Example uses: display.newImage, display.newText, graphics.newImageSheet, addEventListener, audio.loadStream, addEventListener, etc.

Download it here: mini Explosion

You too can build games and business apps. Check this out! It’s Free!

https://coronalabs.com/products/corona-sdk/

1 2