// Check if shots were fired on the given set of coordinates
bool CliGridRenderer::ShotsAtPosition(std::vector<Coordinates> *shots, Coordinates pos)
{
	bool fired = false;
	for (int i = 0; i < shots->size(); i++)
	{
		if (shots->at(i).GetX() == pos.GetX() && shots->at(i).GetY() == pos.GetY())
		{
			// Only return true if both x and y values match
			fired = true;
		}
	}

	return fired;
}
Beispiel #2
0
bool FieldView::DrawDot(const Coordinates& coords){
    window=get_window();        //get pointer to parent window

    //we draw only if parent window exists and if dot is colored
    if(window && field->GetColor(coords)!=NONE){
        //getting coords of point
        const double xc = (coords.GetX() + 1) * CELL_SIZE * GetScaleX();
        const double yc = (coords.GetY() + 1) * CELL_SIZE * GetScaleY();

        //preparing context
        cr = window->create_cairo_context();
        if(cr){//if pointer to contest is not NULL
            allocation = get_allocation();
            double awidth = allocation.get_width();
            double aheight = allocation.get_height();

            cr->rectangle(0.0, 0.0, awidth, aheight);
            cr->clip();

            //choose color
            switch(field->GetColor(coords)){
                case RED:
                    cr->set_source_rgb(1.0, 0.0, 0.0);
                    break;
                case BLUE:
                    cr->set_source_rgb(0.0, 0.0, 1.0);
                    break;
                default:
                    return false;
            }

            //setting line width and draw circle
            cr->set_line_width(GetScaleX() * 2.5);
            //this will draw a circle, but we've got to fat lines and this circle will be like a big fat dot
            cr->arc(xc, yc, GetScaleX(), 0.0, 2 * M_PI);

            cr->stroke();
            return true;
        }
    }
    return false;
}
bool Coordinates::operator==(const Coordinates& other) {
	if (this->GetX() == other.GetX() && this->GetY() == other.GetY()) {
		return true;
	}
	return false;
}
Beispiel #4
0
bool Coordinates::operator !=(const Coordinates& coords2) const{
    return ( (GetX() != coords2.GetX()) || (GetY() != coords2.GetY()) );
}
Beispiel #5
0
bool Coordinates::operator ==(const Coordinates& sec_coord) const{
    return ( (sec_coord.GetX() == x) && (sec_coord.GetY() == y) );
}