📄 squirmcellproperties.cpp
字号:
// SquirmCellProperties.cpp
#include "stdafx.h"
#include "SquirmCellProperties.h"
#include "SquirmError.h"
SquirmCellProperties::SquirmCellProperties(char t,int s)
{
this->type = t;
this->state = s;
RecomputeStyle();
}
void SquirmCellProperties::RecomputeStyle()
{
if(type=='c' && state==0) // water
style = WATER;
else if(type=='b' && state==1) // tail
style = HYDROPHOBIC;
else if(type=='a' && state==1) // head
style = HYDROPHILIC;
else
style = NEUTRAL;
}
COLORREF SquirmCellProperties::GetColour()
{
switch(this->type)
{
case 'e': return state!=0?RGB(255,0,0):RGB(255,128,128);
case 'f': return state!=0?RGB(0,255,0):RGB(128,255,128);
case 'a': return state!=0?RGB(220,220,0):RGB(237,237,128);
case 'b': return state!=0?RGB(128,128,128):RGB(192,192,192); // b=grey
case 'c': return state!=0?RGB(0,255,255):RGB(128,255,255); // c=cyan
case 'd': return state!=0?RGB(0,0,255):RGB(128,128,255); // d=blue
default: return RGB(0,0,0); // black=error!
}
// was Color.red.brighter(),Color.green,Color.orange,
// Color.gray,Color.cyan,Color.blue.brighter()};
}
void SquirmCellProperties::EIGHT(int i,int &x,int &y)
{
switch(i)
{
case 0: x=-1; y=-1; break;
case 1: x=0; y=-1; break;
case 2: x=1; y=-1; break;
case 3: x=1; y=0; break;
case 4: x=1; y=1; break;
case 5: x=0; y=1; break;
case 6: x=-1; y=1; break;
case 7: x=-1; y=0; break;
default: SquirmError("EIGHT: i out of range!"); break;
}
return;
}
void SquirmCellProperties::FOUR(int i,int &x,int &y)
{
switch(i)
{
case 0: x=0; y=-1; break;
case 1: x=1; y=0; break;
case 2: x=0; y=1; break;
case 3: x=-1; y=0; break;
default: SquirmError("FOUR: i out of range!"); break;
}
return;
}
char SquirmCellProperties::GetRandomType()
{
return "abcdef"[rand()%6];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -