Thursday, April 19, 2018

Game of Life, Part 1

Step one: Storyboard

  1. Create a new Xcode app from scratch, iOS Single View Application, Swift.
  2. In the project settings, uncheck the landscape orientations so the app will work only in portrait mode.
  3. On the storyboard, add a UIView (View).
    1. Give it 1:1 aspect ratio
    2. Give it a background color so you can see where it is
  4. Add a caption above the square UIView that says Game of Life or something appropriate.
  5. Below the UIView, put 6 buttons in a row that say: Clear, Start, Stop, Step, +, and –. 
  6. Put the 6 buttons into a Stack View.
  7. Put the buttons, the UIView, and the caption into a Stack View.
  8. Add constraints to the main stack view, using the I-beam tool, to keep it 8 px away from the right and left edges of the screen.

Step two: Code

  1. Add a new file: 
    1. Cocoa Touch Class, 
    2. Derived from UIView,
    3. call it CellView. Be careful of upper and lower case letters here.
  2. Attach the new CellView class to the UIView on the storyboard.

Step three: figure out how to draw a grid.

  1. Math

No comments:

Post a Comment