Software Engineering Second Job

Source: Internet
Author: User

This assignment is two to choose one, I have integrated their interests and circumstances, I chose to do a 3D game to complete. After consulting a lot of information, I chose Unity3d to learn, because it comes with a powerful editor, easy for us to get started, after two weeks of study, I decided to do a very fire before the Flappy Bird to practiced hand, the following is the specific completion of the situation.

Design ideas: The use of u3d physical collision engine to detect collision events, in each frame re-painting to select the bird shape of the switch, give the bird a level of speed, and then set a trigger on the scene, responsible for the continuation of the scene, so that the game can continue to carry on.

The main code is as follows:

Using unityengine;using System.collections;public class Bird:monobehaviour {public float timer=0;public int Framenumber = 10;//Frame Number one secondspublic int framecount=0;//frame counterpublic bool animation=false;//whether play the F LY animationpublic bool Canjump=false;void Start () {//this.rigidbody.velocity = new Vector3 (2,0,0);} Update is called once per framevoid update () {//hard code here for Test//vector3 vel = this.rigidbody.velocity;//this . rigidbody.velocity = new Vector3 (5,vel.y,vel.z);//Animationif (gamemanager._intance. gamestate==gamemanager.gamestate_playing) {timer+=time.deltatime;if (timer>=1.0f/framenumber) {frameCount++; Timer-=1.0f/framenumber;int FrameIndex = framecount%3;//update material ' s offset x//How to set the property of (x offset ) Maintex:main Texturethis.renderer.material.SetTextureOffset ("_maintex", New Vector2 (0.333333f*frameindex,0));// This.renderer.material.SetTextureScale ("_maintext", New Vector2);}} if (gamemanager._intance. gamestate==gamemanager.gamestate_playing) {//Control jumpif (Input.getmousebutton (0)) {//left mouse button down audio. Play (); Vector3 Vel2 = this.rigidbody.velocity;this.rigidbody.velocity = new Vector3 (VEL2.X,5,VEL2.Z);}}} public void Getlife () {rigidbody.usegravity=true;this.rigidbody.velocity = new Vector3 (2,0,0);}}

  

Using unityengine;using System.collections;public class Gamemanager:monobehaviour {//define the state of the Gamepublic static int Gamestate_menu =0;//Game menu State public static int gamestate_playing=1;//in-game state ... public static int gamestate_end=2;  Game over state public Transform firstbg;public int score = 0;public int gamestate  = gamestate_menu;public static Gamemanager _intance;private gameobject bird;void Awake () {_intance = This;bird = Gameobject.findgameobjectwithtag ("Player");} void Update () {if (Gamestate==gamemanager.gamestate_menu) {if (Input.getmousebuttondown (0)) {//Transform Stategamestate = gamestate_playing;//Set Bird is PLAYING//1.set gravity 2.add velocity of xbird. SendMessage ("Getlife");}}        if (gamestate = = gamemanager.gamestate_end) {            gamemenu._instance.gameobject.setactive (true);            Gamemenu._instance. Updatescore (score);}}}        

  

Using unityengine;using System.collections;public class Movetrigger:monobehaviour {public Transform currentbg;public Pipe Pipe1;public pipe pipe2;public void Ontriggerenter (Collider other) {print ("Ontriggerenter"); if (other.tag== " Player ") {//move the BG to the front of first TRANSFORM//1. Get the first transfromtransform firstbg=  gamemanager._int ance.firstbg;//2. Movecurrentbg.position = new Vector3 (FIRSTBG.POSITION.X+10,CURRENTBG.POSITION.Y,CURRENTBG.POSITION.Z); GAMEMANAGER._INTANCE.FIRSTBG = currentbg;//new position for Pipepipe1. Randomgenerateposition ();p ipe2. Randomgenerateposition ();}}}

  

Experience:

Through this u3d study, I have the opportunity to understand the basic concept of 3d program and development process, in the course of learning, I encountered a lot of problems, through the access to information and consulting others to solve all these problems. Since then, I feel that I have a greater enthusiasm for programming, and benefited greatly.

  

Software Engineering Second Job

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.