-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraymonitor.cpp
91 lines (69 loc) · 2.45 KB
/
graymonitor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// graymonitor.c
#include "stdafx.h"
#include "SDLU.h"
#include "main.h"
#include "graymonitor.h"
#include "grays.h"
#include "score.h"
#include "gworld.h"
#include "graphics.h"
#include "level.h"
static SDL_Surface* smallGrayDrawSurface;
MRect grayMonitorZRect, grayMonitorRect[2];
MBoolean grayMonitorVisible[2] = {true, true};
void InitGrayMonitors( void )
{
const double windowLoc[ ] = { 0.16, 0.84 };
SDL_Rect sdlRect;
grayMonitorZRect.top = grayMonitorZRect.left = 0;
grayMonitorZRect.bottom = 32; grayMonitorZRect.right = 144;
grayMonitorRect[0] = grayMonitorRect[1] = grayMonitorZRect;
CenterRectOnScreen( &grayMonitorRect[0], windowLoc[0], 0.11 );
CenterRectOnScreen( &grayMonitorRect[1], windowLoc[1], 0.11 );
smallGrayDrawSurface = SDLU_InitSurface( SDLU_MRectToSDLRect( &grayMonitorZRect, &sdlRect ), 32 );
DrawPICTInSurface( smallGrayDrawSurface, picBoard );
}
void ShowGrayMonitor( short player )
{
SDL_Rect sourceSDLRect, destSDLRect;
short monitor;
MRect myRect = { 4, 4, kBlobVertSize+4, 4 };
MRect srcRect;
const int smallGrayList[] = { 0, kSmallGray1, kSmallGray2, kSmallGray3, kSmallGray4, kSmallGray5 };
if( !grayMonitorVisible[player] ) return;
if( control[player] != kNobodyControl )
{
SDLU_AcquireSurface( smallGrayDrawSurface );
SDLU_BlitSurface( boardSurface[player], &smallGrayDrawSurface->clip_rect,
smallGrayDrawSurface, &smallGrayDrawSurface->clip_rect );
monitor = unallocatedGrays[player];
CalcBlobRect( kSobBlob, 3, &srcRect );
while( monitor >= (6*4) )
{
myRect.right += kBlobHorizSize;
SurfaceDrawSprite( &myRect, 4, kSobBlob );
myRect.left = myRect.right;
monitor -= (6*4);
}
CalcBlobRect( kNoSuction, kGray-1, &srcRect );
while( monitor >= 6 )
{
myRect.right += kBlobHorizSize;
SurfaceDrawAlpha( &myRect, kGray, kLight, kGrayNoBlink );
myRect.left = myRect.right;
monitor -= 6;
}
if( monitor > 0 )
{
myRect.right += kBlobHorizSize;
SurfaceDrawAlpha( &myRect, kGray, kLight, smallGrayList[monitor] );
myRect.left = myRect.right;
myRect.right += kBlobHorizSize;
SurfaceDrawAlpha( &myRect, kGray, kLight, smallGrayList[monitor]+1 );
}
SDLU_ReleaseSurface( smallGrayDrawSurface );
SDLU_BlitFrontSurface( smallGrayDrawSurface,
SDLU_MRectToSDLRect( &grayMonitorZRect, &sourceSDLRect ),
SDLU_MRectToSDLRect( &grayMonitorRect[player], &destSDLRect ) );
}
}