Beginner's corner |
Top Previous Next |
Mouse coordinates
Sometimes, especially when you are designing some panels or doing some beta testing, you will want to see the exact mouse coordinates on the screen, and that's exactly what the code below does.
string temporary_str;
text mcoordinates_txt // using the default font here
starter display_coords()
I have used a simple text definition because the coordinates are displayed by coordinates_str. The starter function converts mouse_pos.x (which is a number) to a string, adds the first parenthesis ( then adds mouse_pos.x to the string, adds a comma, converts mouse_pos.y to a string and adds it to coordinates_str as well. We add the second parenthesis ) and then we make sure that the text is kept 15 pixels to the right and 15 pixels below the pointer. That's it!
Get the vertex and pixel shader versions
I have to admit that I don't feel too comfortable with all these different video cards that are available nowadays. If you want to create a great looking game you will need to make sure that all your customers have video cards with (let's say) VS = 2.0 and PS = 2.0. But will all of them have those modern cards? Hold on, I have just noticed that a card with VS = 2.0 and PS = 2.0 has become an obsolete video card already! ;) The code from this article will display your video card's capabilities so be prepared to be thrilled or extremely disappointed.
string tmp_shader = " ";
text shader_txt
The precious VS and PS values are given by d3d_shaderversion, which is returned by A6.31 or a newer version of it. I have defined a few strings and a text that will display the VS and PS values.
function display_shader_versions()
on_s = display_shader_versions;
The function above displays VS and PS for 5 seconds when the player presses the "S" key. The first line of code converts d3d_shaderversion, which is a number (1234 would mean VS = 1.2 and PS = 3.4) to a string. The following lines of code copy tmp_shader to temp_str, get the first digit for VS, copy the "Vertex shader version: " text to the string, add the first VS digit, and then a dot, the get the second VS digit and copy it to the same string. The things repeat for PS. These are the stages that show how the displayed_str string looks like while it is being built:
Vertex shader version:
Vertex shader version: 2
Vertex shader version: 2.
Vertex shader version: 2.0
Vertex shader version: 2.0
Vertex shader version: 2.0
Vertex shader version: 2.0
Vertex shader version: 2.0 |