Welcome, Guest! Login | Register

HUD Sprites [Print this Article]
Posted by: thenerd
Date posted: May 20 2003
User Rating: 5 out of 5.0
Number of views: 8206
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)
 CODE  

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:

 CODE  

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:
 CODE  

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!

Rate This Article
This article is currently rated: 5 out of 5.0 (1 Votes)

You have to register to rate this article.
User Comments Showing comments 1-5

Posted By: XENO on Aug 26 2003 at 00:40:44
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!!!)

Posted By: omega on Sep 18 2003 at 18:14:13
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!

Posted By: thenerd on Sep 28 2003 at 16:38:01
I started working on a GUI some time ago. But for some reason i never finished it.

Posted By: shadow_riku69 on Jul 20 2004 at 06:57:54
I'm new to this, but i probably could make a decent program for the hud.

Posted By: omega on Sep 17 2004 at 14:04:27
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.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
knock knock
General | News
By: MIFUNE | Dec 31 2017
 
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (4 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!