Skip to content

Commit e506ae6

Browse files
author
Asbjørn Thirslund
committed
Initial commit
1 parent 239d0ef commit e506ae6

32 files changed

+348
-2
lines changed

.gitignore

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# =============== #
2+
# Unity folders #
3+
# =============== #
4+
[Ll]ibrary/
5+
[Tt]emp/
6+
[Oo]bj/
7+
3rdParty/
8+
Builds/
9+
10+
# ===================================== #
11+
# Visual Studio / MonoDevelop generated #
12+
# ===================================== #
13+
ExportedObj/
14+
obj/
15+
*.svd
16+
*.userprefs
17+
*.csproj
18+
*.pidb
19+
*.suo
20+
*.sln
21+
*.user
22+
*.unityproj
23+
*.booproj
24+
25+
# ===================================== #
26+
# Unity generated #
27+
# ===================================== #
28+
*.pidb.meta
29+
sysinfo.txt
30+
31+
# ============ #
32+
# OS generated #
33+
# ============ #
34+
.DS_Store
35+
.DS_Store?
36+
._*
37+
.Spotlight-V100
38+
.Trashes
39+
ehthumbs.db
40+
Thumbs.db
Binary file not shown.

Color Switch Replica/Assets/ColorChanger.prefab.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using UnityEngine;
2+
3+
public class FollowPlayer : MonoBehaviour {
4+
5+
public Transform player;
6+
7+
void Update ()
8+
{
9+
if (player.position.y > transform.position.y)
10+
{
11+
transform.position = new Vector3(transform.position.x, player.position.y, transform.position.z);
12+
}
13+
}
14+
15+
}

Color Switch Replica/Assets/FollowPlayer.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
22.9 KB
Binary file not shown.

Color Switch Replica/Assets/Main.unity.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Color Switch Replica/Assets/Player.cs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using UnityEngine;
2+
using UnityEngine.SceneManagement;
3+
4+
public class Player : MonoBehaviour {
5+
6+
public float jumpForce = 10f;
7+
8+
public Rigidbody2D rb;
9+
public SpriteRenderer sr;
10+
11+
public string currentColor;
12+
13+
public Color colorCyan;
14+
public Color colorYellow;
15+
public Color colorMagenta;
16+
public Color colorPink;
17+
18+
void Start ()
19+
{
20+
SetRandomColor();
21+
}
22+
23+
// Update is called once per frame
24+
void Update () {
25+
if (Input.GetButtonDown("Jump") || Input.GetMouseButtonDown(0))
26+
{
27+
rb.velocity = Vector2.up * jumpForce;
28+
}
29+
}
30+
31+
void OnTriggerEnter2D (Collider2D col)
32+
{
33+
if (col.tag == "ColorChanger")
34+
{
35+
SetRandomColor();
36+
Destroy(col.gameObject);
37+
return;
38+
}
39+
40+
if (col.tag != currentColor)
41+
{
42+
Debug.Log("GAME OVER!");
43+
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
44+
}
45+
}
46+
47+
void SetRandomColor ()
48+
{
49+
int index = Random.Range(0, 4);
50+
51+
switch (index)
52+
{
53+
case 0:
54+
currentColor = "Cyan";
55+
sr.color = colorCyan;
56+
break;
57+
case 1:
58+
currentColor = "Yellow";
59+
sr.color = colorYellow;
60+
break;
61+
case 2:
62+
currentColor = "Magenta";
63+
sr.color = colorMagenta;
64+
break;
65+
case 3:
66+
currentColor = "Pink";
67+
sr.color = colorPink;
68+
break;
69+
}
70+
}
71+
}

Color Switch Replica/Assets/Player.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using UnityEngine;
2+
3+
public class Rotator : MonoBehaviour {
4+
5+
public float speed = 100f;
6+
7+
// Update is called once per frame
8+
void Update () {
9+
transform.Rotate(0f, 0f, speed * Time.deltaTime);
10+
}
11+
}

Color Switch Replica/Assets/Rotator.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
141 KB
Binary file not shown.

Color Switch Replica/Assets/Small Circle.psd.meta

+140
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
11.3 KB
Binary file not shown.

Color Switch Replica/Assets/SmallCircle.prefab.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
m_EditorVersion: 5.6.0f3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
# Color-Switch-Replica
2-
This is the source code for a Color Switch replica created during a Twitch Livestream.
1+
# Color Switch Replica
2+
This is the source code for a Color Switch replica created during a Twitch livestream.
3+
4+
Everything is made using Unity.
5+
6+
Check out my [YouTube Channel](http://youtube.com/brackeys) for more tutorials. The livestream will be uploaded there as well.
7+
8+
Everything is free to use also commercially (public domain) except for the car sprite which I found on google.

0 commit comments

Comments
 (0)