10-day android game development (1)-game programming Basics

Source: Internet
Author: User

Preface

A long time ago, I had the idea of playing games. It was really cool to play games! However, due to time and technical restrictions, it was not implemented. Recently, I finally decided to learn this knowledge.

From today on, we will start our android game journey.

The first article does not involve technical details of the game, so it is a common sense of the game.

Start with a story
The story outlines the action, purpose, and process of the game. The more detailed the story is, the easier it is to write the encoding during game development.

Why is the story important?
Because the story is the foundation of the entire game implementation, from the beginning to the end.
It must be realized that an idea must be complete, and every aspect of it must be carefully considered.
Ideally, your code should be sufficiently scalable, so that you can effectively manipulate it-especially when you want to increase the level or boss to the game in the future.
When coding, if you have a complete game story, it can be matched in real time.

If you have a story about the game in your head, write a draft now. When you finish the game, you can compare it with the game.

OpenGL and 2D
OpenGL and 3D involve a lot of things, but it is also very good at rendering 2D images. In fact, OpenGL rendering and manipulating 2D images are more effective than Android's built-in methods. Android's built-in API is good enough for most applications, but it is more efficient for games. OpenGL is the best method.

A typical game running mode
Draw background;
Move the background if necessary;
Draw text;
Draw weapons, bullets, etc;
Move each role;
Play background music and sound effects;
Accept input from the input device;
Track the movements of roles and backgrounds and make sure they do not go anywhere.
Draw an animation;
Ensure that the motion track of the object conforms to expectations;
Record players' scores;
Manage networks;
Create a menu.

 Game Engine
The gaming engine is universally applicable and must be used in a variety of situations. If possible, it should be applicable to different games, which is just the opposite of the game code. For game code, just like his name, it only targets a specific game.
What the game engine needs to do:
Graphic rendering;
Animation;
Sound;
Collision detection;
Artificial Intelligence;
Physical;
Thread and memory management;
Network;
Command Translation.

The game engine is usually written in low-level languages. Low-level languages provide a more direct connection to hardware. A game engine needs to pass the game code to hardware. In this way, the game can run faster and enjoy a better operation experience.
A game engine does not work for a game. For example, it does not draw a kitten on the screen because it controls Image Rendering, but it allows you to draw anything. Drawing a kitten is done by game code. It just needs to pass what it wants to the engine.
Therefore, you will see the following method in the game engine:
Drawfunykitten ();
At the same time, you will also see statements similar to drawcharacter (funykitten); In the game code.

About game code
A game runs the game code. Unlike a game engine, a game can be used for multiple games. It is usually unique.
When you develop a game, the game engine code and the game code may work closely together and it is difficult to separate them. However, understanding the relationship between the two is still very important.
We strongly recommend that you clearly separate the two, which enhances the reusability of your code and improves your development skills. In addition, you must avoid lazy code and lazy coding practices. For example, the Code does not write comments or indentation.

 

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.