Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLime1 authored Jan 21, 2023
0 parents commit b0281e9
Show file tree
Hide file tree
Showing 19 changed files with 2,025 additions and 0 deletions.
35 changes: 35 additions & 0 deletions BirdScript.cs
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;
}
}
11 changes: 11 additions & 0 deletions BirdScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions LogicScript.cs
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);
}
}
11 changes: 11 additions & 0 deletions LogicScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b0281e9

Please sign in to comment.