Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Nói theo nghĩa gốc, Linux là nhân ( kernel ) của HĐH. Nhân là 1 phần mềm đảm trách chức vụ liên lạc giữa các chương trình ứng dụng máy tính và phần cứng. Cung cấp các chứng năng như: quản lý file, quản lý bộ nhớ ảo, các thiết bị nhập xuất nhưng ổ cứng, màn hình, bàn phím, Nhưng Nhân Linux chưa phải là 1 HĐH | MASTERING SDL 157 particle.y y particle.angle rand 360 particle.energy double rand energy 1000 1000.0 Set the particle s color. particle.r r particle.g g particle.b b Add the particle to the particle system. AddParticle particle This is directly from another code listing. It creates a 16-bit pixel. static Uint16 CreateHicolorPixel SDL_PixelFormat fmt Uint8 red Uint8 green Uint8 blue Uint16 value This series of bit shifts uses the information from the SDL_Format structure to correctly compose a 16-bit pixel value from 8-bit red green and blue data. value red fmt- Rloss fmt- Rshift green fmt- Gloss fmt- Gshift blue fmt- Bloss fmt- Bshift return value Our particle system is limited to 10 000 particles. That should be plenty since there will rarely be more than two or three explosions on the screen at once. It is an arbitrary limit I have tested this code with five times that many particles but after a point it takes a noticeable toll on the game s framerate. CreateParticleExplosion is the main interface to the particle system. This function creates the requested number of particles of a given color and maximum velocity blasting outward from a given origin. We ll create explosions by calling 158 CHAPTER 4 CreateParticleExplosion several times with different velocities and colors. This will allow us to simulate a colorful explosion with hotter particles closer to the center of the blast. Remember that we care little about proper physics it s been said that game programming is all about taking as many shortcuts as possible without cheating the player of a good experience. If an explosion looks good it is good. The other two important particle system routines are UpdateParticles and DrawParticles. The former recalculates the position and color of each particle and checks to see whether it should be removed from the system. Particles are removed when they have faded to black and are therefore invisible since the backdrop is also mostly black . The latter draws a pixel for