One hour after work, each night. This is my "learning to code" diary! Launched: Tiny Calm (meditation). Now: Learning Unity game development.
Don't wanna be here? Send us removal request.
Photo
Back in the game! First step taken, now to begin the journey...
0 notes
Text
It Persists..
Got player pref persistent loading working, and now will remember last duration (difficulty) and start new session from there... will try in practice tomorrow ;) if( PlayerPrefs.GetInt("IsReturningUser") == 1) { DurationShown = PlayerPrefs.GetFloat("LastDurationShown"); if (DurationShown == 0f) { DurationShown = 1.0f; } } else { print("Welcome new user!"); PlayerPrefs.SetInt("IsReturningUser", 1); PlayerPrefs.SetFloat("LastDurationShown", 1.0f); } ps - deja vu from the Tiny Calm meditation app! Looks like all the old approaches of restoring and cloud sync may come in handy... Next up - finish rest of persistent data handling including better error handling and modularizing the code nicely... -- Backup folder: 12 - Persistent Data Start Working --
0 notes
Video
tumblr
Sound working! Much more fun now :) public AudioSource Correct; // drag audioplayer component onto variable in editor Correct.Play(); Also fixed the grammar for 1 bird vs 2 birds problem.. Tomorrow, persistent storage...
0 notes
Photo
Birds more spaced out -- TICK
Session score percent shown -- TICK
Good solid night’s progress... tomorrow’s list:
Persistent storage
Audio
Fix the bird/s remaining thingy
Let’s go...
0 notes
Video
tumblr
Alright, now we have a per session goal up and running... decided on something simple, each day you need to collect 20 birds, so it’s about short daily sessions to reinforce behavior rather than long play times and then boredom...
Tomorrow probably figure out bird placement so it’s not all scrunched up together and looks nice, plus timing of UI displays...
0 notes
Video
tumblr
Woohoo, it works!! Well the bare bones basics at least... each time you detect the brown bird correctly it gets harder (time shown and detect radius goes down) Very productive hour tonight!! Coding wise: - delay on hiding the birds (invoke function) - got world components from mouse - calculate difference and compare to detect radius to determine win/loss (excuse the ugly code...) --- using UnityEngine; using System.Collections; using UnityEngine.UI;public class Game : MonoBehaviour { public GameObject[] Decoys { get; private set; } public GameObject[] Targets { get; private set; } public Text Subtitle; public GameObject Yellow; public GameObject Brown; float DurationShown = 1.0f; float DetectRadius = 1.0f; int NumDecoys = 5; int NumTargets = 1; void Start() { for (int i = 0; i < NumDecoys; i++) { Instantiate(Yellow, new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1), Quaternion.identity); } for (int i = 0; i < NumTargets; i++) { Instantiate(Brown, new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1), Quaternion.identity); } Decoys = GameObject.FindGameObjectsWithTag("Yellow"); Targets = GameObject.FindGameObjectsWithTag("Brown"); HideAll(); Subtitle.text = "Welcome to Spark!"; } void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 p = new Vector3(); p = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane)); // print("Screen pixels: " + Camera.main.pixelWidth + ":" + Camera.main.pixelHeight); // print("Mouse position: " + Input.mousePosition); float mouseX = p.x; float mouseY = p.y; float TargetX = Targets[0].transform.position.x; float TargetY = Targets[0].transform.position.y; print("Mouse x,y = " + mouseX + ", " + mouseY); print("Target x,y = " + TargetX + ", " + TargetY); float distance = Mathf.Sqrt((mouseX - TargetX) * (mouseX - TargetX) + (mouseY - TargetY) * (mouseY - TargetY)); print("Distance between them is " + distance); if (distance < DetectRadius) { Subtitle.text ="You Win!"; DetectRadius = DetectRadius * 0.8f; DurationShown = DurationShown * 0.8f; } else { Subtitle.text = "You Lost!"; } } } public void Play() { Subtitle.text = "Spot the brown bird!"; for (int i = 0; i < NumDecoys; i++) { Decoys[i].GetComponent<Renderer>().enabled = true; Decoys[i].transform.position = new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1); } for (int i = 0; i < NumTargets; i++) { Targets[i].GetComponent<Renderer>().enabled = true; Targets[i].transform.position = new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1); } Invoke("HideAll", DurationShown); } public void HideAll() { Subtitle.text = "Tap where it is!!"; for (int i = 0; i < NumDecoys; i++) { Decoys[i].GetComponent<Renderer>().enabled = false; } for (int i = 0; i < NumTargets; i++) { Targets[i].GetComponent<Renderer>().enabled = false; } }
}
0 notes
Text
Show/hide and detect mousedown...
Getting there....
Decoys[i].GetComponent<Renderer>().enabled = false; if (Input.GetMouseButtonDown(0)) Debug.Log("Pressed left click at " + Input.mousePosition); Instantiate(Yellow, new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1), Quaternion.identity);
Next up, get basic gameplay going (mouse tap, see radius covers target or not and show result then reset) Long weekend tomorrow, nice timing!
0 notes
Text
The power to destroy...
...a prefab!!! (which made up a little for the fact I have background image that refuses to stay on the screen when I resize game view... bad background image!) Enough for tonight...

public void MoveNow() { Instantiate(Yellow, new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1), Quaternion.identity); Instantiate(Brown, new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1), Quaternion.identity); BrownBirds = GameObject.FindGameObjectsWithTag("Brown"); NumBrownBirds = BrownBirds.Length; for (int i = 0; i < NumBrownBirds; i++) { BrownBirds[i].transform.position = new Vector3(Random.Range(0.0f, 16.0f), Random.Range(0.0f, 8.0f), -1); Subtitle.text = BrownBirds[i].transform.position.ToString(); } } public void DestroyNow() { print("ran destroy"); Destroy(BrownBirds[0]); }
0 notes
Video
tumblr
Alright... got my array going and moving the birds around. Tomorrow let’s see how far we get, going to put in a fun many hours :)
0 notes
Photo

Ok, better today. Started from scratch and now can fetch an array of game objects from common prefab (brown bird)... see how much gameplay I can build over the weekend!
0 notes
Photo

Started the cleanup operation. Getting late, brain fried today #dumbmode Going to try and sleep on time and be fresh tomorrow...
0 notes
Photo

Compiler error kind of evening. Head too dumb to figure out why instantiation not working. Tomorrow will clean up the messy project and work it out...
0 notes
Text
Text Message
Button link to blink link to text update the UI...
public class TextScript : MonoBehaviour { public static Text TextLabel; void Start () { TextLabel = GetComponent<Text>(); TextLabel.text = "Speed of Processing!"; } public class Move : MonoBehaviour { public void MoveNow() { print("Ran Move()"); Load.BirdBrown.transform.position = new Vector3 (Random.Range(0.0f, 16.0f), Random.Range(0.0f, 16.0f), -1); print("position is " + Load.BirdBrown.transform.position); TextScript.TextLabel.text = Load.BirdBrown.transform.position.ToString(); } }

Next maybe...prefab multi create?
0 notes
Text
Blink Spell Activated
Got a game object to move (well teleport) randomly on button press, had to re-learn how to find game objects and set their positions...hacky stuff but at least it’s working...

//Load.cs using UnityEngine; using UnityEngine.UI; using System.Collections; public class Load : MonoBehaviour { public static GameObject BirdBrown; void Start () { BirdBrown = GameObject.Find("BirdBrown"); } void Update () { } }
//Move.cs using UnityEngine; using System.Collections; public class Move : MonoBehaviour { public void MoveNow() { print("Ran Move()"); Load.BirdBrown.transform.position = new Vector3 (Random.Range(0.0f, 16.0f), Random.Range(0.0f, 16.0f), -1); print("position is " + Load.BirdBrown.transform.position); } }
Next step... relearn how to change the text label...
0 notes
Text
Dusting off the cobwebs..
OK got the basic background graphic sized to handle from super thin Galaxy S8 down to tablet aspect ratios ... Now got to re-learn how to link up all the objects and scripts etc... Hopefully tomorrow can get a basic needed elements working (probably not gameplay) though...

0 notes
Text
Canvas confusion
Late at night, only 30 mins to spend learning and enough to realize I need a lot more time to figure out how to set my 2d canvas for this game up correctly... more tomorrow... (thanks for long holiday weekends!) *yawn*

0 notes
Text
Here we go...
And for the next trick, we’re going to try and build a Unity game with a very personal meaning...
First step, installing Unity again, setting up Android SDK, Java SDK and getting first APK made and running on device...
Lots and lots to learn, should be a fun next month or two :)
0 notes