My New Project

Hello all, I hope as you read this blog post all is well in your world, and that hopefully reading about some video game architecture might alleviate some of the stress in your life. I’ve talked about a few projects on this site before, but usually just the specific code or concepts that I contributed to the project. However, this is different. Throughout all of last week, a friend and I were ping ponging ideas off of one another until we came up with an expandable mechanic system, a design to foster that system, and an aesthetic that we hope to use to tell a compelling narrative.

Why is this project special? It’s not. It’s just a small game project with a buddy. This happens all the time. I know that. But it’s special in that I’ve written every script that goes into a simple game, which is significant because I’m starting from scratch and able to take who ever might be reading this, along with me.

The Game:

  • Mechanics built around affordances of the Keyboard.
  • Players will control 2D top down sushi chef with right hand
  • Players will engage in unique “active interactions” with left hand by dragging fingers along keyboard in specific patterns, as specified by each individual “active interaction”.
    • Example: Dragging your pointer, middle, and ring finger along the “QWE” keys and downwards (to “ASD” the to “ZXC”) to simulate the rolling of sushi.
  • Perfection of mechanics yields higher rewards to the player
  • Player will engage in various acts involved in being a sushi chef, from cutting rolls to purchasing fish, and live out a life controlled by the daily requirements and upkeep.

The Aesthetics Pitch: So far most energy has been aimed in the direction of building a system of solid mechanics and enjoyable gameplay, however this is what we DO have for aesthetic: You are a sushi chef, and run your own small shop where people often come and go. You live here, because you always work. However, after a disease sends your nation into quarantine, your daily life becomes controlled by a checklist of repetitious tasks.

NOTE: I’m not an artist, most of the assets being used in my game are from this pack. Very great assets. The Player animations and art are done by Shad.din. I’m actually working with Shad.din to get more animations for the player, and more that pertain specifically to this game.

Engineers Corner

This game is my child. I’ve written every piece of code in it, and I’m very very excited to share it with you. In fact, I’m so excited I’m actually going to make available my Engineering Manifest for this project, which will be live updated with all new content. HERE is the link! In this manifest you will find a comprehensive breakdown of all the architecture at work in the project. On my site, however, you will continue to receive deep dives into specific scripts and concepts, they will just likely all pertain to this game project for the time being.

Where and When Can I Play? I will post the first “early early” build on this site, soon… at the time of this post (check that link above, it’s definitely different now) I have constructed and implemented all the architecture necessary for the unique style of input which this game is built on. It has been implemented in 2 unique “active interactions”, with just very early UI and animations. The player controller and animator are finished. And then of course, SODA is completely implemented, making the entire project modular, adjustable, and “dependency free”…. okay maybe a few dependencies.

UPDATE: Playable Build HERE

Where is the Beef? I get it, why come to this post if there’s no code talk. I respect that. Well, let me tell you about InputGrouping. InputGrouping() is a class I wrote for this project which allows us to detect input from specific, pre determined, groupings of keys. So think, how would you go about detecting when the player presses “Q”, then “A”, then “Z”? Did someone say new List<KeyCode>();? That person is wrong and stupid, you would use a new InputGrouping(); Because it does all the work of a List and more. So with that in mind, try to understand what’s going on here, and how I must be using it.

/*
 * An InputGrouping holds the keycodes necesary to execute a specific Advanced Interaction
 * 
 * This will be used by our InputManager Script
 */

using System;
using UnityEngine;
using System.Collections.Generic;



public class InputGrouping 
{
    //List of they keys sought by advanced mechanic, in order.
    public List<KeyCode> desiredInput = new List<KeyCode>();

    //InputGrouping will track it's own "progress" if keys are to be pressed in order
    public int currentStreakInt;

    public KeyCode GetNextKey(int placeInList)
    {
        //Should always be true
        if (desiredInput[placeInList] != null)
        {
            return desiredInput[placeInList];
        }

        //Debug section
        Debug.Log("Input Grouping value could not be found.");
        InputGroupingDebugger();
        return KeyCode.Backspace;

    }

    //Allows us to add keys to the list
    public void AddKey(KeyCode keytoBeAdded)
    {
        //Adds keycode to List
        desiredInput.Add(keytoBeAdded);
    }

    //Returns the size of the array, starting from 1
    public int GetSize()
    {
        return desiredInput.Count;
    }

    //returns progress through List
    public int CurrentStreak()
    {
        return currentStreakInt;
    }
   
    //Increases progress through List
    public void IncreaseCurrentStreak()
    {
        currentStreakInt++;
    }
    //Resets progress through List
    public void ResetCurrentStreak()
    {
        currentStreakInt = 0;
    }

    //Returns true if all keys in desiredInput are being pressed
    public bool AllKeysPressed()
    {
        //Int of how many keys are down 
        int keysCorrect = 0;

        //Iteractes through keycodes
        for(int rep = 0; rep < desiredInput.Count; rep++)
        {
            //increments int if key is registered
            if (Input.GetKey(desiredInput[rep]))
            {
                keysCorrect++;
            }
        }

        //Returns true if int matches desiredInput count
        if(keysCorrect == desiredInput.Count)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
 

   //call for multiple frame window and save highest return
   //Returns how many keys are pressed in List
    public int TotalNumberPressed()
    {
        //Int of how many keys are down 
        int keysCorrect = 0;

        //Iteractes through keycodes
        for (int rep = 0; rep < desiredInput.Count; rep++)
        {
            //increments int if key is registered
            if (Input.GetKey(desiredInput[rep]))
            {
                keysCorrect++;
            }
        }

        return keysCorrect;
    }


    public void InputGroupingDebugger()
    {

        Debug.Log("InputGrouping Debug report:");
        for(int rep = 0; rep < desiredInput.Count; rep++)
        {
            Debug.Log("desiredInput[" + rep + "] = " + desiredInput[rep] + ". ");
        }

        Debug.Log("Report complete. Have a nice day!");
    }

}

It’s not too complicated, but given that my game is heavily dependent on specific keystroke patterns, InputGroupings have proven extremely successful in managing the mess that can come of dealing with complex input detection. And so for an example of how this script appears in my game, I’ll give some snippets below. to note in this code: desidredInput is the name of the List<KeyCode> contained in InputGrouping, as well as currentStreakInt is the internal int which iterates through the List.

            //InputGrouping qazKeys
            if (Input.GetKeyDown(qazKeys.desiredInput[qazKeys.currentStreakInt]))
            {

                //Sets current streak plus 1
                qazKeys.IncreaseCurrentStreak();

                //Resets internal clock, giving player more time to link interaction
                internalClock = Time.time;

                if (qazKeys.currentStreakInt == qazKeys.GetSize())
                {
                    //Begin Interaction
                    Debug.Log("QAZ Input Detected. MakiMaker in range? " + makiMakerInRange.ToString());
                    ResetAllStreaks();

                    if (makiMakerInRange)
                    {
                        //Raise Event
                        makiMaker.Invoke();
                    }
                    
                }
            }

Of course you would have to see some SODA in my scripts. In case you’re unfamiliar with that makiMaker.Invoke() I highly urge you to check out some of my other posts about Scriptable Object Dependent Architecture. Well… that’s it for now. I hope that you enjoyed this post as much as I enjoyed sharing with you. And please check in for updates about the game, including playable builds! Wash your hands!

Image from Asset Pack we will be using, by GuttyKreum, linked above.

3 thoughts on “My New Project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s