-
Notifications
You must be signed in to change notification settings - Fork 4
/
ticker_message.cpp
30 lines (25 loc) · 1.07 KB
/
ticker_message.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
#include "stdafx.h"
#include "typeset.h"
#include "ticker_message.h"
void TickerMessage::setDots(int dots[][256]){
int x_min = 0;
for( int i = 0; i < message.length(); i++)
x_min += typeSetMapping(fontName.c_str(), message[i], yAreaSize, dots, x_min);
xLeastAreaSize = x_min;
/* checking space between the last letter and the first */
if( letterSpaceCheck( dots, 0, xLeastAreaSize -1, yAreaSize) > 0) xLeastAreaSize++;
xAreaSize = 5; // because the minimun gun has 5 positions to have a glider
/* set xAreaSize to proper value */
while( xAreaSize < xLeastAreaSize) xAreaSize += 4;
/* set dots in blank space to zero */
for(int y = 0; y < yAreaSize; y++)
for(int x = 0; x < xAreaSize - xLeastAreaSize; x++)
dots[xLeastAreaSize +x][y] = 0;
}
int TickerMessage::calculateDistance(double bannerSize, int dotShift, int period){
int distance = 4;// distance between eaters and guns
while( distance < xAreaSize *period *bannerSize) distance += 4;
distance += dotShift *period * ((yAreaSize -1) /2);
distance -= ((yAreaSize -1) /2) % 2; /* adjusting parity */
return distance;
}