Write game in C language: try to write a Game Engine

Source: Internet
Author: User

The best way to study C language is to practice it, and the best way to practice it is to write something bigger.ProgramHere, I am talking about a lot of things that I think would be worth 10 thousand. Otherwise, you have not been addicted to it.

Driven by this goal, I spent more than a week in my spare time last week writing a game engine BWF (buffered window framework) in C language ). This engine utilizes windows-related winapi and Cairo (http://cairographics.org/documentation/) Open Source graphics library. After writing, a small tool (http://www.onlinedown.net/soft/30001.htm) calculated a bitCodeThe number of rows is more than one thousand six hundred, which is still far away from the 10 thousand rows. There are many more to be improved in the future, including the improvement of functions and performance. So don't worry.

The purpose of writing this engine was initially to practice using the C language, but then it evolved into the following:

1. In practice, use the C language to write a larger program (at least 10 thousand lines ).
2. Try to write the database and encapsulate the interface to find the feeling of being called.
3. Study how to play games and find the feeling of playing games.

In addition to the BWF engine, a demo is also written for demonstration, with 50 lines of code (which can be shorter). The running effect is as follows:

Each of the above images is actually a button that can be flipped. The buttons in the point will be flipped, and some buttons in the figure have already been flipped. The intention of writing this demo is to write a game similar to Windows mine clearance. After reading this picture, you will find that it is not far from the completion of the game.

Simply put, the demo window is created by winapi, the animation is implemented by the Windows timer, and the drawing work is handed over to the Cairo engine.

BTW: What I wrote is for reference only.

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.