HUD map

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
User avatar
TiTnAsS
Match Winner
Posts: 655
Joined: Sun Jan 23, 2005 2:44 am
Location: Reppin the Bay Area!

Post by TiTnAsS »

can hardly tell where edges are and which are real walls and which are
minimap walls
Damn, it sure has been a while!
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

TiTnAsS wrote:can hardly tell where edges are and which are real walls and which are
minimap walls
On the small map at the bottom right it's generally OK. The big map is just an example. But it is easy to add a filled background.
ˌɑrməˈɡɛˌtrɑn
User avatar
TiTnAsS
Match Winner
Posts: 655
Joined: Sun Jan 23, 2005 2:44 am
Location: Reppin the Bay Area!

Post by TiTnAsS »

ah
Damn, it sure has been a while!
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

One way to get a background:

Code: Select all

void DrawMap(bool rimWalls, bool cycleWalls, bool cycles,
             double cycleSize, double border,
             double x, double y, double w, double h,
             double rw, double rh, double ix, double iy,
             GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
...
	glMultMatrixf(m);
	if(a > 0) {
		glColor4f(r, g, b, a);
		glRectf(lx, ly, hx, hy);
	}
	if(rimWalls)
ˌɑrməˈɡɛˌtrɑn
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Only 600. :)

Edit: Currently my code:

Code: Select all

#define DONTDOIT
#include "rRender.h"
#include "rScreen.h"
#include "tConfiguration.h"
#include "eFloor.h"
#include "eTimer.h"

void DrawMap(bool rimWalls, bool cycleWalls, bool cycles,
             double cycleSize, double border,
             double x, double y, double w, double h,
             double rw, double rh, double ix, double iy,
             GLfloat r, GLfloat g, GLfloat b, GLfloat a);

static int simplemapmode = 0;
static tConfItem<int> simplemapmode_con("SIMPLE_MAP", simplemapmode);

static void drawsimplemap() {
	if(!se_mainGameTimer) return;
	// I haven't checked possible initial matrix state, so init to identity and modelview
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	if(simplemapmode & 1)
		DrawMap(true, true, true,
		        5.5, 10,
		        .5, -1, .5, .5 * sr_screenWidth / sr_screenHeight,
		        .25 * sr_screenWidth, .25 * sr_screenWidth, 1, 0,
		        0, 0, 0, 0);
	if(simplemapmode & 2) {
		REAL r, g, b;
		se_FloorColor(r, g, b);
		DrawMap(true, true, true,
		        5.5, 10,
		        -1, -1, 2, 2,
		        sr_screenWidth, sr_screenHeight, .5, .5,
		        r, g, b, .5);
	}
	if(simplemapmode & 4) {
		REAL r, g, b;
		se_FloorColor(r, g, b);
		unsigned xcount=30;
		unsigned ycount=20;
		unsigned x, y;
		for(y=0; y<ycount; y++) {
			for(x=0; x<xcount; x++) {
				DrawMap(true, true, true,
				        5.5, 10,
				        2.0 / xcount * x - 1, 2.0 / ycount * y - 1, 2.0 / xcount, 2.0 / ycount,
				        2.0 / xcount * sr_screenWidth, 2.0 / ycount * sr_screenHeight, x / (xcount - 1.0), y / (ycount - 1.0),
				        r, g, b, .5);
			}
		}
	}
}

static rPerFrameTask simplemaptask(&drawsimplemap);
Attachments
600maps.png
ˌɑrməˈɡɛˌtrɑn
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

It's posted now for a few days. Got it working?
ˌɑrməˈɡɛˌtrɑn
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

I think I found some problems. Expect an updated version.
ˌɑrməˈɡɛˌtrɑn
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Don't laugh if you spot the errors.

Code: Select all

static void DrawWalls(tList<gNetPlayerWall> &list) {
	unsigned i, len=list.Len();
	double currentTime = se_GameTime();
	double wallsLength = gCycle::WallsLength();
	double wallsStayUpDelay = gCycle::WallsStayUpDelay();
	bool limitedLength = wallsLength > 0;
	glBegin(GL_LINES);
	for(i=0; i<len; i++) {
		gNetPlayerWall *wall = list[i];
		gCycle *cycle = wall->Cycle();
		if(!cycle) continue;
		double alpha = 1;
		if(!cycle->Alive() && wallsStayUpDelay >= 0) {
			alpha -= 2 * (currentTime - cycle->DeathTime() - wallsStayUpDelay);
			if(!(alpha > 0)) continue;
		}
		glColor4f(cycle->color_.r, cycle->color_.g, cycle->color_.b, alpha);
		double cycleDist = cycle->GetDistance();
		double minDist = limitedLength && cycleDist > wallsLength ? cycleDist - wallsLength : 0;
		const eCoord &begPos = wall->EndPoint(0), &endPos = wall->EndPoint(1);
		tArray<gPlayerWallCoord> &coords = wall->Coords();
		double begDist = wall->BegPos();
		double lenDist = wall->EndPos() - begDist;
		unsigned j, numcoords = coords.Len();
		if(numcoords < 2) continue;
		bool prevDangerous = coords[0].IsDangerous;
		double prevDist = coords[0].Pos;
		if(prevDist < minDist) prevDist = minDist;
		prevDist = (prevDist - begDist) / lenDist;
		for(j=1; j<numcoords; j++) {
			bool curDangerous = coords[j].IsDangerous;
			double curDist = coords[j].Pos;
			if(curDist < minDist) curDist = minDist;
			curDist = (curDist - begDist) / lenDist;
			if(prevDangerous) {
				glVertex2f(begPos.x + prevDist * (endPos.x - begPos.x), begPos.y + prevDist * (endPos.y - begPos.y));
				glVertex2f(begPos.x +  curDist * (endPos.x - begPos.x), begPos.y +  curDist * (endPos.y - begPos.y));
			}
			prevDangerous = curDangerous;
			prevDist = curDist;
		}
	}
	glEnd();
}
Edit: tweaked the code in glVertex2f a bit. Only six fp instructions if you have multiply-adds and a smart compiler. :)
ˌɑrməˈɡɛˌtrɑn
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Ummmmm, I remember reading somewhere that this was put in cvs. How do I enable it? Is it in the 0.2.8 branch, or head?
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Don't know where in CVS, but grep for HUD_MAP switches.
ˌɑrməˈɡɛˌtrɑn
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Not in the branch, apparently. Anybody happen to know why? I thought we were going to go ahead and include it in 0.2.8....
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Z-Man
God & Project Admin
Posts: 11710
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Don't look at me, it wasn't me who put it in CVS. The code came in pretty late, so I guess it would have been something with the feature freeze.
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

So, I put #define HUD_MAP in gWall.h, but no hud map. ?
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Are you sure gWall.h is included before any related #ifs? (obvious, but nemo fell in the same trap)
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Aha. :) There's an #ifdef HUD_MAP before the gWall.h include. Got it, thanks!
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
Post Reply