tree.cpp

来自「行人模拟」· C++ 代码 · 共 56 行

CPP
56
字号
//// pedsim - A microscopic pedestrian simulation system. // Copyright (c) 2003 - 2004 by Christian Gloor//                              // You can redistribute and/or modify this program under the terms of// the GNU General Public License.  See copying.txt for details.// //using namespace std;#include "main.h"#include "tree.h"extern TreeContainer tree;// ----------------------------------------------------// Name: constructor// Description: set intial values// Introduced: chgloor Monday, December 29, 2003 11:10:37// ----------------------------------------------------Ttree::Ttree() {  static int staticid = 0;  id = staticid++;  x = 0;  y = 0;  vx = 0;  vy = 0;  energy = 100;  dead = false; // well, who knows  color = .5f + .5f * rand()/RAND_MAX;  size = .3f + .4f * rand()/RAND_MAX;  rotation = .0f + 360.0f * rand()/RAND_MAX;};// ----------------------------------------------------// Name: hit// Description: if an tree was hit by an agent // Introduced: chgloor Monday, December 29, 2003 14:06:36// ----------------------------------------------------void Ttree::hit() {  energy = energy - 0.1 ;  if (energy < 0) {    dead = true;  }};// ----------------------------------------------------// Name: move// Description: does nothing// Introduced: chgloor Monday, December 29, 2003 11:10:58// Return value: void// ----------------------------------------------------void Ttree::move() {}

⌨️ 快捷键说明

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