2-a basic game architecture (basic game architecture)

Source: Internet
Author: User
Document directory
  • Game Logic
  • Sound
  • Graphics
  • Output

The second article is too simple. I will not translate it when I get started with Android development. The third article is about the basic game architecture.

Our Android program can run. You may want to know what kind of program is a game. Let's talk about my understanding. The following table shows the architecture of a game.

Game architecture of the Android platform

In our example, the touch screen is input, but it may also be a physical keyboard, microphone, camera, accelerator, or GPS, frame display event. The event is transmitted by the view in the touch screen activity.

User input

The input in our game is a touch screen event. Our game engine monitors the ontouch event. We record coordinates for each event. If the coordinates are in the control area we set, we let the game engine send out actions. For example, if the touch is in the circle we designed to let the characters move, it also applies to weapon control, all these conversions will change the character state due to the user's gesture input.

Game Logic

The game logic is responsible for changing the character State. Each character has a State, such as our hero, bad sex, terrain, bullets, laser rays, etc. For example, we touch the upper half of the control area ,, to calculate the movement speed of a person based on the position of our mobile control.

The light green circle in represents the control area of our finger touch. The user enters the notification game engine and provides coordinates. dx and Dy represent the distance from the center of the circle, the game engine calculates the new speed and direction of the character. If dx is positive, it indicates that he will go to the right, while dy is positive, it indicates that he will move up.

Sound

This module will play the sound based on the current status, and almost all objects will play the sound in their status, because our device only has several channels, we must decide which sound to play, for example, when bad sex threatens our hero, there will be a sound. Of course, we will also save a channel for the shooting sound. In short, the sound is like this.

Graphics

This module is responsible for displaying different game states. It can be simply drawing on the canvas in the view, or saving a separate graphic buffer, and then passing it to the custom view or OpenGL view.

The rendering standard is FPS, that is, how many frames are displayed per second. If it is 30fps, 30 images are displayed per second. for mobile devices, 30 frames are enough.

Of course, the higher the FPS, the smoother the animation. Imagine a person walking, you close your eyes for a second, and your eyes will see the position after a second. This is 2 FPS. Observe them walking and keep your eyes open, you will see smooth movement, and we want to ensure the minimum is 30fps. Depending on your eyes, you may need more FPS. If you have a good receiver, this value may be 80-100

Output

The output is the display result of the sound image, or it may vibrate if we want it.

Next, we need to set our view and try to input the screen touch to make our first game loop. We will have our first game engine.

 

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.