Beispiel #1
0
Game::Game() {
    kill = false;
    srand(time(NULL));
    if (!texture.loadFromFile("solitaire_sprite_sheet.png")) {
        kill = true;
        freopen("error.txt", "w", stdout);
        std::cout << "Fatal error: Could not load sprite sheet" << "\n";
        return;
    }
    texture.setSmooth(true);
    backside.set_texture(texture);
    three_card_rule = true;
    init_rect();
    init_text();
    reset_game();
}
/*
** Print on the map the grass [prepare the surface ans blit]
*/
void		print_init_map(t_sdl *sdl)
{
  SDL_Rect	screen_pos;
  int		x;
  int		y;

  x = sdl->scrollX;
  init_rect(&screen_pos);
  screen_pos.h = SCREEN_H;
  screen_pos.w = SCREEN_W;
  while (x < map_size.x && x - sdl->scrollX < SCREEN_H / 64)
    {
      y = sdl->scrollY;
      while (y < map_size.y && y - sdl->scrollY < (SCREEN_W - 192) / 64)
	{
	  update_map(sdl, &screen_pos, x, y);
	  y++;
	}
      x++;
    }
}
Beispiel #3
0
void Renderer::init()
{
	init_shaders();

	ortho = new Matrix4f();
	mx_translate = new Matrix4f();
	mx_scale = new Matrix4f();
	mx_rotate = new Matrix4f();
    
    init_rect();
    init_grid();
	InitPassGrid();
    init_line();
	init_tower();
	init_circle();
	init_ring();
	InitTriangle();
	InitPolygon();
	initHexGrid();
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glCullFace(GL_BACK);
}
void		put_items_map(t_sdl *sdl)
{
  SDL_Rect	screen_pos;
  int		x;
  int		y;

  x = sdl->scrollX;
  init_rect(&screen_pos);
  screen_pos.h = SCREEN_H;
  screen_pos.w = SCREEN_W;
  while (x < map_size.x && x - sdl->scrollX < SCREEN_H / 64)
    {
      y = sdl->scrollY;
      while (y < map_size.y && y - sdl->scrollY < (SCREEN_W - 192) / 64)
	{
	  up_date_position(&screen_pos, x - sdl->scrollX, y - sdl->scrollY);
	  put_items(x, y, sdl, &screen_pos);
	  put_item_user(x, y, sdl, &screen_pos);
	  put_eggs(x, y, sdl, &screen_pos);
	  y++;
	}
      x++;
    }
}