![]() |
![]() |
||||||
Chapter 2: GRAPHICS General: DiNGS uses 3 screen pages. Let’s take a look at these: 1. Primary Surface 2. Back Buffer 3. Offscreen Surface When SHOWSCREEN is
called, back buffer and primary surface swap. The now unuseable back buffer will be replaced (cleaned) with the offscreen surface which is black when no bitmap is loaded. A game mostly is structured like this: // My game SPRITES:
If you know about computers you might know the truth. The PC doesn’t have real sprites. The good news: DiNGS pretends to have sprites. With all comfort. Next, what is a sprite? No, not a refreshing drink. Sprites are smal graphics
that can perform effects that would otherwise have to be programmed with hard work. Attention: All graphic files loaded are in the Windows-Bitmap format, uncompressed. You cannot load 256-color graphics. You have to reload and save them as 24Bit color images. Your first sprite: //////////////// // load SPRITE from file “Bubble.bmp” and assign it to ID 0 // show SPRITE with ID 0 at position x=300, y=150 As you can see with 3 commands you made a visible result. The code bejond this is several pages long. And this is your advantage to all the other coders of languages like C++, ASM or
Pascal... BMPLOAD "back.bmp"; to the beggining of the program. The command SPRITE need 4 parameters. The frist is the ID of the sprite to be shown. 2 and 3 are the screen position of th sprite to be shown. The last
value is an alpha value in %. Right. DiNGS supports alpha blending. Never heared? No problem. AlphaBlending is, when 2 images (namly the background and the sprite) are melted together. DiNGS knows 2 possibilities for doing this.
1. ADDITIVE ALPHABLENDING a value from 1(%) and 100(%) mixes the 2 colour values of each pixel
by adding the red, green and blue values and watch it not to be more than 255(FF). Sounds complicated, but all work is done by DiNGS. A value more than +1 is for effects like fire, explosions and glass screens. 2. INTERPOLATED ALPHABLENDING a value from -1(%) to -100(%) melts the 2 objects by adding both values and
divide them by 2. You can use this for shaddows and other nice effects. Try it. A tip: take some time and test some geomertic shapes of different colors on a coloured background with both alpha modes. Even black and white
background can get a great look with coloured sprites. SPRITE SPECIAL FUNCTION
Zooming a sprite to any size can be done with: size% is a value that specifies the scaling of the sprite. 50 is half the size. 200 double size. GRAPHIK SPECIAL FUNCTION: As a special goodie DiNGS offers you a command to fade from the current back buffer into a BMP-file. Fading to a black bitmap the screen will fade-out. BLENDSCREEN bmpdatei$; And even better: DiNGS can play videos in all known video codecs. (AVI, MP2...) Very easy with: PLAYMOVIE filename$; Only drawback: DiNGS uses an external module for video playback. You have to copy this module when redistributing your game. TEST: So. That’s enough for today. Write a program that loads 2 sprites and does the
following: Move a sprite fromleft to right, then rotate with ROTOSPRITE once, then use ROTOZOOMSPRITE to rotate the sprite onece and zoom it to screen size meanwhile. Now the program should load an image and do the same again with
alpha value of -100 for sprite 1, and 100 for sprite 2. You’ll find graphics and a smal project for this task in the projects folder.
Chapter 3: SOUND This will be a quite short chapter. You handle sounds as you do with sprites. There are 3 commands for sound playback.
You can play more sounds simultanously. The sound device will mix them on the fly.
|