コード例 #1
0
ファイル: boid.c プロジェクト: csteifel/parallelboids
void moveBoid(const goalContainer * const goals, boidContainer * boidlist, int index){
	directionVector exitVec, cohVec, alignVec, averVec, acceleration;
	int i;

	acceleration.x = 0;
	acceleration.y = 0;


	//Could possibly make these all execute in parallel as well
	exitVec = moveToExit(goals, boidlist, index);
	cohVec = cohesion(boidlist, index);
	alignVec = alignment(boidlist, index);
	averVec = aversion(boidlist, index);


	//Add up vectors with weights
	addVector(&acceleration, &exitVec, 3);
	addVector(&acceleration, &cohVec, 1);
	addVector(&acceleration, &alignVec, 1);
	addVector(&acceleration, &averVec, 2);

	//Limit the vector to required speed
	limitVec(&acceleration);

	boidlist->boidArr[index].velocity = acceleration;
	boidlist->boidArr[index].xpos += acceleration.x;
	boidlist->boidArr[index].ypos += acceleration.y;

	for(i = 0; i < goals->size; i++){
		if(boidlist->boidArr[index].xpos == goals->pos[i][0] && boidlist->boidArr[index].ypos == goals->pos[i][1]){
			boidlist->boidArr[index].active = 0;
		}
	}
	
}
コード例 #2
0
ファイル: empty.c プロジェクト: Developer626/YouCannotGoBack
bool tickEmpty(bool _doInit) {
  if (_doInit == true) {
    s_state = 0;
    m_player.m_position = GPoint(0, SIZE*9);
    addCluter(20, 20, 0);
    return false;
  }

  if (s_state == 0) { // start initial move
    enterRoom(&s_state);
  } else if (s_state == 1) { // initial move is done
    setGameState(kAwaitInput);
    ++s_state;
  } else if (s_state == 2) {
    moveToExit(&s_state);
  } else if (s_state == 3) {
    setGameState(kFadeOut);
  }

  return false;
}
コード例 #3
0
ファイル: start.c プロジェクト: Developer626/YouCannotGoBack
bool tickStart(bool _doInit) {
  if (_doInit == true) {
    s_state = 0;
    m_player.m_position = GPoint(0, SIZE*9);
    addCluter(4, 0, 20); // Only left
    return false;
  }

  static bool _first = true;
  static const char _msgA[] = "SHAKE TO TURN...";
  static const char _msgB[] = "ON BACKLIGHT";

  if (s_state == 0) { // start initial move
    enterRoom(&s_state);
  } else if (s_state == 1) { // initial move is done
    if (_first == true) {
      setDisplayMsg(_msgA);
      setGameState(kDisplayMsg);
      s_state = 2;
      _first = false;
    } else {
      setGameState(kAwaitInput);
      s_state = 4;
    }
  } else if (s_state == 2) {
    setDisplayMsg(_msgB);
    setGameState(kDisplayMsg);
    ++s_state;
  } else if (s_state == 3) {
    setGameState(kAwaitInput);
    ++s_state;
  } else if (s_state == 4) {
    moveToExit(&s_state);
  } else if (s_state == 5) {
    setGameState(kFadeOut);
  }

  return false;
}