Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

#include "wi_stuff.h"

//

//Data needed to add patches to full screen intermission pics.

//Patches are statistics messages, and animations.

//Loads of by-pixel layout and placement, offsets etc.

//

//

//Different vetween registered DOOM (1994) and

//Ultimate DOOM - Final edition (retail, 1995?).

//This is supposedly ignored for commercial

//release (aka DOOM II), which had 34 maps

//in one episode. So there.

#define NUMEPISODES

4

#define NUMMAPS

9

// in tics

 

//U #define PAUSELEN

(TICRATE*2)

//U #define SCORESTEP

100

//U #define ANIMPERIOD

32

// pixel distance from "(YOU)" to "PLAYER N"

//U #define STARDIST

10

//U #define WK 1

 

// GLOBAL LOCATIONS

 

#define WI_TITLEY

2

#define WI_SPACINGY

33

// SINGPLE-PLAYER STUFF

 

#define SP_STATSX

50

#define SP_STATSY

50

#define SP_TIMEX

16

#define SP_TIMEY

(SCREENHEIGHT-32)

// NET GAME STUFF

 

#define NG_STATSY

50

#define NG_STATSX

(32 + SHORT(star->width)/2 + 32*!dofrags)

#define NG_SPACINGX

64

// DEATHMATCH STUFF

 

#define DM_MATRIXX

42

#define DM_MATRIXY

68

#define DM_SPACINGX

40

#define DM_TOTALSX

269

#define DM_KILLERSX

10

#define DM_KILLERSY

100

#define DM_VICTIMSX

5

#define DM_VICTIMSY

50

typedef enum

{

781

ANIM_ALWAYS,

ANIM_RANDOM,

ANIM_LEVEL

} animenum_t;

 

typedef struct

 

{

 

int

x;

int

y;

} point_t;

 

//

//Animation.

//There is another anim_t used in p_spec.

typedef struct

{

animenum_t type;

// period in tics between animations

int

period;

//

number of animation frames

int

nanims;

//

location of animation

point_t

loc;

//ALWAYS: n/a,

//RANDOM: period deviation (<256),

//LEVEL: level

int

data1;

//ALWAYS: n/a,

//RANDOM: random base period,

//LEVEL: n/a

int data2;

// actual graphics for frames of animations patch_t* p[3];

//following must be initialized to zero before use!

//next value of bcnt (used in conjunction with period)

int

nexttic;

// last drawn animation

frame

int

lastdrawn;

// next frame number to

animate

int

ctr;

 

// used by RANDOM and LEVEL when animating

int

state;

} anim_t;

static point_t lnodes[NUMEPISODES][NUMMAPS] =

{

// Episode 0 World Map

{

782

{ 185, 164

},

// location

of level

0

(CJ)

{ 148, 143

},

// location

of level

1

(CJ)

{ 69, 122

},

// location of level

2

 

(CJ)

{ 209, 102

 

},

// location

of level

3

(CJ)

{ 116, 89

},

// location of level

4

 

(CJ)

{ 166, 55

 

},

// location of level

5

 

(CJ)

{ 71, 56

},

 

// location of level 6

(CJ)

{ 135, 29

 

},

// location of level

7

 

(CJ)

{ 71, 24

}

 

 

// location of

level 8

(CJ)

},

// Episode 1 World Map should go here

{

{ 254, 25 },

// location of

level 0 (CJ)

{ 97, 50 },

// location of level 1 (CJ)

{ 188, 64

},

// location of

level 2

(CJ)

{ 128,

78

},

//

location of

level

3

(CJ)

{ 214,

92

},

//

location of

level

4

(CJ)

{ 133, 130

},

// location of level 5

(CJ)

{ 208, 136

},

// location of level 6

(CJ)

{ 148,

140

},

// location of level 7

(CJ)

{ 235,

158

}

// location of level 8 (CJ)

},

// Episode 2 World Map should go here

{

{ 156, 168 },

// location of level 0 (CJ)

{ 48, 154 },

// location of level 1 (CJ)

{ 174, 95 },

// location of level 2 (CJ)

{ 265, 75 },

// location of level 3 (CJ)

{ 130, 48

},

// location of level 4 (CJ)

{ 279, 23

},

// location of level 5

(CJ)

{ 198, 48

},

// location of level 6

(CJ)

{ 140, 25

},

// location of level 7

(CJ)

{ 281, 136 }

// location of level 8

(CJ)

}

};

//

//Animation locations for episode 0 (1).

//Using patches saves a lot of space,

//as they replace 320x200 full screen frames.

static anim_t epsd0animinfo[] =

{

{ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 184, 160 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 112, 136 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 72, 112 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 88, 96 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 64, 48 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 192, 40 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 136, 16 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 } }

};

static anim_t epsd1animinfo[] =

{

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1 },

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 2 },

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 3 },

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 4 },

783

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 5 },

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 6 },

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 7 },

{ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8 },

{ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8 }

};

static anim_t epsd2animinfo[] =

{

{ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 40, 136 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 160, 96 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 104, 80 } },

{ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 } },

{ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 } }

};

static int NUMANIMS[NUMEPISODES] =

{

sizeof(epsd0animinfo)/sizeof(anim_t), sizeof(epsd1animinfo)/sizeof(anim_t), sizeof(epsd2animinfo)/sizeof(anim_t)

};

static anim_t *anims[NUMEPISODES] =

{

epsd0animinfo,

epsd1animinfo,

epsd2animinfo

};

//

// GENERAL DATA

//

//

//Locally used stuff.

#define FB 0

//States for single-player

#define

SP_KILLS

0

#define

SP_ITEMS

2

#define

SP_SECRET

4

#define

SP_FRAGS

6

#define

SP_TIME

8

#define

SP_PAR

ST_TIME

#define

SP_PAUSE

1

// in seconds

 

#define

SHOWNEXTLOCDELAY

4

//#define SHOWLASTLOCDELAY

SHOWNEXTLOCDELAY

// used

to accelerate or skip a stage

static int

acceleratestage;

// wbs->pnum

 

static int

me;

// specifies current state

static stateenum_t

state;

784

// contains information passed into intermission

static wbstartstruct_t* wbs;

static wbplayerstruct_t* plrs; // wbs->plyr[]

//

used for general timing

 

static

int

cnt;

//

used for timing of background animation

static

int

bcnt;

// signals

to refresh everything for one

frame

static int

firstrefresh;

 

static int static int static int static int static int static int

// # of commercial levels static int

cnt_kills[MAXPLAYERS]; cnt_items[MAXPLAYERS]; cnt_secret[MAXPLAYERS]; cnt_time;

cnt_par; cnt_pause;

NUMCMAPS;

//

//GRAPHICS

//background (map of levels).

static

patch_t*

bg;

// You

Are Here graphic

 

static

patch_t*

yah[2];

// splat

 

static

patch_t*

splat;

// %, : graphics

 

static

patch_t*

percent;

static

patch_t*

colon;

// 0-9

graphic

 

static

patch_t*

num[10];

// minus sign

 

static

patch_t*

wiminus;

// "Finished!" graphics

 

static

patch_t*

finished;

// "Entering" graphic

 

static

patch_t*

entering;

// "secret"

 

static

patch_t*

sp_secret;

// "Kills", "Scrt", "Items", "Frags"

static

patch_t*

kills;

static

patch_t*

secret;

static

patch_t*

items;

static

patch_t*

frags;

// Time sucks.

785

static patch_t*

time;

static patch_t*

par;

static patch_t*

sucks;

// "killers", "victims"

 

static patch_t*

killers;

static patch_t*

victims;

// "Total", your face, your dead face

static patch_t*

total;

static patch_t*

star;

static patch_t*

bstar;

// "red P[1..MAXPLAYERS]"

static patch_t*

p[MAXPLAYERS];

// "gray P[1..MAXPLAYERS]"

static patch_t*

bp[MAXPLAYERS];

// Name graphics of each level (centered)

static patch_t**

lnames;

//

//CODE

//slam background

//UNUSED static unsigned char *background=0;

void WI_slamBackground(void)

{

memcpy(screens[0], screens[1], SCREENWIDTH * SCREENHEIGHT); V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);

}

//The ticker is used to detect keys

//because of timing issues in netgames. boolean WI_Responder(event_t* ev)

{

return false;

}

//Draws "<Levelname> Finished!"

void WI_drawLF(void)

{

int y = WI_TITLEY;

// draw <LevelName>

V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2,

y, FB, lnames[wbs->last]);

// draw "Finished!"

y += (5*SHORT(lnames[wbs->last]->height))/4;

V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2,

y, FB, finished);

}

// Draws "Entering <LevelName>" void WI_drawEL(void)

{

786

int y = WI_TITLEY;

// draw "Entering"

V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2,

y, FB, entering);

// draw level

y += (5*SHORT(lnames[wbs->next]->height))/4;

V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2,

y, FB, lnames[wbs->next]);

}

 

void

 

WI_drawOnLnode

 

( int

n,

patch_t*

c[] )

{

 

int

i;

int

left;

int

top;

int

right;

int

bottom;

boolean

fits = false;

i = 0; do

{

left = lnodes[wbs->epsd][n].x - SHORT(c[i]->leftoffset); top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset); right = left + SHORT(c[i]->width);

bottom = top + SHORT(c[i]->height);

if (left >= 0

&&right < SCREENWIDTH

&&top >= 0

&&bottom < SCREENHEIGHT)

{

fits = true;

}

else

{

i++;

}

} while (!fits && i!=2);

if (fits && i<2)

{

V_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, FB, c[i]);

}

else

{

// DEBUG

printf("Could not place patch on level %d", n+1);

}

}

void WI_initAnimatedBack(void)

{

int

i;

787

anim_t* a;

if (gamemode == commercial) return;

if (wbs->epsd > 2) return;

for (i=0;i<NUMANIMS[wbs->epsd];i++)

{

a = &anims[wbs->epsd][i];

//init variables a->ctr = -1;

//specify the next time to draw it if (a->type == ANIM_ALWAYS)

a->nexttic = bcnt + 1 + (M_Random()%a->period); else if (a->type == ANIM_RANDOM)

a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1); else if (a->type == ANIM_LEVEL)

a->nexttic = bcnt + 1;

}

}

void WI_updateAnimatedBack(void)

{

int

i;

anim_t*

a;

if (gamemode == commercial) return;

if (wbs->epsd > 2) return;

for (i=0;i<NUMANIMS[wbs->epsd];i++)

{

a = &anims[wbs->epsd][i];

if (bcnt == a->nexttic)

{

switch (a->type)

{

case ANIM_ALWAYS:

if (++a->ctr >= a->nanims) a->ctr = 0; a->nexttic = bcnt + a->period;

break;

case ANIM_RANDOM: a->ctr++;

if (a->ctr == a->nanims)

{

a->ctr = -1;

a->nexttic = bcnt+a->data2+(M_Random()%a->data1);

}

else a->nexttic = bcnt + a->period; break;

case ANIM_LEVEL:

// gawd-awful hack for level anims if (!(state == StatCount && i == 7)

&& wbs->next == a->data1)

{

788

a->ctr++;

if (a->ctr == a->nanims) a->ctr--; a->nexttic = bcnt + a->period;

}

break;

}

}

}

}

void WI_drawAnimatedBack(void)

{

int

i;

anim_t*

a;

if (commercial) return;

if (wbs->epsd > 2) return;

for (i=0 ; i<NUMANIMS[wbs->epsd] ; i++)

{

a = &anims[wbs->epsd][i];

if (a->ctr >= 0)

V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]);

}

}

//

//Draws a number.

//If digits > 0, then use that many digits minimum,

//otherwise only use as many as necessary.

//Returns new x position.

//

int

 

WI_drawNum

 

( int

x,

int

y,

int

n,

int

digits )

{

 

int

fontwidth = SHORT(num[0]->width);

int

neg;

int

temp;

if (digits < 0)

 

{

 

if (!n)

 

{

 

// make variable-length zeros 1 digit long digits = 1;

}

else

{

// figure out # of digits in # digits = 0;

temp = n;

789

x,
y, t )

while (temp)

{

temp /= 10; digits++;

}

}

}

neg = n < 0; if (neg)

n = -n;

//if non-number, do not draw it if (n == 1994)

return 0;

//draw the new number

while (digits--)

{

x -= fontwidth;

V_DrawPatch(x, y, FB, num[ n % 10 ]); n /= 10;

}

// draw a minus sign if necessary if (neg)

V_DrawPatch(x-=8, y, FB, wiminus);

return x;

 

}

 

void

 

WI_drawPercent

 

( int

x,

int

y,

int

p )

{

 

if (p < 0) return;

V_DrawPatch(x, y, FB, percent);

WI_drawNum(x, y, p, -1);

}

//

//Display level completion time and par,

//or "sucks" message if overflow.

//

void WI_drawTime ( int

int int

{

int

div;

int

n;

if (t<0) return;

if (t <= 61*59)

790

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]