Posted by: thenerd
Date posted: May 20 2003 User Rating: 5 out of 5.0 | Number of views: 5317 Number of comments: 5 | Description: Understanding hud.txt |
If you don't understand how hud.txt works, this article aims to guide you. It's really very easy to add new sprites to this file. Different hud items use these such as the health and armor displays. If you haven't already got a custom hud.txt, grab it from the valve/sprites folder (or inside the pak0.pak if it's not readily visible).
When you open it up, you should see the following: (assuming you haven't modified the default hud.txt file)
| | | 123 selection 320 320hud1 160 160 80 20
bucket1 320 320hud2 108 16 12 12 bucket2 320 320hud2 108 28 12 12 bucket3 320 320hud2 108 40 12 12 bucket4 320 320hud2 108 52 12 12 bucket5 320 320hud2 108 64 12 12 bucket0 320 320hud2 108 76 12 12
|
The very first line (the number '123') designates how many sprites exist inside hud.txt - this is important, the client dll needs to know how many sprites to allocate memory for. on the second line we see:
| | | selection 320 320hud1 160 160 80 20
|
- selection is the name of the sprite; which you'll use to reference inside the source code.
- 320 is the resolution the sprite is for, valid resolutions (with unmodified hud sprite code) are 320 and 640. (note: you need to define both sets so it functions properly!)
- 320hud1 is the actual sprite filename (320hud1.spr)
- 160 160 is the top left corner of the sprite. (inside the file!) you can have multiple "image" sections inside a single sprite layer (256x256 pixels max!)
- 80 20 is the actual width/height from the top left corner of the sprite (inside the file as well)
To further explain the last 4 numbers, say you have a 64x64 sprite it only has one object in it so the first two values would be 0, and the last two would be 64. Which means, start at the top left corner of the whole sprite and draw from 0 to 64 pixels horizonally, and vertically. If you had a 128x128 sheet with 4 64x64 sprites in them, you could define them as the following:
| | | sprite1 320 sheet 0 0 64 64 //start at 0,0 sprite 64 pixels wide/tall sprite2 320 sheet 64 0 64 64 //start at 64,0 sprite is 64 pixels wide/tall sprite3 320 sheet 0 64 64 64 //start at 0,64 sprite is 64 pixels wide/tall sprite4 320 sheet 64 64 64 64 //start at 64,64 sprite is 64 pixels wide/tall
|
Each object doesn't have to be multiples of 8, but the actual .spr file does.
I hope you've gained some knowledge from this article that you didn't know before!
Good luck, and happy modding! |
|
User Comments
Showing comments 1-5
|
This would be easier with a GUI, I'm tired of doing it manually (the third time... ENOUGH IS ENOUGH!!! WHERE IS MY BACKUP CD!!! AGGH!!!) |
|
|
i thought about writing a gui for it, but i didn't bother, its so easy to do by hand. the magic of copy and paste! |
|
|
I started working on a GUI some time ago. But for some reason i never finished it. |
|
|
I'm new to this, but i probably could make a decent program for the hud. |
|
on a side note, excel is perfect for editing the hud.txt files. heh just go through your hud.txt and make sure everything is tabbed, then import the data into excel using tabs as the identifiers.
then you can just save out an xls file for editing, then just save out a txt file when you wanna use it. |
|
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
3 People Online (25 guests)
|
|