Soundmap for Terrain

Back

 

2

 

This script contains only the solution for one only terrain per level!

 

What can soundmap for terrain?

With the help of "scan_texture" one gets the suitable noises below the player feets. To this this must level be built from blocks.

And at the use of terrain? Only one single textur is available here. An inquiry as in the case of blocks isn't possible. Blocks can alternatively be put under the terrain. They are textured correspondingly and then queried with "scan_texture". Or invisible blocks become builtly level into this. The player collides with a block and the sound begins to play

All this is far too complicated. The many blocks in the land increase the unclearness. At ways with looking of snake lines denies the block technique!

 

Now here the idea of a color map. This map shows the same terrain again, but simply without details. The foot noises are assigned to different colors. All functions are contained in the "colormap.wdl". Downloads the file at the end of this tutorial. The definitions contained in it of the colors and sounds refer to the example terrain. You can change and refine her.

And you can do more still with that. Defines a color as level borders and other!

 

The first picture shows the terrain textur (skin). Original size is 1400x1000 pixel. I also have the ways on this painted (only 10 pixel width).

 

 

These texture is a basic for a "colormap" (next bitmap) with the function of a "soundmap" Note to colormap size! A textur size of 1400 x1000 pixels indicates a 100 kb large file (compressed), 4MB not compressed hard disk memory but 8 MB! of working memories (RAM) at an open file. I would therefore create the colormap more smally at great terrain textur. The same size at a single terrain to 1500 x1500 pixel. Have you several large terrains in your game, then use another size relationship. Please always take integer size of relationship (to example, terrain 1000x1000 --> colormap 500x500 = 2:1)! The bigger the relationship the more inaccurate the sound assignment! Save the colormap bitmap as 24bit *.tga file. (16.7mill. colors).

Note: I have also tested 24bit .bmp und .pcx bitmaps. These became, however, on 16 bits through the A6 engine. The RGB number of colors then don't agree any more

 

 

In the upper one picture you see different colors. These are the different grounds. Defines so many colors like you needs. In this example are five sufficient. Don't mix the colors at hers transitions (antialiasing). The five colors represented here, are integrate in the "colormap.wdl". Test it with these colors. Later, you can change everything just like you would like it.

 

 

If you draw a colormap, it is important to know the color values. R = RED G = GREEN B= BLUE are the three parts of all possible colors. They start at '0' and end at '255' (256x256x256 =  16777216 colors, this therefore must having 24 bit). The underground for the mountains is Blue here (Blue, the names are free. Blue consists here R = 0 G = 0 B = 255). Memory these values for the script.

 

 

Now set the colormap bitmap into your games directory.

The next step. Include the "colormap.wdl" to the "main.wdl". Set the "colormap.wdl" before player movements!

 

 

 

Open the WED and load the "colormap.tga" (or whatever her name you given) in the terrain level. OBJEKT --> ADD SPRITE .

The colormap doesn't have to be seen. Selecting the "invisible" and "passable" flag therefore. Put this bitmap in the level someplace to. Best at the terrain below. Not cares about its orientation or scale.

 

 

 

Now assign "get_color"action to colormap. That's all for colormap in WED.

 

 

The terrain get the"terrain_colmap"action. Write the scale value of the terrain in his skill1. In skill2 get the sizes relationship of the colormap bitmap and the terrain textur (original size of terrain bitmap). Is these 1:1 therefore equally big, you can, however, must not write into skill2 a '1'. Is the colormap smaller as the terrain textur, to example 1:2, then write her '2' (1:3 then typing in '3', 1:4 then '4' typing in...).

 

 

Thats all for WED!

 

Use the colormap wdl

Here a example to defined a color in the "colormap.wdl". The color vector 'RED_cv' contain the noticed RGB value. Under this a switch variable is defined. If the RGB vector equal the actualy color of colormap, then is this RED_sound switch = 1. The first condition to play a foot sound for ways is true.

The third line is a definition of wave sound. At the end still come a variable  to save the sound handle.Thats a unique ident number.

 

 

In the function "sound_instruct" At this begins becomes one compare executed between color vectors and the actualy color by colormap. All three colors must agree. Second, the sound mustn't play. Third, the player must be moving. All conditions are ready, then play the sound.

 

 

Another functions manage the customization of the current player position on the terrain to the corresponding  position on the colormap.

IMPORTANT FOR LEVELCHANGE!!!

The pointer for the colormap bitmap named "mymap" MUST be setting on NULL at every level change! Don't do this and there is an little engine crash.

 

 

Here a short simple example for levelchange be backed like the pointer resetting to NULL (or '0').

 

 

For the end the connection of the script function with your player

This can be different at everybody. The next picture shows the end of my own "player_move" function. Here call the "sound_on_terrain" function (is in it "colormap.wdl"). This function calculates an internal player position and take it to agreement with the colormap. After this changed it to the"sound_instruct" function. This compares colors vector and colormap. Is it the same and the player moves (walk_sound_switch == 1) be play the right sound below the player feets. The sound is ended if the player stands (walk_sound_switch ==0) or the color is a other.. In my own "player_animation"function, these starts also out the player_move function, controls this a "walk_sound_switch" variable. On the end of "colormap.wdl" is a part of my animation script. It shows the connection from "walk_sound_switch" with the animation code.The *.wav examples in the script are from 3DGS template directory. These not matching to the underground. But I have no better yet.

 

 

Here the colormap.wdl

DOWNLOAD

 

 August 2004: Some people have difficulties in understanding the instructions with the sound. Others would like only the color below the feet of the player to write her own functions. Here is the pure script for that.

tercolor.wdl

DOWNLOAD

 

2