Some Skeleton Logic

The premise for BugCatch is pretty simple. Kids are presented with a virtual playing area many times the size of the phone’s screen. They are tasked with searching the landscape for certain bugs that they need to either catch or squish. A small HUD will give them access to a few implements to switch between (such as jars/nets/shoes/hands) to accomplish this. Scrolling will be done by swiping across the playing area. Catching or squishing is just a simple tap on the moving bug. Different bugs will move in different ways and be harder/easier to catch depending on type and difficulty level.

I jotted some notes this afternoon with some pseudo-code for some of the core methods in the game engine.

Init()
    clearInput()
    resetState()
    GameLoop()

resetState()
    if NEVER INITIALIZED then init
    setLevel()
    setGoals()
    createBugList()
    setBugListState()

GameLoop()
    getInput()
    updateActions()
    updateAI()
    updateGameState()

getInput()
    if INPUTS
        store action

updateActions()
    if SWIPE
        move background
    if TOUCH HUD
        hittest catcher
        hittest options
    if TOUCH PLAYAREA
        hittestBugs()

hittestBugs()
    foreach BUG
        if HIT
            goalCheck(bug)
            tagRemoveBug

goalCheck(bug)
    foreach GOAL
        if GOAL +matches bug
            satisfyGoal()
        else
            exposeError()

updateAI()
    foreach BUG
        if TAG REMOVED
            removeBug
        else
            moveBug

updateGameState()
    updateTime
    checkForGoalsComplete
    checkForEndOfTime

    if GOALS COMPLETE
        winGame
    if END TIME
        loseGame

setLevel()
    setCompleteTime()
    setHitboxSize()

setGoals()
    createGoalsList(level)
        randomly select a set of goals, taking into account level
        select time limit based on level

setBugListState(level)
    inspect goals
    select bugs req'd for goals
    select additional bugs not required based on level.
    create random distribution based on level (lower level == greater percent bugs req'd for goal)
    populate bug array.