An introduction to Generic Game Model
-
Upload
martin-grider -
Category
Software
-
view
906 -
download
2
description
Transcript of An introduction to Generic Game Model
An introduction to Generic Game Model
Martin Grider Abstract Puzzle LLC
What is GGM?• A small collection of re-usable classes for native
2D game development in iOS.
• Primarily (exclusively) uses UIKit.
• Facilitates rapid 2D prototyping.
• Allows you to think almost exclusively in grid coordinates rather than pixel coordinates.
M(VC) for 2D games• Model
• various properties I find useful for games: gameIsPaused, gameIsOver, gameDuration, score
• each grid element (x,y) has an integer “state”
• View
• knows how to display each state
• translates user input to the model
pod ‘GenericGameModel’
• GenericGameModel is installable via cocoapods.
• Also available here: https://github.com/mgrider/GenericGameModel
• Example project shows you how to do stuff.
GGM_BaseModel• Subclasses BaseModel
• [self.game save]; — does all the encoding stuff or you.
• Game states are stored in a multidimensional array of NSNumber objects.
• int s = [self.game stateAtX:x andY:y];
• [self.game setStateAtX:x andY:y toState:newState];
• Typically use key/value observing for score, sometimes for GameIsOver. (Yes, this should be isGameOver, this, among other things, needs refactoring.)
GGM_UIView• setHandlesTaps:YES — detect tap input
• override handleTapAtX:andY: in your subclass
• setHandlesDrags:YES — detect drag input
• override handleDragStart, handleDragContinue, and handleDragEnd in your subclass.
• setGridType — supports backgroundColor/UIImage/UILabel/Hex shape
• Individual views themselves are often another custom UIView subclass that draws its own state.
GGM History• Conceived in 2012 because I
was writing very similar “model” code for all my games. (At the time I was working on both For the Win and Oppo-Citrus.)
• Really got its start at the Overnight Game Jam at 360iDev in 2012.
1st use, Cloud Growth, september 2012 —>
GGM History, p.2• Second use was
for a Ludum Dare (another game jam) at the end of 2012.
• Subclassed GGM_UIView to support isometric display. 2nd use, Henchmen, December 2012
GGM History: DrawCade• Jan 2013 updated
DrawCade, my drawing application for the iCade, to use GGM classes.
• Took less than a day to refactor/rewrite to use GGM.
• Spent another two days making it universal.
GGM History: Catchup• Jan 2013 — started
working on Catchup (then Ketchup), a hex-based board game conversion for 2-players.
• Uses GGM_HexView
• Still in work in progress.
GGM History: RE@L Match• In 2013, built a series of kid’s
educational games around the mechanic of matching tiles in the “sliding hole” puzzle.
• 3 apps published Dec 2013:
• Numbers & Words
• Numbers & Counting
• Counting & Words
• States come not from the GGM_BaseModel subclass.
GGM History: Root Down• December 2013,
published Root Down, an original 2-player board game.
• Prototyped initial game in an evening. ~6 hours.
• App store version took maybe another 4 hours.
GGM History: Poker Game
• Feb / March 2014, built this poker variant application.
• Client project
• ~6 weeks
GGM History: Action Go
• Jan 2014, ported my first game, Go-Tetris (originally a flash game) to iOS.
• ~4 weeks spent in development so far.
Quartz “Juicing”• Juicing just refers to visual effects, or pizazz.
• Some cocoapods to check out:
• AGGeometryKit
• UIView+EasingFunctions
• Squash