This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b0281e9
Showing
19 changed files
with
2,025 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Numerics; | ||
using UnityEngine; | ||
using Vector2 = UnityEngine.Vector2; | ||
|
||
public class BirdScript : MonoBehaviour | ||
{ | ||
public Rigidbody2D body; | ||
public float flapStrength; | ||
public LogicScript logic; | ||
public bool birdIsAlive=true; | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>(); | ||
birdIsAlive=true; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
if (Input.GetKeyDown(KeyCode.Space)&& birdIsAlive) | ||
{ | ||
body.velocity = Vector2.up * flapStrength; | ||
} | ||
|
||
} | ||
private void OnCollisionEnter2D(Collision2D collision) | ||
{ | ||
logic.game0ver(); | ||
birdIsAlive = false; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using UnityEngine.SceneManagement; | ||
|
||
public class LogicScript : MonoBehaviour | ||
{ | ||
public int playerScore; | ||
public Text scoreText; | ||
public GameObject game0verScreen; | ||
|
||
[ContextMenu("Increase Score")] | ||
public void addScore(int scoreToAdd) | ||
{ | ||
playerScore = playerScore + scoreToAdd; | ||
scoreText.text = playerScore.ToString(); | ||
} | ||
|
||
public void RestartGame() | ||
{ | ||
SceneManager.LoadScene(SceneManager.GetActiveScene().name); | ||
} | ||
|
||
public void game0ver() | ||
{ | ||
game0verScreen.SetActive(true); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.