Conferences for Spring 2018

I’ve gotten a little behind on my goals for this blog recently. I have several upcoming conference appearances that I am preparing for that are absorbing a bunch of my time.

In trying to keep with the spirit of posting at least once a week, I am announcing my future appearances so if you want to say hi you have the opportunity to do so and I get to keep my streak alive!

NVIDIA GPU Tech Conference (GTC): March 26-29

First up I have GTC in San Jose. I am leaving for this on Sunday.

GTC is the first conference I have attended in a while where I am simply an attendee. I don’t think I have been a conference attendee since 2013. I have always either volunteered to work the conference or spoken.

GTC is focused on cutting edge GPU technologies including VR, autonomous driving, and deep learning. There are like 600 sessions and various labs, both self directed and instructor led.

I am trying to branch out beyond just iOS programming conferences. I started that last year with GDC (the game developer conference.) This is the first GPU programming conference I will have attended. I am deeply interested in seeing all the use cases for GPU programming to get a better idea about how to channel my energies in this field. Right now I feel rather overwhelmed by what is out there and I am eager to see what possibilities exist in this space.

RWDevCon: April 5-7

Up next I have RWDevCon. I last spoke at RWDevCon in 2016, but I came as an inspirational speaker. This year I am tackling a much harder task. I will be leading a 90-minute guided tutorial on how to integrate Metal shaders into SceneKit code so that you’re not responsible for setting up the entire rendering pipeline.

I will also be recording a live podcast with my cohost on the Ray Wenderlich podcast, Dru Freeman. It’s going to be a hectic, busy conference, but if you’re a fan of the work the Ray Wenderlich team does, this is an invaluable opportunity to meet the team in real life.

UIKonf: May 13-16

UIKonf is my first European conference of the year. It’s also my first international conference in a country where English is not the native language. (I was privileged to speak at two conferences in the UK last year.)

I have not yet determined what I will be speaking about, so I can’t give a lot of details on this. Planning for RWDevCon is occupying most of my available free time and energy.

WWDC? Nope!

I delayed this blog post until after I had determined if I had won a ticket to WWDC. I did not win the lottery this year, which leaves my record and 0:3. I am trying not to be too disappointed or be upset in a few months when everyone is tweeting about the amazing time they are having. But I promise nothing!

Conclusions

As much as I enjoy going to conferences and seeing my friends, it’s really put a pin in the work I would like to be doing right now. I can’t finish my game because I have slides and presentations to finish. I am feeling incredibly listless and upset because I feel I am not accomplishing anything and it bothers me tremendously. I am hoping after I get these two conferences out of the way I can get back to doing things that make me happy and productive.

Looking forward to seeing friends old and new over the next few weeks!

Pizza and Video Games March 2018: Portal

The first entry in my Pizza and Video Game series was pretty much a no-brainer. I wanted a relatively short game that was iconic and not brutally hard. The best representation of all of my parameters is the game Portal.

Portal was released just over a decade ago. It is a fairly short puzzle game where you wake up in a laboratory and run through several experiments testing a new device that creates “portals” within the laboratory. You eventually control the entry and the ending point of these portals in an attempt to navigate through the levels of this experiment. Some surfaces are portal-able while others are not. Sometimes you need to utilize momentum and physics to fling yourself further.

There are a few common design elements for all of the puzzles in the game:

  • Moving blocks from one room/inaccessible space to another
  • Using physics to fling yourself by going through multiple portals or jumping off cliffs
  • Utilizing fireballs to hit inaccessible targets

These start easy, but then build on one another to create increasingly complex puzzles. The game is very well designed. There is no point during the game where you feel that things are unfair or require knowledge you have not accessed. You can figure out what you’re supposed to do without feeling like the designers were smoking The Crack.

One issue I personally had with Portal is that there was a point at which I could not continue with the game. I could only get through level 17 when the puzzles became too difficult. They weren’t difficult in regards to the logic required to figure out what the solution was. They were difficult because they required a degree of fine motor skills and coordination that I simply don’t possess.

I have tried getting through Portal several times, but I always got stuck at a certain point because I couldn’t do things fast enough to pass certain levels. The Boyfriend noticed that I tend to not use the controls properly. He noticed that I would work the camera and the movement controls independently rather than synchronously.

We are going to start working through the Halo because that is one of the first games to utilize the camera and movement controls together so that I can get more used to this design pattern in games.

Even beyond my lack of experience and comfort with the controls, the game becomes significantly more difficult in the later levels. I had spend several years hearing people tell me that Portal was a very quick and easy game. I went in with the expectation that it would be so, only to run into a brick wall towards the end of the game. I wound up having The Boyfriend complete the last two levels of the game for me. Otherwise I may not have finished. Or if I had it would have taken all weekend. There are a few incredibly fidgety puzzles that required an incredible amount of timing and precision. I know a lot of gamers really want a challenge, but it would really be nice to have something that would be accessible to people with physical impairments who can figure out the puzzle but can’t react as quickly.

It was interesting to see a lot of patterns in Portal that are “borrowed” by other games. The secret rooms with the warnings about the AI and the cute song at the end of the game feel kind of like the post-credit sequences in Marvel movies. They were a completely new thing a decade ago but have been used by so many people in the intervening years that it’s hard to remember how innovative it was at the time.

I did also appreciate that the two characters in the game were both female. The AI being female I understand. Between Siri and Alexa it’s just kind of a default for computers to have female voices, but the choice to make the protagonist female was really cool. I always appreciate it when creators don’t just default to male protagonists, even though in this case you only see Chell in passing if you see yourself before you go through the portal.

Conclusions

I feel our first Pizza and Video Game day was a success. I feel like Portal was the perfect kind of game to do for something like this. I am a little sad that so many gamers feel like games have to be a hundred hours long to be worth the money. I worry about the number of games that I can actually get done in a day, but I will worry about that another time. For now, I am glad I finally got to see all of Portal, even though I didn’t complete it myself. Until next time!

Monthly Pizza and Video Games

Back when I was a kid we didn’t have any video game consoles. My parents thought they rot your brain and were expensive, so we didn’t have a Nintendo.

My brother and I had a home daycare woman who had four kids and I swear bought every video game system ever. Every time a new system came out within a few weeks one would magically appear at their house. I was never allowed to play with it because it was “their” system, but I was allowed to watch them play from the couch.

One day that we had off from school the older kids went out and bought a bunch of junk food to eat in the basement. They had a bunch of friends over to play games and eat junk. They actually let the younger kids hang out with them and shared junk food. This was the only time in my childhood where I felt like I was part of a group of people doing normal things having fun. I told myself that when I was in high school I was going to have a gang of friends who would come to my house and play video games and eat junk food. I didn’t process that I lived in a rural town where I already knew all my future high school classmates and that I didn’t get along with any of them and that this would never come to pass.

It’s been a thing I revisit sometimes. My ex-husband decided he was over video games by the time we got together and wouldn’t play with me. I bought a few systems after the divorce and really got into the Persona series, but I didn’t have people to play games with. Luckily, my new boyfriend likes video games and I finally have someone to play games with.

So we decided to institute “Pizza and Video Games” days. The first Saturday of every month, we are ordering a pizza and playing a video game. We’re limiting the amount of junk food we do in a day because, frankly, my digestive system can’t handle it as well as it used to. We want to try all the various pizza places around us so we’re not just ordering from the same place every month.

We have a few parameters we’re looking for when considering a game for Pizza and Video Games day:

  • Console Game: Primarily looking for a game that would be played on the TV through either a PS3/PS4/Xbox 1/Steam. I have a vast multitude of 3DS/Vita games that I play in the bath or while I am traveling and these are not candidates for Pizza and Video Game days. Not sure about Switch games yet as they’re in a gray area.
  • Short: I’m looking for games that can mostly be played in a day. I’m sure the Assassin’s Creed games are awesome, but I wanted to focus on trying to find a game that could mostly be completed within a day.
  • Relatively Easy: I didn’t grow up playing video games, so I am not looking for the most brutally hard games I can find. So no Super Meat Boy or Celeste. These are probably awesome games, but I would die like two seconds in and that would not be fun.
  • Variety of Genres: I have mostly played adventure games in my time as a gamer. These are games that don’t really require a lot of coordination or motor skills. They just involve walking around solving puzzles. These are great games, but I am trying to expand outside my comfort zone and try different things I am less familiar with. We are not going to just do first person shooters, but I would like some experience with these as they’re a large chunk of the video game landscape.
  • Important Historically: There’s like 40 years of video game history that I need to work through to become familiar with current game design patterns. I’m basically trying to find someone’s top ten list of the most important video games and focus on those as a jumping off point so I can see how these games influenced the landscape.

We may not be able to satisfy all of these requirements. These are more like suggestions or guidance questions as opposed to set in stone rules. We’re also going to try to do more games together after work on a regular basis. There are longer games like Mass Effect that I would very much like to work through that I will be writing about in the future, but not as part of this series of articles.

These do not need to be new/recent games. I would like to go back and play through the Super Mario Brothers games on the original NES. Since I have an NES emulator, this shouldn’t be a problem.

Games were designed to be a social thing to bring people together. You can play on your own, but having a community of people to share your experiences with is a vital part of the gaming experience. I didn’t get to have fun game days in high school, but it’s never too late to find a community of people to have fun with. I’m glad I finally found one.

Tic Tac Toe: Graphics, Labels, and Animations

I have a roughed out version of my tic tac toe game running. If my point was to just get something working, I could call it a day at this point. However, the goal I have with this project is to put together a somewhat professional game. This requires a lot of polish and a lot more work.

The focus I have in this blog post is to do the biggest immediate thing I can do to make this look like a real game. This includes real graphics and not just colors that I used as placeholders. I also want to give the user feedback about whose turn it is and what the state of the game is. Additionally I want to add some interest to the game with animations so it feels more responsive than it does now.

Graphics

This section will focus on incorporating graphics. I got a graphic design degree ten years ago and I haven’t used it much in the last decade. One of my longer term goals is to work more with graphics programs so I can get more comfortable with them. But for this project I am opting to use assets created by other people.

One resource I like a lot is Game Art Guppy. If you have worked through any tutorials from Ray Wenderlich, then the art on Game Art Guppy should look familiar. Ray’s wife Vicki did all of the art assets for the site for a number of years. Game Art Guppy is her market for low cost art assets for developers. Many assets on the site are free and none are over $25.

Since my other major hobby is cooking, I decided to use the pastry icon set from the site for my squares. I know Xs and Os are traditional, but I want this to be whimsical. There is a correlating background that goes with this tile set. These assets were used in an epic Candy Crush tutorial on Ray’s site. I highly recommend it because I learned a lot from working through it.

First I placed the background image behind the board. When I initially added the background it covered the other parts of my board, so I made its z-position -1 so that it would appear behind the board:

let background = SKSpriteNode(imageNamed: "bg_ipad_portrait")
background.zPosition = -1
addChild(background)

I chose the donut and one of the sugar cookies for the Xs and Os because they kind of looked a little like Xs and Os. I want to keep the white background but just apply the texture on top of it. I also want to animate the tiles, but that will happen later. Here is the code I used to get this working:

switch currentPlayer {
    case .playerA:
	let playerTile = SKSpriteNode(imageNamed: "pastry_donut_320")
	playerTile.scale(to: node.size)
	playerTile.position = CGPoint(x: node.size.width / 2, 
				      y: node.size.height / 2)
	node.addChild(playerTile)
	board[tiles.index(of: node)!] = .playerA
    case .playerB:
	let playerTile = SKSpriteNode(imageNamed: "pastry_starcookie02_320")
	playerTile.scale(to: node.size)
	playerTile.position = CGPoint(x: node.size.width / 2, 
				      y: node.size.height / 2)
	node.addChild(playerTile)
	board[tiles.index(of: node)!] = .playerB
    case .notPlaying:
	node.color = UIColor.white
	board[tiles.index(of: node)!] = .notSelected
}

Each player has a pastry associated with them. If I just change the texture of the containing node to the pastry icon then they will appear to float in space, so I am making the pastry a new sprite and making it a child of the containing node. The pastry icon is way too large to fit inside the containing node, so it needs to be scaled to fit within the tile. Additionally, the anchor point of the tile is in the bottom left, so I am positioning the new sprite to sit in the middle of the sprite node.

Finally, I want to have a real app icon. I always forget to make a generic one for sample projects and tech talks and it constantly bothers me. When I see other people went to the trouble it makes me feel crappy and inadequate, so really wanted to make sure I did that on this project.

I chose the sugar cookie as my main focus on the app icon because I thought it was the more visually interesting sprite in the set. I used Illustrator to place the sprite in the view and exported it as PNG. I then used Photoshop to change the size and apply the correct labels to each size. I believe Illustrator has an option to do all of this in one step, or a least fewer than I did, but I didn’t figure out how to make that work. I have been told Sketch does this as well, but I don’t own it and I’m unfamiliar with it, so I used the thing I am comfortable with.

Labels

I want to use a label at the top of the screen to give information to the user. I want to be able to tell the user which player’s turn it is and how the game has ended. Right now I am just printing it out to the console, but that can only be seen by me when I run this in the simulator.

SpriteKit has a specific node for labels. I created one inside the class declaration but outside of any methods:

let label = SKLabelNode(fontNamed: "Noteworthy-Bold")

I created a backing image for the label, which I need to add as a sprite node to the main node hierarchy:

let labelBackground = SKSpriteNode(imageNamed: "headerBacking")
labelBackground.zPosition = 2
labelBackground.size = CGSize(width: boardSize, height: 60.0)
labelBackground.position = CGPoint(x: 0.0, y: (boardSize / 2.0) + 100)
labelBackground.anchorPoint = CGPoint(x: 0.5, y: 0.5)
addChild(labelBackground)

I need to add the label node as a child of the label background node. I set the anchor point for the label background to the middle of the node so that the text can be placed in the center of the node.

label.text = "Tic Tac Toe"
label.fontColor = SKColor.black
label.fontSize = 40
label.zPosition = 10
label.position = CGPoint(x: 0.0, y: -20.0)
labelBackground.addChild(label)

I want raw string values associated with both my player state and my win state so that I can post them in the label for the user. Here are my updates to my state enums:

enum GameState: String {
    case notPlaying
    case playerA = "Player A"
    case playerB = "Player B"
}

enum GameEndState: String {
    case playerAWin = "Player A Wins!"
    case playerBWin = "Player B Wins!"
    case draw = "Draw!"
}

I tried attaching an observer to the current user to update the label whenever the current user changed, but that not only resulted in never telling the user that the game was over, it also didn’t prevent the game from continuing. Instead, I explicitly update the label in the line of code after I update the user. I do this in the initializer but I also have to do that on the touch event:

if let isWin = checkForWin(currentPlayer: currentPlayer, board: board) {
    label.text = isWin.rawValue
    isUserInteractionEnabled = false
} else {
    currentPlayer = switchPlayer(currentPlayer: currentPlayer)
    label.text = "\(currentPlayer.rawValue)'s Turn"
}

Previously I was checking for each specific win condition, but since that is being tracked in the raw value I can just post the end state in the label. I don’t want the player to continue to play if the game is over, so I need to disable user interaction. If the game isn’t over, then the current player switches and the label updates.

Animations

Next I want to animate the tiles as they are selected. This works, but it’s a little boring. It’s also a little abrupt to just have an image pop up when you touch a tile. Adding an animation to the action really gives a bit of life to the application.

One thing that confused me greatly about SpriteKit was how animations were done. I knew that animations had to be a huge component of SpriteKit, but there was no SKAnimation class. I thought maybe this descends from UIKit and you would need to use Core Animation to get this to animate. After some digging I found that there is an animation class in SpriteKit, but it’s called SKAction. Why they changed it, I can’t say. People just liked it better that way.

At some point I would like to do a dedicated blog post to SKAction, but for this project I am trying to simply focus on doing what I need to for the effect that I want. I want to create some kind of transition in with the sprites so they don’t just pop out of nowhere on the tiles. I want the sprite to fade in. I also want my sprite to scale up and kind of pop out a little before scaling back to the proper size.

First, I pulled a few properties out of the code blocks that I need to calculate my actions:

let nodeSize = node.size
let largeNodeSize = CGSize(width: nodeSize.width + 30, 
			   height: nodeSize.height + 30)
let spritePosition = CGPoint(x: node.size.width / 2, 
			     y: node.size.height / 2)

Next, I created my action outside of my switch statement. I want to use the same actions for both Player A and Player B, so there isn’t any point in creating those in-line. I wanted to place them outside of the touches method, but there are properties on objects that I need to check inside that method, so the actions are declared there.

SKAction has two ways of grouping actions together: Groups and Sequences. Groups are actions that need to run together at the same time. Sequences are actions that run one after another. I need to utilize both groups and sequences for my sprite animations. The scale up and scale down need to be part of a sequence because one follows the other. That sequence has to be grouped with the fade in so that it sprite both fades in and scales simultaneously.

Here is my action code:

// Actions
let fadeAction = SKAction.fadeIn(withDuration: 0.75)
let scaleUpAction = SKAction.scale(to: largeNodeSize, duration: 0.5)
let scaleDownAction = SKAction.scale(to: nodeSize, duration: 0.25)
let scaleSequence = SKAction.sequence([scaleUpAction, scaleDownAction])
let actionGroup = SKAction.group([fadeAction, scaleSequence])

You may notice that there is no code here to specify what the starting scale is for the sprite. That needs to be set when the sprite is created. My refactored tile sprite code now looks like this:

case .playerA:
    let playerTile = SKSpriteNode(imageNamed: "pastry_donut_320")
    playerTile.setScale(0)
    playerTile.position = spritePosition
    node.addChild(playerTile)
    playerTile.run(actionGroup)
    board[tiles.index(of: node)!] = .playerA

Music and Sounds

The last bit of polish I want to add to the project is music and sound effects. One interest that I have in game development is doing music and sound effects. Before I went into programming, I went to school for audio engineering and video production. My specific area of interest was sound design. I loved to sit down with an animated scene and remove all the sound and add it back as a project. One of my sound design projects can be seen here.

I need more practice to get back up to speed with sound design, along with graphics and illustration. Those are concerns for another time. But needless to say, I understand the value of music and sounds to making something feel like a finished product. So I wanted to make sure I had nice sounds for the game.

I want background music and I want a nice little “popping” sound effect for when the sprite pops into the tile. I don’t have time right now to make my own sounds or music, so I needed to find decent free sounds and music to include in the project. I don’t assume that if you find something online that it can be used in any way. I make sure that the creator has given permission for the use I have. I am willing to buy music and sound effects, if anyone reading this has any suggestions about good places to find resources.

I found the tile popping sound at Sound Effects Plus. The sounds are free to download. Their licensing and restrictions are available here.

I found my music at Incompetech. I discovered this site through Paul Hudson. He mentions the site, along with a few other good resources, in his SpriteKit book, which I reviewed here.

For the tile popping sound, I want to make sure the pop happens at the right time. I tried simply calling it at the same time the animation was happening, but because the sound was so short, the “pop” was happening while the sprite was still growing. I resolved this by adding it to my scale sequence:

let soundEffect = SKAction.playSoundFileNamed("pop.wav", waitForCompletion: false)
let scaleSequence = SKAction.sequence([scaleUpAction, soundEffect, scaleDownAction])

Finally, I added my background music to the game. Not a lot of people have written much about audio mixing in SpriteKit, so that might be a thing I do in the future. I want to be able to lower the volume of the background music so that it doesn’t drown out the sound effects, but I am not certain how to make that work. I tried a few things but none of them worked, so for now I am simply adding the sound when the application begins:

run(SKAction.playSoundFileNamed("Carpe Diem.mp3", waitForCompletion: false))

I feel comfortable with my control of SKAction for animations, but I am not happy with my control of it for sounds and sound effects. Want to research this further.

Conclusions

You can see the current state of the project here.

In total I spent under ten dollars on assets for this game. The sound effect and background music were free. The tile set was nine bucks. I am honestly kind of shocked at how much better this looks with just a minimal amount of work using assets I found on the internet.

For now this isn’t completely done. I still don’t handle what happens when a game ends in a way that I find satisfactory, but that is a chunk of functionality I intend to tackle in a future blog post. However, this did come along pretty well and I am happy with the results so far.