Speedometer

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
Hypersonic
Posts: 134
Joined: Mon Aug 14, 2017 3:04 pm

Speedometer

Post by Hypersonic »

Does one come with the engine, or is there a mod? It would be nice to verify being in run mode (not walk), and to see the speed difference with dual chording.
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Speedometer

Post by ramon.dexter »

What?
Hypersonic
Posts: 134
Joined: Mon Aug 14, 2017 3:04 pm

Re: Speedometer

Post by Hypersonic »

User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Speedometer

Post by Gutawer »

Quickly cooked something up - https://www.dropbox.com/s/2okixyv2du8wp ... r.pk3?dl=0. Doesn't have all those crazy bars that the first video has, because I have no idea what those mean :P. Also includes some information about angle, pitch, yaw, and position, feel free to take those out of the code if you just want speed.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Speedometer

Post by gwHero »

Great example for learning the possibilities of ZScript :thumb: (wiki worthy)
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Speedometer

Post by Gutawer »

I'm not sure about that, the code was thrown together really quickly, and there's probably a bunch of ways it could be improved (I don't really like having to use DTA_HUDRules, but AFAIK it's the only way to get stuff to scale to the HUD size - my problem is that it draws from the top middle rather than the top right) :P.
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: Speedometer

Post by Xaser »

I just want to point out how great it is that a user named Hypersonic has requested a Speedometer. ;)
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Speedometer

Post by gwHero »

Gutawer wrote:I'm not sure about that, the code was thrown together really quickly, and there's probably a bunch of ways it could be improved (I don't really like having to use DTA_HUDRules, but AFAIK it's the only way to get stuff to scale to the HUD size - my problem is that it draws from the top middle rather than the top right) :P.
Improvement on details is always possible, but since ZScript code examples are yet difficult to find, this is surely an example that can give people a start!
Hypersonic
Posts: 134
Joined: Mon Aug 14, 2017 3:04 pm

Re: Speedometer

Post by Hypersonic »

Thanks for putting it together Gutawer! The extra info could come in handy as well (though idmypos 1 already displays position.) I haven't tried it just yet, but I'm curious about how ZScript works. Is it compiled at run time like Javascript, or pre-compiled such as Quake 1 (.qc files compiles to a progs.dat file.)

In the pk3 (zip) file I see 2 files

.lmp (adds event handler)
.zsc (defines an event handler)

(Ya I'm not sure what the bars in the first video are either, presumably something to assist one learning to strafe jump in Quake 3.)

EDIT: didn't know .lmp was a text file, thought it was binary. So there is no pre-compiled code.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Speedometer

Post by Gutawer »

Yeah, .lmp is just the extension I use for lumps that aren't quite code, but aren't plain English text files either.
Hypersonic
Posts: 134
Joined: Mon Aug 14, 2017 3:04 pm

Re: Speedometer

Post by Hypersonic »

Tried to run it, but nothing seems to happen, even when not using advanced hub. Using GZDoom 3.1.0.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Speedometer

Post by gwHero »

Gutawer wrote:I'm not sure about that, the code was thrown together really quickly, and there's probably a bunch of ways it could be improved (I don't really like having to use DTA_HUDRules, but AFAIK it's the only way to get stuff to scale to the HUD size - my problem is that it draws from the top middle rather than the top right) :P.
About HUD scaling: since I took your Speedometer as one of the examples to learn more about ZScript, I found out that the Screen.DrawText you use has a lot of flags.
DTA_KeepRatio & DTA_VirtualWidth / Height are quite powerful concerning scaling:

Code: Select all

// title top middle of the screen
string sTitle = "=title=";  
Font fnt = bigfont;
Screen.drawText(fnt, Font.CR_OLIVE, 320 - (fnt.StringWidth(sTitle) / 2), 1, sTitle,
	DTA_KeepRatio, true, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400);

// stuff top right corner of the screen
string stuff = "=stuff=";
Screen.drawText(fnt, Font.CR_DARKBROWN, 640 - (fnt.StringWidth(stuff) +1), 1, stuff,
	DTA_KeepRatio, true, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400);
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Speedometer

Post by Gutawer »

I'm aware of those, but I wanted to keep the text scaled to the user's HUD scale preferences.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Speedometer

Post by gwHero »

I see what you mean, the font is scaled automatically.

Btw, since I have recently read this discussion viewtopic.php?f=3&t=55278 from a while ago, I am now fully aware of the efforts the developers have made to make this all possible. Even more, apparently Graf was very reluctant in the beginning to give renderoverlay to the modders since it could quite mess with the playsim.

But I guess we can freely use it now to display messages and simple stuff on the screen? Or is using the statusbar classes a more preferred way to show things on the screen?

EDIT: About using it safely is answered here I guess https://zdoom.org/Changelog/1dcc017da/files
Post Reply

Return to “General”