Esempio n. 1
0
bool DrawCircleTool::mouseReleaseEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget)
{
	Q_UNUSED(widget);
	
	if (!isDrawingButton(event->button()))
	{
		if (event->button() == Qt::RightButton)
			abortDrawing();
		return false;
	}
	if (!editingInProgress())
		return false;
	
	updateStatusText();
	
	if (dragging || second_point_set)
	{
		cur_pos = event->pos();
		cur_pos_map = map_coord;
		if (dragging && !second_point_set)
			opposite_pos_map = map_coord;
		updateCircle();
		finishDrawing();
		return true;
	}
	return false;
}
Esempio n. 2
0
bool DrawCircleTool::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget)
{
	Q_UNUSED(widget);
	
	bool mouse_down = containsDrawingButtons(event->buttons());
	
	if (!mouse_down)
	{
		if (!editingInProgress())
		{
			setPreviewPointsPosition(map_coord);
			setDirtyRect();
		}
		else
		{
			cur_pos = event->pos();
			cur_pos_map = map_coord;
			if (!second_point_set)
				opposite_pos_map = map_coord;
			updateCircle();
		}
	}
	else
	{
		if (!editingInProgress())
			return false;
		
		if ((event->pos() - click_pos).manhattanLength() >= Settings::getInstance().getStartDragDistancePx())
		{
			if (!dragging)
			{
				dragging = true;
				updateStatusText();
			}
		}
		
		if (dragging)
		{
			cur_pos = event->pos();
			cur_pos_map = map_coord;
			if (!second_point_set)
				opposite_pos_map = cur_pos_map;
			updateCircle();
		}
	}
	return true;
}
Esempio n. 3
0
void Character::init(Ground *ground) {
  circle_vector_.push_back(Circle());
  circle_ = &circle_vector_[0];
  circle_->radius = 0.001f;
  drawer_.init(&circle_vector_);
  drawer_.setParent(Renderer::instance().rootNode());
  drawer_.setDisplayPriority(5.0f);
  drawer_.setIsVisible(true);
  ground_ = ground;
  position_.x = kPlayerWidth;
  updateY(0.0f);
  updateCircle();
}
Esempio n. 4
0
void Character::update(float delta_time, GameState *state) {
  if (*state == WALKING) {
    // Update x position.
    if (left_down_) moveLeft(delta_time);
    if (right_down_) moveRight(delta_time);
    // Udpate y postion.
    if (space_pressed_) this->jump();
  }
  if (*state == TRIGGERING_JUMPING || *state == ENDING) {
    if (time_on_ground_ > time_till_next_jump_) {
      this->jump();
      time_till_next_jump_ = randomFloat(0.0f, 0.2f);
    }
  }
  updateY(delta_time);
  updateCircle();
}