void GUICheckBox::Draw(SDL_Surface *dst){
  if(isCircle){
    int rad = ((posX2-posX1<posY2-posY1)?(posX2-posX1):(posY2-posY1))-7;
    filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,0xFFFFFFFF);
    arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,135,315,0x000000FF);
    arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad+1,135,315,0x808080FF);
    arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,315,135,0xD4D0C8FF);
    arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad+1,315,135,0xFFFFFFFF);
    if(isChecked)filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad-3,0x000000FF);
  }else{
    boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFFF);
    GUIDrawBorder(dst,posX1,posY1,posX2,posY2,0x808080FF,0x404040FF,0xFFFFFFFF,0xD4D0C8FF);
    if(isChecked){
      int tickX=((posX2+posX1)/2)-2,tickY=((posY2+posY1)/2)-3; Uint32 clr=0x000000FF;
      boxColor(dst,tickX+1,tickY+4,tickX+3,tickY+5,clr);
      boxColor(dst,tickX+4,tickY+2,tickX+5,tickY+3,clr);
      vlineColor(dst,tickX,tickY+2,tickY+4,clr);
      vlineColor(dst,tickX+6,tickY,tickY+2,clr);
      pixelColor(dst,tickX+1,tickY+3,clr);
      pixelColor(dst,tickX+3,tickY+3,clr);
      pixelColor(dst,tickX+4,tickY+4,clr);
      pixelColor(dst,tickX+5,tickY+1,clr);
      pixelColor(dst,tickX+2,tickY+6,clr);
    }
  }
}
Пример #2
0
void DrawImpendingDoom(SDL_Surface *screen, GameState *gs)
{
	for(unsigned p = 0; p < gs->player_count; p++)
	{
		if(gs->board[p].ojamms_pending >0 ){
			Sint16 x_offset = gs->board[p].x_offset;
			Sint16 y_offset = gs->board[p].y_offset;
			Sint16 width_in_px = gs->board[p].width_in_px;
			Sint16 piece_width = gs->board[p].piece_width;
			Sint16 piece_height = gs->board[p].piece_height;
		
			int x = x_offset + 15 + (p * width_in_px);
			int y = 5;
			int r = (piece_width + piece_height) / 4;

			Uint32 color = 0x333333FF;
			filledCircleColor(screen, x+r, y+r, r, color);
			filledCircleColor(screen, x+r-r/2, y+r+r/4, r/4, 0x000000FF);
			filledCircleColor(screen, x+r+r/2, y+r+r/4, r/4, 0x000000FF);

			if(font_on){
				std::stringstream s;
				s << " incoming: " << gs->board[p].ojamms_pending << "   ";
				SDL_Color fg = {0xFF,0xFF,0xFF};
				SDL_Color bg = {0x33,0x33,0x33};
				SDL_Surface *fontsurf = TTF_RenderText(gs->font, s.str().c_str(),fg, bg);
				SDL_Rect fontblitrect = {x+r*4, y+2, 50, 50};
				SDL_BlitSurface(fontsurf, NULL, screen, &fontblitrect);
				SDL_FreeSurface(fontsurf);
			}
		}
	}
}
Пример #3
0
void DrawPuyos(SDL_Surface *screen, GameState *gs)
{
	for(unsigned p = 0; p < gs->player_count; p++){
		Sint16 x_offset = gs->board[p].x_offset;
		Sint16 y_offset = gs->board[p].y_offset;
		Sint16 width_in_px = gs->board[p].width_in_px;
		Sint16 piece_width = gs->board[p].piece_width;
		Sint16 piece_height = gs->board[p].piece_height;

		for(unsigned x = 0; x < gs->board[p].width_in_pieces; x++){
			for(unsigned y = 0; y < gs->board[p].height_in_pieces; y++){
				if(gs->board[p].b[x][y] != NULL){
					Piece *piece = gs->board[p].b[x][y];
					Sint16 x = x_offset + (piece->x * piece_width)  + (p * width_in_px);
					Sint16 y = y_offset + (piece->y * piece_height);
					Sint16 r = (piece_width + piece_height) / 4;

					Uint32 color = 0x000000FF;
					switch(piece->color)
					{
					case BLUE:
						color = 0x0000FFFF;
						break;
					case ORANGE:
						color = 0xFF9900FF;
						break;
					case GREEN:
						color = 0x00FF00FF;
						break;
					case PURPLE:
						color = 0x9900FFFF;
						break;
					case YELLOW:
						color = 0xFFFF00FF;
						break;
					case OJAMM:
						color = 0x333333FF;
						break;
					default:
						break;
					}

					filledCircleColor(screen, x+r, y+r, r, color);
					filledCircleColor(screen, x+r-r/2, y+r+r/4, r/4, 0x000000FF);
					filledCircleColor(screen, x+r+r/2, y+r+r/4, r/4, 0x000000FF);
				}
			}
		}
	}
}
Пример #4
0
void draw_test(SDL_Surface* s, Point mid) {
  return;
  Point start = {100.0,100.0};
  Point end = {200.0,200.0};
  Point towards = add_Point(end,mult_Point(0.3,subs_Point(end,start)));

  filledCircleColor(s,(int)start.x, (int) start.y, 5,intColor(c_fuchsia));
  filledCircleColor(s,(int) end.x, (int) end.y, 5,intColor(c_fuchsia));
  filledCircleColor(s,(int)mid.x, (int) mid.y, 5,intColor(c_fuchsia));
  filledCircleColor(s,(int)towards.x, (int) towards.y, 5,intColor(c_fuchsia));

  draw_B_spline(s,
		start, subs_Point(mult_Point(2.0,start),mid),
		end, towards, c_fuchsia);
}
Пример #5
0
void mediumbullet(int x, int y, SDL_Surface *surface, style *st)
{
	if(st->bullet2 != NULL)
	{
		SDL_Rect dst;
		dst.x = x - (st->bullet2->w / 2);
		dst.y = y - (st->bullet2->h / 2);
		SDL_BlitSurface(st->bullet2, NULL, surface, &dst);
	}
	else
	{
		Uint32 pen = colour->pens->item(st->bullet2colour);
		filledCircleColor(surface, x, y, st->bullet2size, colour->light_grey_pen);
		filledCircleColor(surface, x, y, st->bullet2size - 1, pen);
	}
}
Пример #6
0
/*****************************************************************
関数名 : DrawShot
機能	: 先輩こいつ玉とか描画しはじめましたよ
引数	: なし
出力	: なし
*****************************************************************/
void DrawShot()
{
	int i, j;
	double x, y;
	Pos spos;
	for(i=0; i<MAX_SHOT; i++){
		if(gShot[i].state == LIVING){
			if(gShot[i].type == LASER){
				spos.x = gBoss.pos.x + gBoss.shotpos[gShot[i].id+MAX_BOSSGUN].x; //発射座標
				spos.y = gBoss.pos.y + gBoss.shotpos[gShot[i].id+MAX_BOSSGUN].y;
				if(gShot[i].id >= 0){
					lineColor(gMainWindow, gChara[gShot[i].id].pos.x+S_SIZE/2, gChara[gShot[i].id].pos.y+S_SIZE/2+1,
								gShot[i].pos.x, gShot[i].pos.y+1, gShot[i].color);
				}
				else{
					for(j= -gShot[i].size/2; j<gShot[i].size/2+1; j++){
						x = j; y = (double)j*j/gShot[i].size;
						lineColor(gMainWindow, spos.x + (x * cos(-gShot[i].dir * M_PI / 180) - y * sin(-gShot[i].dir * M_PI / 180)),
												spos.y - (x * sin(-gShot[i].dir * M_PI / 180) + y * cos(-gShot[i].dir * M_PI / 180)),
												gShot[i].pos.x + (x * cos(-gShot[i].dir * M_PI / 180) - gShot[i].size / 4 * sin(-gShot[i].dir * M_PI / 180)),
												gShot[i].pos.y - (x * sin(-gShot[i].dir * M_PI / 180) + gShot[i].size / 4 * cos(-gShot[i].dir * M_PI / 180)),
												gShot[i].color);
					}
				}
			}
			else{
				filledCircleColor(gMainWindow, gShot[i].pos.x, gShot[i].pos.y, gShot[i].size, gShot[i].color);
			}
		}
	}
}
Пример #7
0
void PlayMode::drawPlayer()
{
  if(!crashed)
  {
    // draw the player
    filledCircleColor(display, 145,(int)(player_pos + 4.5f), 5, 0x9DD8F6FF);
  }
}
Пример #8
0
void GUICheckBox::Draw(SDL_Surface *dst){
  if(isCircle){
    int rad = ((posX2-posX1<posY2-posY1)?(posX2-posX1):(posY2-posY1))-7;
    filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,0xFFFFFFFF);
    aacircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,BORDER);
    if(isChecked){
      filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad-3,0x000000FF);
      aacircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad-3,0x000000FF);
    }
  }else{
    boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFFF);
    rectangleColor(dst,posX1,posY1,posX2,posY2,BORDER);
    if(isChecked){
      thickLineColor(dst,posX1+1,posY1+1,posX2-1,posY2-1,3,0x000000FF);
      thickLineColor(dst,posX1+1,posY2-1,posX2-1,posY1+1,3,0x000000FF);
    }
  }
}
Пример #9
0
int GeoLayer::circle_fill(int16_t x, int16_t y, int16_t r, uint32_t col) {
    if(!surf) {
        error("%s can't run: layer not initialized", __PRETTY_FUNCTION__);
        return -1;
    }
    res = filledCircleColor(surf, x, y, r, col);
    if(res < 0) error("error in %s (%i, %i, %i, %u)", __PRETTY_FUNCTION__, x, y, r, col);
    return(res);
}
Пример #10
0
CAMLprim value ml_filledCircleColor(value dst,value p,value ra, value col)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect prect;
  int r;

  SDLRect_of_value(&prect,p);
  r=filledCircleColor(sur,prect.x,prect.y,Int_val(ra),Int32_val(col));

  return Val_bool(r);
}
Пример #11
0
//http://www.ferzkopp.net/Software/SDL2_gfx/Docs/html/_s_d_l2__gfx_primitives_8h.html
//utilisation de la primitive gfx
// ici on ajoute des cercles pein ou vide
// on peut aussi ajouter des courbes de bézier, des polygones,des lignes épaisses...
void createShapes(){
        Sint16 circleR = 100;
        Sint16 circleX = 300;
        Sint16 circleY = 300;
        SDL_Renderer* renderer=SDLS_getRenderer();
        filledCircleColor(renderer, circleX, circleY, circleR, 0xFF0000FF);
        circleRGBA(renderer,200,200,100,0,255,0,255);
        roundedRectangleRGBA(renderer,10,10,100,100,30,120,120,0,255);
        thickLineRGBA(renderer,450,150,150,450,50,255,0,255,255);
        trigonRGBA(renderer,100,100,200,200,100,300,0,255,120,255);
        Sint16 vx[10]={10,50,150,200, 220,240,410,500,200,250};
         Sint16 vy[10]={10,80,10,0,10,30,50,80,30,150};
        bezierRGBA(renderer,vx,vy,10,3,50,0,255,255);
}
Пример #12
0
GridMap dilate(const GridMap& map, int amount) {
	const int w = map[0].size(), h = map.size();
	SDL_Surface* surf = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0xff, 0);
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (map[y][x]) {
				filledCircleColor(surf, x, y, amount, 0xffffff);
			}
		}
	}
	GridMap out(h, GridRow(w));
	for (int y = 0; y < h; y++) {
		Uint32* srcrow = reinterpret_cast<Uint32*>(static_cast<char*>(surf->pixels) + surf->pitch * y);
		GridRow& dstrow = out[y];
		for (int x = 0; x < w; x++) {
			if (srcrow[x])
				dstrow[x] = true;
		}
	}
	return out;
}
Пример #13
0
static PyObject*
_gfx_filledcirclecolor (PyObject *self, PyObject* args)
{
    PyObject *surface, *color, *pt;
    int x, y, r;
    pguint32 c;

    ASSERT_VIDEO_INIT (NULL);

    if (!PyArg_ParseTuple (args, "OOiO:filledcircle", &surface, &pt, &r,
        &color))
    {
        PyErr_Clear ();
        if (!PyArg_ParseTuple (args, "OiiiO:filledcircle", &surface, &x, &y,
            &r, &color))
            return NULL;
    }
    else
    {
        if (!PointFromObj (pt, (int*)&x, (int*)&y))
            return NULL;
    }
    
    if (!PySDLSurface_Check (surface))
    {
        PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
        return NULL;
    }
    if (!ColorFromObj (color, &c))
        return NULL;

    if (filledCircleColor (((PySDLSurface*)surface)->surface,
            (Sint16)x, (Sint16)y, (Sint16)r, (Uint32)c) == -1)
    {
        PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
        return NULL;
    }
    Py_RETURN_NONE;
}
Пример #14
0
void graphics_fill_circle(GContext *ctx, GPoint p, int radius) {
    GPoint topOffset=getTopOffset ();
    filledCircleColor(getTopScreen(), topOffset.x+p.x, topOffset.y+p.y, radius, getRawColor(ctx->fill_color));
}
Пример #15
0
void DrawParticles(SDL_Surface *screen, std::vector<Particle> &particles)
{
	for(unsigned i = 0; i < particles.size(); i++){
		filledCircleColor(screen, particles[i].x, particles[i].y, 3, particles[i].color);
	}
}
Пример #16
0
/**
 * @brief This function draws a filled circle in the matrix.
 *
 * @param center The centre of the circle.
 * @param radius The radius of the circle.
 * @param number The number to use to fill the circle.
 */
void Matrix::DrawCircle(Point center, int radius, Uint8 number)
{
    pthread_mutex_lock((pthread_mutex_t*)&m_mutex);
    filledCircleColor(m_surface, center.x, center.y, radius, number << 24 | 0xFF);
}
Пример #17
0
void Boid::DrawDebug(SDL_Renderer* renderer)
{
	if (currentBehaviour == Behaviour::OBSTACLE_AVOIDANCE)
	{
		if (obstacleAvoidanceCollision == true)
		{
			filledCircleColor(renderer, avoidTarget.x, avoidTarget.y, 10, Colors::TURQUOISE);
		}
	}
	else if (currentBehaviour == Behaviour::COLLISION_AVOIDANCE 
		|| currentBehaviour == Behaviour::PRIORITY_COLLISION)
	{
		static int timerColor = 0;
		int maxTime = 10;
		Uint32 collisionColor = Colors::BELIZE_HOLE;
		if (collisionDetected == true || timerColor > 0)
		{
			collisionColor = Colors::ORANGE;
			if (collisionDetected == true)
			{
				timerColor = maxTime;
			}
		}
		--timerColor;
		Vector2D triangleX1 = { position.x + coneHeight, position.y - tanf(coneHalfAngle * DEG2RAD) * coneHeight };
		Vector2D triangleX2 = { position.x + coneHeight, position.y + tanf(coneHalfAngle * DEG2RAD) * coneHeight };
		Vector2D rotatedTriangle1 = Vector2DUtils::RotatePoint(position, triangleX1, angle);
		Vector2D rotatedTriangle2 = Vector2DUtils::RotatePoint(position, triangleX2, angle);
		filledTrigonColor(renderer, position.x, position.y,
			rotatedTriangle1.x, rotatedTriangle1.y,
			rotatedTriangle2.x, rotatedTriangle2.y,
			collisionColor);
		return;
	}
	else if (currentBehaviour == Behaviour::ARRIVE)
	{
		circleRGBA(renderer, target->position.x, target->position.y, slowingRadius, 255, 255, 0, 255);
		sprintf(textBuffer, "Speed = %.2f", desiredVelocity.Length());
		RotatedText_SetText(&informationText4, textBuffer);
		RotatedText_DrawText(&informationText4, position.x + 10.0f,
			position.y + 10.0f, 0.0f,
			0, 0, 255, 255);
	}
	else if (currentBehaviour == Behaviour::WANDER)
	{
		circleRGBA(renderer, wanderCircleCenter.x, wanderCircleCenter.y, wanderCircleRadius, 255, 255, 0, 255);
		filledCircleRGBA(renderer, wanderDisplacementVector.x, wanderDisplacementVector.y, 10, 128, 0, 128, 255);

		SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
		SDL_RenderDrawLine(renderer, position.x, position.y, wanderDisplacementVector.x, wanderDisplacementVector.y);
	}
	else if (currentBehaviour != Behaviour::PRIORITY_OBSTACLE)
	{
		int currentTextAngle;

		SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
		SDL_RenderDrawLine(renderer, position.x, position.y, position.x + speed.x, position.y + speed.y);

		if (isSteering == true)
		{
			SDL_SetRenderDrawColor(renderer, 255, 255, 0, 255);
			SDL_RenderDrawLine(renderer, position.x, position.y, position.x + desiredVelocity.x, position.y + desiredVelocity.y);

			SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255);
			SDL_RenderDrawLine(renderer, position.x + speed.x, position.y + speed.y, position.x + desiredVelocity.x, position.y + desiredVelocity.y);

			currentTextAngle = atan2f(desiredVelocity.y, desiredVelocity.x) * RAD2DEG;
			if (currentTextAngle < -90 || (currentTextAngle > 90 && currentTextAngle < 180))
			{
				currentTextAngle = currentTextAngle - 180;
			}
			RotatedText_DrawText(&informationText2,
				(2 * position.x + (desiredVelocity.x)) / 2,
				(2 * position.y + desiredVelocity.y) / 2,
				currentTextAngle,
				255, 255, 0, 255);

			currentTextAngle = atan2f((desiredVelocity.y - speed.y), (desiredVelocity.x - speed.x)) * RAD2DEG;
			if (currentTextAngle < -90 || (currentTextAngle > 90 && currentTextAngle < 180))
			{
				currentTextAngle = currentTextAngle - 180;
			}
			RotatedText_DrawText(&informationText3,
				(position.x + (speed.x) + position.x + (desiredVelocity.x)) / 2,
				(position.y + speed.y + position.y + desiredVelocity.y) / 2,
				currentTextAngle,
				255, 0, 255, 255);

			if (currentBehaviour == Behaviour::PURSUE || currentBehaviour == Behaviour::EVADE)
			{
				filledCircleRGBA(renderer, futurePosition.x, futurePosition.y, 20, 255, 255, 0, 255);
			}
		}

		currentTextAngle = angle;
		if (currentTextAngle < -90 || (currentTextAngle > 90 && currentTextAngle < 180))
		{
			currentTextAngle = currentTextAngle - 180;
		}
		RotatedText_DrawText(&informationText1,
			(2 * position.x + (speed.x)) / 2,
			(2 * position.y + speed.y) / 2,
			currentTextAngle,
			255, 0, 0, 255);
	}
}
Пример #18
0
void Surface::filledCircle(Sint16 x, Sint16 y, Sint16 r, const SDL_Color& c) {
	filledCircleColor(surface, x, y, r, getRGBA(c));
	aacircleColor(surface, x, y, r, getRGBA(c));
}
Пример #19
0
void CellGrid::draw_active_water(Coord here) {
  //Draw the water located at 'here' to water_surface
  //...fancy!
  CellBox cell = CellBox(*this, here, AIR, ROCK, INACTIVE_WATER, INACTIVE_WATER);
  int exposed_count = cell.count(EXPOSED_WATER);
  int inactive_count = cell.count(INACTIVE_WATER);
  int air_count = cell.count(AIR);

  //We draw either a bubble, or a wave.
  bool draw_bubble = true;
  //These are directions, for drawing waves.
  //a1 and a2 indicate what the lines will be drawn through.
  int a1 = -1, a2 = -1;
  //'under' indicates what part is under water
  int under = -1;
 

  //Determine how to proceed
  if (air_count == 3 && exposed_count == 0 && inactive_count == 1) {
    //tower of water?
    int d = cell.find(INACTIVE_WATER);
    a1 = rotate_cc(d);
    a2 = rotate_co(d);
    under = d;
    draw_bubble = false;
  }
  else if (air_count == 2 && exposed_count == 1 && inactive_count == 1) {
    int e = cell.find(EXPOSED_WATER), i = cell.find(INACTIVE_WATER);
    int ei_angle = normalize_angle(angle(e, i));
    if (ei_angle == 4) {
      //opposite
      a1 = rotate_cc(i);
      a2 = rotate_co(i);
      under = i;
    }
    else if (ei_angle == 2 || ei_angle == 6) {
      //adjacent
      a1 = e;
      under = i;
      //a2 is i rotated away from a1
      if (ei_angle == 6) {
        a2 = rotate_cc(i);
      }
      else {
        a2 = rotate_co(i);
      }
    }
    else {
      throw ei_angle;
    }
    draw_bubble = false;
  }
  else if (air_count == 1 && exposed_count == 2 && inactive_count == 1) {
    int e1 = cell.find(EXPOSED_WATER, 0), e2 = cell.find(EXPOSED_WATER, 1);
    if (normalize_angle(angle(e1, e2)) == 4) {
      //We've got two exposeds opposite, with an inactive on one side
      //put the line between the two inactives
      a1 = e1;
      a2 = e2;
      draw_bubble = false;
      under = cell.find(INACTIVE_WATER);
    }
  }
  else if (air_count == 1 && exposed_count == 1 && inactive_count == 2) {
    //similiar to above, except we want two inactives adjacent
    int i1 = cell.find(INACTIVE_WATER, 0), i2 = cell.find(INACTIVE_WATER, 1);
    int n = normalize_angle(angle(i1, i2));
    if (n == 2 || n == 6) {
      draw_bubble = false;
      int e = cell.find(EXPOSED_WATER);
      int between = opposite(cell.find_air());
      a1 = e;
      a2 = opposite(e);
      under = between;
      int direction = normalize_angle(angle(between, a2));
      if (direction == 6) {
        a2 = rotate_cc(a2);
      }
      else {
        a2 = rotate_co(a2);
      }
    }
  }
  

  
  //Now do the drawing
  int seed = (here.x << here.y) + (ticks/15); //used for RNG
  const Uint32 surface_color = CellData::color(EXPOSED_WATER);
  const Uint32 under_water = CellData::color(INACTIVE_WATER);
  SDL_FillRect(water_surface, NULL, CellData::color(AIR));

  if (draw_bubble) {
    if (air_count == 4) {
      //draw drop of water instead
      seed = (here.x * 191) >> 3;
      const int offset = (block_pixel_size/2) - 1;
      const int radius = (block_pixel_size/3)-(seed % 5);
      filledCircleColor(water_surface, offset, offset, radius, under_water);
      circleColor(water_surface, offset, offset, radius, surface_color);
    }
    else {
      //A few random foamy bubbles
      if (inactive_count == 4) {
Пример #20
0
int main(int argc, char *argv[]) {
	SDL_Event ev,az;
	SDL_Surface *screen;
	SDL_Surface *kep;
	SDL_TimerID id;
	FILE *fp;
	int x, y,click=0,clicktwo=0,aut=0,quit=0,gomb=0,egerx,egery,nothinghappened=1;
	cell cells[MAX][MAX]={0};

	kep=IMG_Load("sejt.png");
	if(!kep)
		fprintf(stderr, "Nem sikerult betolteni a kepfajlt!\n");

	/* SDL inicializálása és ablak megnyitása */
	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
	screen=SDL_SetVideoMode(MAX*MERET+KERET*2+100, MAX*MERET+KERET*2-100, 0, SDL_FULLSCREEN);
	if (!screen) {
		fprintf(stderr, "Nem sikerult megnyitni az ablakot!\n");
		exit(1);
	} 
	SDL_WM_SetCaption("Game Of Life", "Game Of Life");
	
	SDL_FillRect(screen, NULL, 0x433e3f);
	boxColor(screen,KERET/3,KERET/3,MAX*MERET+KERET*2-KERET/3,MAX*MERET+KERET*2-KERET/3,KERETSZIN);

	drawcell(cells,screen,kep);



	while(!quit)
	{
		boxColor(screen, MAX*MERET+KERET*2+10,KERET+5,MAX*MERET+KERET*2+90,KERET+40,0xFFDFD2FF);
		boxColor(screen, MAX*MERET+KERET*2+14,KERET+9,MAX*MERET+KERET*2+86,KERET+36,0xE5C8BDFF);
		stringRGBA(screen, MAX*MERET+KERET*2+20, KERET+19, "Leptetes", 255, 255, 255, 255);

		boxColor(screen, MAX*MERET+KERET*2+10,KERET+5+HEZAG,MAX*MERET+KERET*2+90,KERET+40+HEZAG,0xFFDFD2FF);
		boxColor(screen, MAX*MERET+KERET*2+14,KERET+9+HEZAG,MAX*MERET+KERET*2+86,KERET+36+HEZAG,0xE5C8BDFF);
		if(aut==0)
			stringRGBA(screen, MAX*MERET+KERET*2+15, KERET+69, "Szimul.be", 255, 255, 255, 255);
		else
			stringRGBA(screen, MAX*MERET+KERET*2+15, KERET+69, "Szimul.ki", 255, 255, 255, 255);

		boxColor(screen, MAX*MERET+KERET*2+10,KERET+5+HEZAG*2,MAX*MERET+KERET*2+90,KERET+40+HEZAG*2,0xFFDFD2FF);
		boxColor(screen, MAX*MERET+KERET*2+14,KERET+9+HEZAG*2,MAX*MERET+KERET*2+86,KERET+36+HEZAG*2,0xE5C8BDFF);
		stringRGBA(screen, MAX*MERET+KERET*2+26, KERET+19+HEZAG*2, "Torles", 255, 255, 255, 255);

		boxColor(screen, MAX*MERET+KERET*2+10,KERET+5+HEZAG*3,MAX*MERET+KERET*2+90,KERET+40+HEZAG*3,0xFFDFD2FF);
		boxColor(screen, MAX*MERET+KERET*2+14,KERET+9+HEZAG*3,MAX*MERET+KERET*2+86,KERET+36+HEZAG*3,0xE5C8BDFF);
		stringRGBA(screen, MAX*MERET+KERET*2+27, KERET+19+HEZAG*3, "Kilovo", 255, 255, 255, 255);

		filledCircleColor(screen,MAX*MERET+2*KERET+80,9,8,0xFFDFD2FF);
		filledCircleColor(screen,MAX*MERET+2*KERET+80,9,6,0xE5C8BDFF);
		stringRGBA(screen,MAX*MERET+KERET*2+77,6,"X",255,255,255,255);
		
		SDL_Flip(screen);

		
		while(SDL_PollEvent(&ev)){
			switch(ev.type)
			{
				/*case SDL_KEYDOWN:
				switch(ev.key.keysym.sym)
				{
				case SDLK_s:
				mentes(cells);		   
				break;
				case SDLK_l:
				fp=fopen("save.txt","r");

				for(y=0;y<MAX;y++)
				for(x=0;x<MAX;x++)
				fscanf(fp,"%d ",&cells[y][x].alive);

				fclose (fp);

				drawcell(cells,screen,kep);
				SDL_Flip(screen);
				break;
				}
				break;*/

			case SDL_MOUSEBUTTONDOWN:
				if(ev.button.button==SDL_BUTTON_LEFT)
				{
					if(ev.button.x<=MAX*MERET+KERET){
						egerx=holazeger(ev.button.x);
						egery=holazeger(ev.button.y);

						if(cells[egery][egerx].alive==1)
							cells[egery][egerx].alive=0;
						else
							cells[egery][egerx].alive=1;
					}

					else if(incircle(ev.button.x,ev.button.y,MAX*MERET+2*KERET+80,9,8))
						quit=1;

					else if((ev.button.x<=MAX*MERET+KERET*2+90 && ev.button.x>=MAX*MERET+KERET*2+10) && (ev.button.y<=KERET+40 && ev.button.y>=KERET+5))//egyes lépés
					{
						round(cells);

					}
					else if((ev.button.x<=MAX*MERET+KERET*2+90 && ev.button.x>=MAX*MERET+KERET*2+10) && (ev.button.y<=KERET+90 && ev.button.y>=KERET+55))//szimulálás
					{
						if(aut==0)
							aut=1;
						else aut=0;	
					}
					else if((ev.button.x<=MAX*MERET+KERET*2+90 && ev.button.x>=MAX*MERET+KERET*2+10) && (ev.button.y<=KERET+40+HEZAG*2 && ev.button.y>=KERET+5+HEZAG*2))//egyes lépés
					{
						for(y=0;y<MAX;y++)
							for(x=0;x<MAX;x++)
								cells[y][x].alive=0;
					}
					else if((ev.button.x<=MAX*MERET+KERET*2+90 && ev.button.x>=MAX*MERET+KERET*2+10) && (ev.button.y<=KERET+40+HEZAG*3 && ev.button.y>=KERET+5+HEZAG*3))//egyes lépés
					{
						fp=fopen("save.txt","r");

						for(y=0;y<MAX;y++)
							for(x=0;x<MAX;x++)
								fscanf(fp,"%d ",&cells[y][x].alive);

						fclose (fp);

						drawcell(cells,screen,kep);
						SDL_Flip(screen);
					}
					drawcell(cells,screen,kep);
					SDL_Flip(screen);
				}
				break;

			case SDL_MOUSEBUTTONUP:
				if(ev.button.button==SDL_BUTTON_LEFT)
				{
					click=0;
					clicktwo=0;
				}
				break;

			case SDL_QUIT:
				quit=1;
				break;
			}
		}

		if(aut)
		{
			SDL_Delay(100);
			round(cells);
			drawcell(cells,screen,kep);
			SDL_Flip(screen);
		}


	}


	SDL_FreeSurface(kep);
	SDL_Quit();
	exit(0);
	return 0;
}
Пример #21
0
/*****************************************************************
関数名 : DrawShip
機能	: 船(仮)を描画する
引数	: なし
出力	: なし
*****************************************************************/
void DrawShip()
{
	int i;
	Rect rect = {{0, 0, F_WIDTH, HEIGHT}, {0, 0}};

	for(i=0; i<CT_NUM; i++){
		if(gChara[i].state == LIVING){
			rect.src.x = (((gChara[i].dir % 360) % 45) / 5 * S_SIZE);
			rect.src.y = ((gChara[i].dir % 360) / 45) * S_SIZE;
			rect.src.w = rect.src.h = S_SIZE;
			rect.dst.x = gChara[i].pos.x;
			rect.dst.y = gChara[i].pos.y;
			SDL_BlitSurface(ShipWindow[i], &(rect.src), gMainWindow, &(rect.dst));

			//hpを表す四角形を描画
			if(gChara[i].hp > gChara[i].maxhp/2)
				boxColor(gMainWindow, gChara[i].pos.x - S_SIZE / 2 , gChara[i].pos.y + S_SIZE,
						gChara[i].pos.x - S_SIZE / 2 + S_SIZE * 2 * (double)(gChara[i].hp) / gChara[i].maxhp, gChara[i].pos.y + S_SIZE + 10, 0x00ff0080);
			else
				boxColor(gMainWindow, gChara[i].pos.x - S_SIZE / 2 , gChara[i].pos.y + S_SIZE,
						gChara[i].pos.x - S_SIZE / 2 + S_SIZE * 2 * (double)(gChara[i].hp) / gChara[i].maxhp, gChara[i].pos.y + S_SIZE + 10, 0xff000080);
			rectangleColor(gMainWindow, gChara[i].pos.x - S_SIZE / 2, gChara[i].pos.y + S_SIZE,
					gChara[i].pos.x + S_SIZE * 3 / 2, gChara[i].pos.y + S_SIZE + 10 , 0xff000080);
		}
	}

	for(i=0; i<MAX_USEMOB; i++){
		if(gMob[i].state == LIVING){
			if(gMob[i].anipatnum <= 1)
				rect.src.x = 0;
			else{
				gMob[i].anipat = (gMob[i].anipat + 1) % (gMob[i].anipatnum * 2);
				rect.src.x = gMob[i].anipat/2 * gMob[i].w;
			}
			rect.src.y = 0;
			rect.src.w = gMob[i].w;
			rect.src.h = gMob[i].h;
			rect.dst.x = gMob[i].pos.x;
			rect.dst.y = gMob[i].pos.y;
			SDL_BlitSurface(MobWindow[gMob[i].no], &(rect.src), gMainWindow, &(rect.dst));

			//hpを表す四角形を描画
			if(gMob[i].hp > gMob[i].maxhp/2)
				boxColor(gMainWindow, gMob[i].pos.x - 50 , gMob[i].pos.y + gMob[i].h,
						gMob[i].pos.x - 50 + (gMob[i].w + 100) * (double)(gMob[i].hp) / gMob[i].maxhp, gMob[i].pos.y + gMob[i].h + 10, 0x00ff0080);
			else
				boxColor(gMainWindow, gMob[i].pos.x - 50 , gMob[i].pos.y + gMob[i].h,
						gMob[i].pos.x - 50 + (gMob[i].w +100) * (double)(gMob[i].hp) / gMob[i].maxhp, gMob[i].pos.y + gMob[i].h + 10, 0xff000080);
			rectangleColor(gMainWindow, gMob[i].pos.x - 50, gMob[i].pos.y + gMob[i].h,
					gMob[i].pos.x + gMob[i].w + 50, gMob[i].pos.y + gMob[i].h + 10 , 0xff000080);
		}
	}

	if(tState == ADVENTURE){
		/*ボスの描画*/
		if(gBoss.anipatnum <= 1)
			rect.src.x = 0;
		else{
			gBoss.anipat = (gBoss.anipat + 1) % (gBoss.anipatnum * 2);
			rect.src.x = gBoss.anipat/2 * gBoss.w;
		}
		rect.src.y = 0;
		rect.src.w = gBoss.w;
		rect.src.h = gBoss.h;
		rect.dst.x = gBoss.pos.x;
		rect.dst.y = gBoss.pos.y;
		SDL_BlitSurface(BossWindow[gBoss.no], &(rect.src), gMainWindow, &(rect.dst));

		//hpを表す四角形を描画
		if(gBoss.hp > gBoss.maxhp/2)
			boxColor(gMainWindow, gBoss.pos.x - 100 , gBoss.pos.y + gBoss.h,
					gBoss.pos.x - 100 + (gBoss.w + 200) * (double)(gBoss.hp) / gBoss.maxhp, gBoss.pos.y + gBoss.h + 10, 0x00ff0080);
		else
			boxColor(gMainWindow, gBoss.pos.x - 100 , gBoss.pos.y + gBoss.h,
					gBoss.pos.x - 100 + (gBoss.w +200) * (double)(gBoss.hp) / gBoss.maxhp, gBoss.pos.y + gBoss.h + 10, 0xff000080);
		rectangleColor(gMainWindow, gBoss.pos.x - 100, gBoss.pos.y + gBoss.h,
				gBoss.pos.x + gBoss.w + 100, gBoss.pos.y + gBoss.h + 10 , 0xff000080);
	}

	// 1Pの区別用
	if(gChara[0].state == LIVING)
		filledCircleColor(gMainWindow, gChara[0].pos.x+S_SIZE/2, gChara[0].pos.y+S_SIZE/2, 10, 0xFFFFFFF); //自分を写す
}
Пример #22
0
void TMoveStatic::disp(SDL_Surface *sf, TFont *font, int x, int y, int w, int h,
  int myfg, int mybg, int xoptions) {
    int fg = myfg, bg = mybg;
    char buff[256];
    /* Copy the string to allow to modify it without problem */
    strcpy(buff,menu->label);
    char *s = buff;
    char *old = s;
    int old_min = min_font_size;
    min_font_size = 1;
    font->set_utf(is_utf);
    int white = mymakecol(255,255,255);
    // All the translations are taken from http://home.comcast.net/~plotor/command.html
    while (*s) {
	if (*s != '_' && *s != '^' && *s != '@') {
	    s++;
	    continue;
	}
	char pre = *s;
	if (s > old) {
	    // Eventually display what's before
	    *s = 0;
	    int w,h;
	    font->dimensions(old,&w,&h);
	    font->surf_string(sf,x,y,old,fg,bg,w);
	    x += w;
	    *s = pre;
	}
	s++;
	font->dimensions("mp",&w,&h);
	int col = 0;
	char str[4];
	TFont *f0 = NULL;
	str[0] = *s;
	str[1] = 0;
	TSketcher *d = new TSketcher(sf,x,y,w,h,10,9);
	if (pre == '_') {
	    switch(*s) {
	    case 'A':
	    case 'a':
	    case 'S':
	    case '5':	col = mymakecol(255,64,64); break;
	    case 'B':
	    case 'b':	col = mymakecol(255,238,0); break;
	    case 'C':
	    case 'c':	col = mymakecol(0,255,64); break;
	    case 'D':
	    case 'd':	col = mymakecol(0,170,255); break;
	    case 'P':
	    case 'e':	col = mymakecol(255,0,170); break;
	    case 'K':
	    case 'Z':
	    case 'f':	col = mymakecol(170,0,255); break;
	    case 'g': col = mymakecol(0,255,204); break;
	    case 'i': col = mymakecol(255,160,0); break;
	    case 'G': col = mymakecol(0,170,255); break;
	    case 'H':
	    case 'h': col = mymakecol(255,0,255); break;
	    case 'j': col = mymakecol(190,190,190); break;
	    }
	    if (*s >= 'a' && *s <= 'j')
		sprintf(str,"%d",*s-'a'+1);
	    else if (*s == 'L')
		sprintf(str,">>"); // too many drawings !!!
	    else if (*s == 'M')
		sprintf(str,"<<");
	    else if (*s == 'X')
		sprintf(str,"TAP");
	    else if (*s == '^')
		sprintf(str,"AIR");
	    else if (*s == '?')
		sprintf(str,"DIR");
	    else if (*s == 'S')
		sprintf(str,"St"); // tss...
	    else if (*s == '.')
		sprintf(str,"...");

	    d->set_filled_poly(1);

	} else if (pre == '^') {
	    d->set_filled_poly(0);
	    switch (*s) {
	    case 'S':
	    case 'E': col = mymakecol(255,238,0); break;
	    case 's':
	    case 'F': col = mymakecol(255,160,0); break;
	    case 'G':	col = mymakecol(255,64,64); break;
	    case 'H': col = mymakecol(190,190,190); break;
	    case 'I': col = mymakecol(0,255,204); break;
	    case 'J':	col = mymakecol(0,170,255); break;
	    case 'T':	col = mymakecol(170,0,255); break;
	    case 'W':
	    case 'U':	col = mymakecol(255,0,170); break;
	    case 'V':	col = mymakecol(170,0,255); break;
	    }
	    if (*s >= 'E' && *s <= 'J') {
		if (has_input(KB_DEF_P1_B6)) {
		    // Street fighter games
		    char *keys[] = { "lp","mp","sp","lk","mk","sk" };
		    sprintf(str,"%s",keys[*s-'E']);
		} else
		    sprintf(str,"b%d",*s-'E'+1); // button n for other games
	    } else if (*s == 'T')
		sprintf(str,"3K");
	    else if (*s == 'U')
		sprintf(str,"3P");
	    else if (*s == 'V')
		sprintf(str,"2K");
	    else if (*s == 'W')
		sprintf(str,"2P");
	    else if (*s == 'S')
		sprintf(str,"SE"); // ?!
	    else if (*s == 'M')
		sprintf(str,"MAX");
	} else if (pre == '@') {
	    if (!strncmp(s,"W-button",8)) {
		sprintf(str,"W");
		col = mymakecol(255,238,0);
		s += 7;
	    }
	}

	// I finally keep a constant base width to have all the circles of the
	// same size...
	// font->dimensions(str,&w,&h);
	// w += 2; // some small margin
	if (col)
	    filledEllipseColor(sf, x+w/2, y+h/2, w/2,h/2, col);

	if (strlen(str) > 2) {
	    // Try to find a font size which fits in this space !
	    f0 = font;
	    int h = f0->get_font_height()/2;
	    do {
		font = new TFont_ttf(h,"VeraMono.ttf");
		if (h <= 3) break;
		int w0,h0;
		font->dimensions(str,&w0,&h0);
		if (w0 > w) {
		    h--;
		    delete font;
		    font = NULL;
		}
	    } while (!font);
	}
	// The coordinates below are supposed to be on & 10x9 matrix, except
	// that the picture I am using has clearly been resized and so it's
	// only an approximation...

	// For the arrows they are rotated and mirrored, so I do the rotation/
	// mirror instead of risking more errors with more coordinates...
	Sint16 kx[13] = {1,3,6,4,4,7,7,9,9,7,4,2,2};
	Sint16 ky[13] = {3,1,3,3,5,5,3,3,5,7,7,5,3};
	Sint16 mkx[13],mky[13];
	mirror(13,kx,mkx);
	mirror(13,ky,mky);

	Sint16 ox[10] = {1,3,3,5,5,7,7,5,3,3};
	Sint16 oy[10] = {6,4,5,5,1,1,5,7,7,8};
	Sint16 mox[10],moy[10];
	mirror(10,ox,mox);
	mirror(10,oy,moy);

	Sint16 wx[16] = {3,1,1,3,6,8,8,10,7,5,7,5,3,3,5,4};
	Sint16 wy[16] = {8,6,3,1,1,3,5,5, 7,5,5,3,3,6,7,8},mwx[16],mwy[16];
	mirror(16,wx,mwx);
	mirror(16,wy,mwy);

	if (pre == '@') {
	    // Very special case, W Button, 1 letter.
	    font->surf_string(sf,x+w/4,y,str,(col ? 0 : fg),bg,w);
	    goto end_loop;
	}

	if (*s == '1')
	    d->poly(white,
		    6,1,
		    2,6,
		    1,5,
		    1,8,
		    4,8,
		    3,7,
		    8,2,
		    -1,-1);
	else if (*s == '2')
	    d->poly(white,
		    2,1,
		    2,6,
		    1,6,
		    3,8,
		    5,6,
		    4,6,
		    4,1,
		    -1,-1);
	else if (*s == '3')
	    d->poly(white,
		    0,2,
		    5,8,
		    4,9,
		    8,9,
		    8,5,
		    7,6,
		    3,1,
		    -1,-1);
	else if (*s == '4')
	    d->poly(white,
		    3,2,
		    0,5,
		    3,7,
		    3,6,
		    9,6,
		    9,4,
		    3,4,
		    -1,-1);
	else if (*s == '6')
	    d->poly(white,
		    1,4,
		    6,4,
		    6,2,
		    9,5,
		    6,7,
		    6,6,
		    1,6,
		    -1,-1);
	else if (*s == '7')
	    d->poly(white,
		    1,1,
		    1,5,
		    2,4,
		    8,9,
		    9,7,
		    4,2,
		    5,1,
		    -1,-1);
	else if (*s == '8')
	    d->poly(white,
		    2,8,
		    2,3,
		    1,3,
		    3,1,
		    5,3,
		    4,3,
		    4,8,
		    -1,-1);
	else if (*s == '9')
	    d->poly(white,
		    8,1,
		    8,5,
		    7,4,
		    1,9,
		    0,7,
		    5,2,
		    4,1,
		    -1,-1);
	else if (*s == 'k')
	    d->polytab(13,kx,ky,white);
	else if (*s == 'm') // horizontal mirror of k (10-x)
	    d->polytab(13,mkx,ky,white);
	else if (*s == 'l') // vertical mirror of m (8-y)
	    d->polytab(13,mkx,mky,white);
	else if (*s == 'n') // horizontal mirror of l (10-x)
	    d->polytab(13,kx,mky,white);
	else if (*s == 'o')
	    d->polytab(10,ox,oy,white);
	else if (*s == 'p')
	    d->polytab(10,moy,ox,white);
	else if (*s == 'q')
	    d->polytab(10,mox,moy,white);
	else if (*s == 'r')
	    d->polytab(10,oy,mox,white);
	else if (*s == 's' && pre == '_')
	    d->polytab(10,mox,oy,white);
	else if (*s == 't')
	    d->polytab(10,oy,ox,white);
	else if (*s == 'u')
	    d->polytab(10,ox,moy,white);
	else if (*s == 'v')
	    d->polytab(10,moy,mox,white);
	else if (*s == 'w')
	    d->polytab(16,wx,wy,white);
	else if (*s == 'x')
	    d->polytab(16,mwx,mwy,white);
	else if (*s == 'y')
	    d->polytab(16,wx,mwy,white);
	else if (*s == 'z')
	    d->polytab(16,mwx,wy,white);
	else if (*s == 'Q')
	    d->poly(white,
		    1,1,
		    1,3,
		    3,3,
		    3,4,
		    1,6,
		    7,6,
		    7,7,
		    9,5,
		    7,3,
		    7,4,
		    4,4,
		    4,3,
		    6,1,
		    -1,-1);
	else if (*s == 'R') // horiz mirror of Q (10-x)
	    d->poly(white,
		    9,1,
		    9,3,
		    7,3,
		    7,4,
		    9,6,
		    3,6,
		    3,7,
		    1,5,
		    3,3,
		    3,4,
		    6,4,
		    6,3,
		    4,1,
		    -1,-1);
	else if (*s == '-' && pre == '_') { // not used for any raine game afaik
	    d->lineC(3,1,7,1,white);
	    d->lineC(3,5,5,3,white);
	    d->lineC(5,3,7,5,white);
	    d->lineC(5,3,5,7,white);
	} else if (*s == '-' && pre == '^') {
	    d->lineC(1,4,6,4,white);
	    d->lineC(6,4,4,2,white);
	    d->lineC(6,4,4,6,white);
	    d->lineC(8,2,8,6,white);
	} else if (*s == '=' && pre == '^') {
	    d->lineC(1,4,6,4,white);
	    d->lineC(1,4,3,2,white);
	    d->lineC(1,4,3,6,white);
	    d->lineC(8,2,8,6,white);
	} else if (*s == '`' && pre == '_') {
	    filledCircleColor(sf, x+w/2, y+h/2, w/10, white);
	} else if (str[1] == 0) {
	    int ws,hs;
	    font->dimensions(str,&ws,&hs);
	    font->surf_string(sf,x+(w-ws)/2,y,str,(col ? 0 : fg),bg,w);
	} else {
	    int ws,hs;
	    font->dimensions(str,&ws,&hs);
	    font->surf_string(sf,x+(w-ws)/2,y,str,(col ? 0 : fg),bg,w);
	}
	if (f0) {
	    delete font;
	    font = f0;
	}
	delete d;

end_loop:
	s++;
	old = s;
	x += w;
    }

    if (*old)
	font->surf_string(sf,x,y,old,fg,bg,w);
    min_font_size = old_min;
}
Пример #23
0
/**
 * Draws a filled circle on the surface.
 * @param x X coordinate in pixels.
 * @param y Y coordinate in pixels.
 * @param r Radius in pixels.
 * @param color Color of the circle.
 */
void Surface::drawCircle(Sint16 x, Sint16 y, Sint16 r, Uint8 color)
{
	filledCircleColor(_surface, x, y, r, Palette::getRGBA(getPalette(), color));
}
Пример #24
0
void
Surface::AAFillCircle (const Point & center, Sint16 r, const Color & c)
{
    if (filledCircleColor (surface, center.x, center.y, r, c.GetRGBAColor ()))
	throw SDLException ();
}