My Nuts Programming


Name: Davon Miller

Lead Programmer of My Nuts!!!


I would like to start off by saying I'm a total noob at programming and this is my first time doing so for a project like this . What I've learn throughout this is to have patience and take things in smaller pieces instead of doing this all at once. When it comes to creativity there is no cut off point with me at times and I just need to have constraints and work at a steady pace. Now on to what you came here for the progress of this game. The base of this project is just to keep things simple like the Game & Watch games of the past. So what I've done is begin with a simple start menu, nothing too complicated and not to overdrawn with clicking.  As you can see in the screenshots for now it's just the title and where the player should click. Where it says click to start I attached a blinking script so it blinks and when ever the player hovers over it turns black. Along with going to the next scene which is the main menu to get to the meat and potatoes of the game. In addition to adding a quit option when the player wants to exit the application after playing, with a simple press of the escape button.

Start Menu



Quit Option


After clicking  click to start  this leads to the main menu. Where I implemented level selection of the single player, and multiplayer. Along with the options  for the player  to make the game more of their style and a credits button to lead to the credits scene for the end game  and see who've helped or made this game. In the beginning I've thought the set up of clicking a button  to go to the level select scene, then clicking the button to get to that level. After receiving some feedback I've decided to do a simple drop-down within the same scene so it's easier for the player to get to each level instantly. 

Main Menu


Options Menu


Credits



Now for the main event the actual level itself and game mechanics. The overall premise of the is game is a 2D, pixel art, one screened, collection game. Where the player is a squirrel that collects nuts to prepare for the winter. Each level will have weather conditions except the first. If the player misses collecting a nut the player loses a life and if this happens three times game over. In order to win the player has to store the nuts gather which the player can collect two if they wish and place it in the bank the score increases. Once the desire score is reached the player wins and on to the next level. As of now in order to regain the player's health is a work in progress.  

What I've implemented was using the UI game components to display Score & Collection amounts. As for how to obtain the nuts and fruit I've made them spawn and  us transform.translate to control the speed, and the direction of how they fall.  As for the player, the movement only consists of using the horizontal axis that is build in Unity. Which is from left to right using the A and D buttons or Left and Right.  Along with those controls I've implemented a jump button using the space button as well by controlling the gravity, jump speed in the inspector. Also the movement speed of the player is controlled in the inspector as well.  In order to obtain the objects of the nut and fruit they both use  OnTriggerEnter  for collecting, storing and lost and gain of life . As for the pause, you win, and game over parts I've used panels to create each one and gave them simple choices for the player with basics. By using buttons, making buttons out of text along with making the events match to the desired action. As for keybind changes and other options that is also a work in progress as well along with making the player stay in bounds of the screen.

Level 1



Falling Nuts & Fruit (Life Lost)



Game Over 



I going to continue on the areas that need work like  the rest of the levels, mechanics, and the overall things to make things complete.  To make things as polished as possible and neat. But hear is some of the code that I used, it's through the many tutorials I've obtained from YouTube. Thank you for reading this and  enjoy the game when it's ready.


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

public class PlayerController : MonoBehaviour
{
    CharacterController characterController;

    public float speed = 7f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;

    private Vector3 moveDirection = Vector3.zero;

    public Text collectText;
    public Text winText;
    public Text gameoverText;
    private int count;
    // Start is called before the first frame update
    void Start()
    {
        characterController = GetComponent<CharacterController>();
        count = 0;
        SetCollectText(); 
        
        
    }
    // Update is called once per frame
    void Update()
    {
        if (characterController.isGrounded)
        {
            moveDirection = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, 0.0f);
            moveDirection *= speed;

            if (Input.GetButtonDown("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }

        }
        moveDirection.y -= gravity * Time.deltaTime;

        characterController.Move(moveDirection * Time.deltaTime);
    }

   void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.CompareTag("Nut"))
        other.gameObject.SetActive(false);
        count = count + 1;
        SetCollectText();
    }

    void SetCollectText()
    {
        collectText.text = "Collect: " + count.ToString();
        if(count >= 2)
        {
            count = 0;
        }

    }

}

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

public class MainMenu : MonoBehaviour
{
  public void Single()
    {
        SceneManager.LoadScene(0);
    }

   public void Multi()
    {
        SceneManager.LoadScene(0);
    }

    public void Credits()
    {
        SceneManager.LoadScene(4);
    }

}

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

public class Spawner : MonoBehaviour
{
    public GameObject NutPrefab;
    
    public float secondsBetweenSpawns = 1;
    float nextSpawnTime;
    public float spawnAngleMax;
    public Vector2 spawnSizeMinMax;

    Vector2 screenHalfSizeWorldUnits;
    // Start is called before the first frame update
    void Start()
    {
        screenHalfSizeWorldUnits = new Vector2(Camera.main.aspect * Camera.main.orthographicSize, Camera.main.orthographicSize);
    }

    // Update is called once per frame
    void Update()
    {
        if (Time.time > nextSpawnTime)
        {
            nextSpawnTime = Time.time + secondsBetweenSpawns;
            float spawnAngle = Random.Range(-spawnAngleMax, spawnAngleMax);
            float spawnSize = Random.Range(spawnSizeMinMax.x, spawnSizeMinMax.y);
            Vector2 spawnPosition = new Vector2(Random.Range(-screenHalfSizeWorldUnits.x, screenHalfSizeWorldUnits.x), screenHalfSizeWorldUnits.y + spawnSize/2);
            Instantiate(NutPrefab, spawnPosition, Quaternion.Euler(Vector3.forward * spawnAngle));
        }
    }
}

Get My Nuts(WIP)

Leave a comment

Log in with itch.io to leave a comment.