I made a little game of Flying chess.

Source: Internet
Author: User

After four days (except for the normal working hours during the day), I finally made the Flying chess project with a free online video. Download the game Please click http://wjh.lkbxw.com/htm/soft/softDetail.aspx? IID = 31

The teacher spoke really well. Step by step, he followed his mind and explained the thought process. "What effect do I want and how do I do it.

However, haha, it's just "not", but it's just a little bit of shrimp? It means "but". Haha, I am too busy. I don't have time to watch all the videos. (The teacher has to take care of most of them.) Haha, so I am accelerating the playback speed. Generally, I want to speed up to 150% ~ Between 200%, sometimes skipped ...... (Time is too short, there is no way, and you have no time to read it ).

My opinion is that I followed the teacher's method to code a little bit, but instead bound my "method" (here it refers to the term "Method" in the Program), so I have read about it, write your own "methods" based on your own thinking ".

I think the most difficult and time-consuming part of my mind is to "suspend a player once", which consumes two nights, the last time I went to play at, I had to say something: a programmer must have a strong body! Because the framework and video of the game I implemented are too different and have different structures, I found the implementation method of this section by the teacher, I can't implement it in my program, so I have to renew it myself! For example, if I want to pause Player A for one time, And I modify the code repeatedly, I can even let player a throw two retries, speechless ...... Shuangliu tears! I am so angry that I have all the words! Exaggerated, and the eyes are tired ......

In fact, in order to take care of beginners, the teacher has used an easy-to-understand method to throw a and B, that is:

Do {

// Player A throws

[Code]

// Player B throws

[Code]

} While (true); is to execute the rollback process of a and B in sequence in the code, it's easy to understand, but one drawback I see is that there are a lot of [Code] blocks under the throws of Player A and player B and there are repeated code (besides the key points, after all, others only need to change the characters a and B), but it is because of the exchange of A and B, so the writing method cannot be reused (this is my personal understanding ).

I just learned about the out parameters section and thought that I could use the out parameter to pass multiple parameters to solve this problem. (The method A and B throw the limit to write one, pass A or B using the parameter passing method, and the number of outgoing POINTS OF THE out parameter is:

/// <Summary>
/// Throttling Method
/// </Summary>
/// <Param name = "p"> only values A and B can be received. </param>
/// <Param name = "dincevalue"> The out parameter transmits a value to the outside. The dincevalue must be defined first. | Number of throws thrown by the throw operator </param>
Private Static void dince (char P, out int dincevalue)
{

}

In this way, you only need to call this method to throw A or B. Saves all the code in the main function.

Of course, after using my own thinking, I will still read the video from instructor su kun again. I think this method will get twice the result with half the effort. The benefits:

1. It will not be framed by others' thoughts;

2. enhanced the level of code writing by yourself (first writing with your own thinking without looking at others );

3. After making the video on your own, watch the video again (and never miss the teacher's video !!), There will be a big framework and problems in my mind, and I can compare myself and my teacher's advantages and disadvantages a little bit, or the teacher's "method" will be better than I thought;

----------------------------

I read the code in the video again, and found that the teacher overwrote the code for throwing the dice at the end: I used the Action Method for reuse. How can I obtain the name of the other party, the teacher used a very superb method:

Some students on the site said that they should use the if statement, that is, if I am 0, then the other party is 1, else if I am 1, then the other party is 0;

The method I want is the ternary operator playerpos = (playerpos [0] = 0 )? '1': '0 ';

However, the teacher used a very clever method and used only one statement: playnumber = 1-playnumber. // If the operator is 0, the operator is 1, the operator is 1, and the operator is 0.

High, it's too high!

Program = structure + algorithm, everything is simple!

This is also one of the differences between 3 K programmers and 3 W programmers?

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.