squirmcell.cpp

来自「本程序模拟细胞的自我繁殖」· C++ 代码 · 共 22 行

CPP
22
字号
// SquirmCell.cpp

#include "stdafx.h"
#include "SquirmCell.h"
#include "SquirmCellSlot.h"

#include <math.h>

SquirmCell::SquirmCell(C2dVector loc,char type,int state)
     : SquirmCellProperties(type,state)
{
    this->location = loc;
    AssignRandomVelocity();
}

void SquirmCell::AssignRandomVelocity()
{
	// initialize with a random velocity
	float angle = rand()*2.0F*3.1415926535F/RAND_MAX;
	this->velocity.x = MAX_VELOCITY * (float)cos(angle);
	this->velocity.y = MAX_VELOCITY * (float)sin(angle);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?