0% found this document useful (0 votes)
76 views6 pages

GP Notes

Game programing assignment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
76 views6 pages

GP Notes

Game programing assignment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Stopwatch: a= Page no 1 Image of output 3 buttons for play pause and restart public class Timer : NonoBehaviour public Text text; float theTime; public float speed = se; bool play; // Start is called before the first frame update void Start() { theTime = 0; text = GetComponentcText>(); } // Update is called once per frame void Update() { if (play == true) { theTime += Time.deltaTime * speed; string seconds = (theTime % 60).Tostring("2e")s aes string minutes = Mathf.Floor((theTime % 368¢) / 60).Tostring("@0");, string hours = Mathf.Floor((theTime % 216000) / 3600) .ToString("20"); text text = hours + ":" + minutes + ":" + seconds; } t public void ClickPlay() play = true; } public void ClickStop() { play = false; public void clickReset() therine = 0 play = falses ong opt 4 tet + 7005 cence: = Ta0reg Mh RPS + ¥ Maze Game: Main Camera pigld body and Movement Script Directional Light 4Plane for 4 walls Mesh Render Mesh Collider Box Collider Ball Sphere Collider Rigid body Script Hurdle Box Collider Coin Capsule Collider public Rigidbody ball; public float force = 50f; 4/ Start is called before the first frame update void Start() ball = GetComponent(); } // Update is called once per frame void Update() iq Page no 2 @) novenent ()5 ? 2 plc void moverent() { float novex = Input .GetAxisRaw("Horizontal"); Pp Float moveZ = Tepe eetaaisnan(rvertica\"); age no 3 Vectors nove = new Vector3(movex, OF, moveZ)s pall.velocity = force * move * Time.deltatime; ) y Animations: Main Camera Player Sprite Render Animator Rigid Body 2D Box Collider 2D Walking Script Cloud Polygon Collider public Rigidbody20 players public Animator anim; Oy start is called before the first frame update void Start() { } 11 update is called once per frame void Update() mov()5 public void mov() € float force = 10f3 Float dir = Input.GetAxisRaw("Hordzontal”); if(dir > @) ai 11 mov right player.AddForce(new Vector2(force,0f)); Vector3 temp = transform. localScale; temp.x = 23 transform.localscale = temp; anim.SetBool("chk™, true); Page no 4 Yecairee) 4 11 mov left player-AddForce(new Vector2(-force, Of); Vector3 temp = transform. localsca: temp.x = -25 transform.localscale = temp; anim.SetBool("chk", true); Xecaires0) {1 stop anim.SetBool("chk", false); ; a Airport Game Characters Envoirnment Mesh Collider Runway Buildings Grass Vehicles Ground Wolf Animator Rigid body Mov Script Cutscene ‘Script public Rigidbody player; public float force = 10F; Start is called P g 5 us ae before the first frame update a e no { ) player = GetComponent(); // Update is called once per fi void Update() aia { movement() 5 public void movenent() float movex = Input .GetaxisRaw("Horizontal" ); Float moveZ = Input .Getaxiskaw(“Vertical”); Vector3 move = new Vector3(movex, OF, moveZ); player.velocity = force * move; Guess the Number Canvas Harder Text User Number Input Field Guess Button Script Restart Button Script public int Randontunber, tr = 55 public InputField UserNumber public Text Result, Tries; public Button Guess, Restart; J] Start 4s called before the first frane update void Start() / RandomNumber = Random.Range(1, 5@); ‘ Page no 6 1] Update is called once per frane void Update() { } public void GBtnClick() int UN = int.Parse(UserNumber.text); if (UN == RandonNunber) { Result.text = "You Won"; Guess .ganeObject .SetActive( false); Restart. gameObject .Setactive(true); Tries. gameObject.Setactive(false); Me else { tre-5 if (tr > @) { Tries.text = "Tries Remaining: " + tr; | if (UN > RandomNunber) Result.text = "You Number is Greater than Generated Number”; }. else Result.text = "You Number is Smaller than Generated Number”; 3 } else { Result.text = "You Lose"; Tries.text = "Tries Remaining: " + tr3 Guess .gameObject.SetActive(false); Restart .gameObject.SetActive(true) 5 Tries .gameObject.Setactive(false) } t } public void rest() { Guess. gameObject .Setactive(true) ; Tries. gamedbject .SetActive(true); Restart, gamedbject .Setactive( false); tr = 5; Tries.text = “Tries Remaining: * + tr; Usernumber.text = "";

You might also like