예제 #1
0
void
Platform::update(float elapsed_time)
{
  if (!path->is_valid()) {
    remove_me();
    return;
  }

  // check if Platform should automatically pick a destination
  if (automatic) {

    if (!player_contact && !walker->is_moving()) {
      // Player doesn't touch platform and Platform is not moving

      // Travel to node nearest to nearest player
      auto player = Sector::current()->get_nearest_player(bbox);
      if (player) {
        int nearest_node_id = path->get_nearest_node_no(player->get_bbox().p2);
        if (nearest_node_id != -1) {
          goto_node(nearest_node_id);
        }
      }
    }

    if (player_contact && !last_player_contact && !walker->is_moving()) {
      // Player touched platform, didn't touch last frame and Platform is not moving

      // Travel to node farthest from current position
      int farthest_node_id = path->get_farthest_node_no(get_pos());
      if (farthest_node_id != -1) {
        goto_node(farthest_node_id);
      }
    }

    // Clear player_contact flag set by collision() method
    last_player_contact = player_contact;
    player_contact = false;
  }

  Vector new_pos = walker->advance(elapsed_time);
  if (Editor::is_active()) {
    set_pos(new_pos);
  } else {
    movement = new_pos - get_pos();
    speed = movement / elapsed_time;
  }

}
예제 #2
0
xmlNodePtr goto_node_with_create(xmlNodePtr cur, const char *str){
  xmlNodePtr nn = goto_node(cur, str);
	if( ! nn ){
		if( !(nn=xmlNewChild(cur,NULL,(xmlChar *)str,NULL)) ){
			fprintf(stderr,"xmlNewChild() failed\n");
			return NULL;
		}
	}
	return nn;
}
예제 #3
0
파일: help.c 프로젝트: rpodgorny/ewterm
void ShowHelp() {
  if (HelpPanel) {
    beep();
    return;
  }

  MkHelpWin();
  HOldDMode = DisplayMode;
  DisplayMode |= HELPSHOWN+OTHERWINDOW;

  SetMenu(FormsMenu, 1);

  HOldEditHook = EditHook;
  EditHook = HelpEditHook;
  RedrawKeys();

  touchwin(InfoWindow);

  forms_active = 1;
  init_forms();
  if (LineBuf) {
    char *UpperBuf = strdup(LineBuf);
    char *UpperPtr = UpperBuf;

    while (*UpperPtr) { *UpperPtr = toupper(*UpperPtr); UpperPtr++; }

    if (goto_node(UpperBuf) < 0 && goto_node("OMEXCH") < 0) {
      AddEStr("Forms file not found!\n", 0, 0);
      HideForms();
      return;
    }

    free(UpperBuf);
  } else {
    if (goto_node("OMEXCH") < 0) {
      AddEStr("Forms file not found!\n", 0, 0);
      HideForms();
      return;
    }
  }
  start_loop();
}
예제 #4
0
파일: help.c 프로젝트: rpodgorny/ewterm
void HelpGotoIndex() {
	goto_node("OMEXCH");
	start_loop();
}