• 游戏开发二:游戏的开发简介


    游戏的组成部分:

    1)Window management: This is responsible for creating a window and coping with
         things like closing the window or pausing/resuming the application on Android.
    2)Input: This is related to the window management module, and keeps track of user
         input (e.g., touch events, keystrokes, and accelerometer readings).
    3)File I/O: This allows us to get the bytes of our assets into our program from disk.
    4)Graphics: This is probably the most complex module besides the actual game. It is
         responsible for loading graphics and drawing them on the screen.

    图像显示原理:

    The display receives a constant stream of information from the graphics processor. It
    encodes the color of each pixel in the display’s raster as specified by the program or
    operating system in control of drawing to the screen. The display will refresh its state a
    few dozen times per second. The exact rate is called the refresh rate. It is expressed in
    Hertz. Liquid crystal displays (LCDs) usually have a refresh rate of 60 Hz per second;
    cathode ray tube (CRT) monitors and plasma monitors often have higher refresh rates.

    The graphics processor has access to a special memory area known as video memory, 

    or VRAM. Within VRAM there’s a reserved area for storing each pixel to be displayed on 

    the screen. This area is usually called the framebuffer. A complete screen image is
    therefore called a frame. For each pixel in the display’s raster grid, there’s a
    corresponding memory address in the framebuffer that holds the pixel’s color. When we
    want to change what’s displayed on the screen, we simply change the color values of
    the pixels in that memory area in VRAM.

    双缓冲机制

    为了解决屏幕刷新时部分显示前一帧部分显示后一帧

    The first part of the solution to this problem is called double-buffering. Instead of having
    a single framebuffer, the graphics processing unit (GPU) actually manages two of them,
    a front buffer and a back buffer. The front buffer is available to the display to fetch the
    pixel colors from, and the back buffer is available to draw our next frame while the
    display happily feeds off the front buffer. When we finish drawing our current frame, we
    tell the GPU to switch the two buffers with each other, which usually means just
    swapping the address of the front and the back buffer. In graphics programming
    literature and API documentation, you may find the terms page flip and buffer swap,
    which refer to this process.

    帧同步

    Double-buffering alone does not solve the problem entirely, though: the swap can still
    happen while the screen is in the middle of refreshing its content. That’s where vertical

    synchronization (also known as vsync) comes into play. When we call the buffer swap
    method, the GPU will block until the display signals that it has finished its current refresh.
    If that happens, the GPU can safely swap the buffer addresses, and all will be well.

    颜色

    Physically, color is the reaction of your retina and visual cortex to electromagnetic
    waves. Such a wave is characterized by its wavelength and its intensity. We can see
    waves with a wavelength between roughly 400 and 700 nm. That subband of the

    electromagnetic spectrum is also known as the visible light spectrum

    The RGB color model is called an additive color model, due to the fact that the final
    color is derived via mixing the additive primary colors red, green, and blue

    图片的压缩

    The two most popular formats are JPEG and PNG. JPEG is a  lossy format. This means

    that some of the original information is thrown away in the process of compression. PNG

     is a lossless format, and will reproduce an image that’s 100 percent true to the original.

    注:上诉几点游戏开发时并不需要操心,但需要了解。

     5)Audio: This module is responsible for loading and playing everything that will hit our 

        ears.

        背景音乐一定不要事先加载到内存而是用输入流,因为占内存太大,短小的实时音效可以。
    6)Game framework: This ties all the above together and provides an easy-to-use base
         to write our games.

      通用游戏框架需要实现的接口:

    1、Set up the window and UI component and hook into callbacks so we
         can receive window and input events.
    2、Start the main loop thread.
    3、Keep track of the current screen and tell it to update and present itself
         in each main loop iteration (aka frame).
    4、Transfer any window events (e.g., pause and resume events) from the
         UI thread to the main loop thread and pass them on to the current
        screen so it can change its state accordingly.
    5、Grant access to all the modules we developed earlier: Input, FileIO,
        Graphics, and Audio.

  • 相关阅读:
    随笔
    打破生活的套牢
    健忘是种美德
    【转贴】怎样冒充古典高手!
    php数组中删除元素
    JS 总结
    ubuntu apache rewrite
    JS 预览超级大图
    UBUNTU 安装SVN
    Yahoo14条前端优化规则
  • 原文地址:https://www.cnblogs.com/shangdahao/p/2237967.html
Copyright © 2020-2023  润新知