Spike Hopper

In 8th grade, a friend and I shipped an iOS game called Spike Hopper—a score-chaser where players jump over randomly generated spikes on an ever-accelerating floor. My responsibility was handling the code and game mechanics, such as randomly generating spikes, while my friend created the graphics.

We'd already built a teaser app the previous year that swept through our school, filling Game Center leaderboards with nearly every kid's name. When Spike Hopper launched, almost all of them came back—as well as some new faces.

Making the game was like playing a game for me. Take for example this died() function. I would probably call it something more like gameOver() nowadays to be more polite—but it's good to know my younger self was already thinking in terms of logic, variables, and state changes while having a bit of fun.

Died Code

//What happens when you die
    
    func died() {
        
        floor_speed = 0
        floor_speed_substitute = 0
        spike_speed = 0
        spike_speed_substitute = 0
        phoenix.removeFromParent()
        
        audioPlayerding.stop()
        audioPlayermusic.stop()
        
        //Sets up transition
        
        let transition = SKTransition.fade(withDuration: 2)
        
        //Sets the high score number if needed
        
        if (score > HighScoreNumber) {
            UserDefaults.standard.set(score, forKey: "HighScoreSaved")
            UserDefaults.standard.synchronize()
            HighScore = score
            saveHighscore(score: score)
        }

        
        //loads the scene in the class "GameScene"
        
        let scene2 = gameover(size: self.size)
        let skView2 = self.view as SKView!
        skView2!.ignoresSiblingOrder = true
        scene2.scaleMode = .resizeFill
        scene2.size = skView2!.bounds.size
        skView2!.presentScene(scene2, transition: transition)
    }
						

Reading through this code, I realized how much I've grown as an engineer over the years. I was confused about the floor_speed_substitute, until I remembered it was a redundant variable I created for recalling the floor speed when the game was paused. Today, I would've created a boolean to determine if the game was running and base the floor speed on that.

I won't pretend I wasn't keeping score. Watching my classmates compete over something we'd built from scratch felt like the best possible proof that an idea in my head could become something real in someone else's hands.

That's still why I build things.

While it's not on the App Store anymore since my old developer account expired, the archived source code can be found here: https://github.com/emurray2/SpikeHopper