Beispiel #1
0
void crte_pacman_sprtes(SDL_Surface* image)
{
    pacman = new character(7);
    pacman->screen = screen;
    //pacman moves forward sprites
    pacman->create_sprites(3,69,40,16,16,0); //move right

    imgflp2 = rotate_surface(image); //move down
    //pacman->create_sprites(3,40,68,16,16,1);
    pacman->create_sprites2(3,40,168,16,16,1);

    imgflp= flip_surface(imgflp2, FLIP_VERTICAL  ); // move up
    pacman->create_sprites(3,40,76,16,16,1);

    

    flplft = flip_surface(image,FLIP_HORIZONTAL); //move left
    pacman->create_sprites2(3,175,40,16,16,0);

    //pacman dies sprites
    pacman->create_sprites(3,14,55,16,16,0); 

    pacman->create_sprites(3,14,55,16,14,0); 
    pacman->create_sprites(2,64,57,17,14,0); 
    pacman->create_sprites(5,122,54,16,14,0); 
}
Beispiel #2
0
struct surface_t *leave_main_lock_and_rotate_surface(struct surface_t *in_surface, 
	int scale_width, int scale_height, double theta)
{
	struct surface_t *duplicate, *rotated;
	
	duplicate = duplicate_surface(in_surface);
	
	leave_main_lock();
	
	rotated = rotate_surface(duplicate, scale_width, scale_height, theta);
	free_surface(duplicate);
	return rotated;
}
void Shape_Blitter::SDL_Draw(SDL_Surface *dst_surface, const Image_Rect& dst)
{
    if (!dst_surface)
		return;
	
    // load shape into surface if necessary
    if (!m_surface)
    {
        byte *pixelsOut = NULL;
        SDL_Surface *tmp = get_shape_surface(m_frame, m_coll, &pixelsOut, (m_type == Shape_Texture_Interface) ? -1.0 : 1.0);
        if (!tmp)
            return;
        
        if (pixelsOut)
        {
			m_surface = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_BGRA8888, 0);
            SDL_FreeSurface(tmp);
            free(pixelsOut);
            pixelsOut = NULL;
        }
        else if (m_coll == 0 && m_frame >= 12 && m_frame <= 29)
        {
            // fix transparency on motion sensor blips
            SDL_SetColorKey(tmp, SDL_TRUE, 0);
			m_surface = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_BGRA8888, 0);
            SDL_FreeSurface(tmp);
        }
        else
            m_surface = tmp;
    }
    if (!m_surface)
        return;
    
    if (!m_scaled_surface ||
        m_scaled_surface->w != m_scaled_src.w ||
        m_scaled_surface->h != m_scaled_src.h)
    {
        if (m_scaled_surface && (m_scaled_surface != m_surface))
            SDL_FreeSurface(m_scaled_surface);
        
        if (m_scaled_src.w != m_src.w || m_scaled_src.h != m_src.h)
            m_scaled_surface = rescale_surface(m_surface, m_scaled_src.w, m_scaled_src.h);
        else
            m_scaled_surface = m_surface;
        
        if (m_type == Shape_Texture_Wall)
        {
            // rotate wall textures
            SDL_Surface *tmp = rotate_surface(m_scaled_surface, m_scaled_surface->w, m_scaled_surface->h);
            if (m_scaled_surface != m_surface)
                SDL_FreeSurface(m_scaled_surface);
            m_scaled_surface = tmp;
        }
        else if (m_type == Shape_Texture_Landscape)
        {
            // flip landscapes vertically
            SDL_Surface *tmp = flip_surface(m_scaled_surface, m_scaled_surface->w, m_scaled_surface->h);
            if (m_scaled_surface != m_surface)
                SDL_FreeSurface(m_scaled_surface);
            m_scaled_surface = tmp;
        }
    }
    
    if (!m_scaled_surface)
        return;
    
    SDL_Rect r = { crop_rect.x, crop_rect.y, crop_rect.w, crop_rect.h };
    SDL_Rect sdst = { dst.x, dst.y, dst.w, dst.h };
	SDL_BlitSurface(m_scaled_surface, &r, dst_surface, &sdst);
}
void test_centroid(Polygon* surface, Polygon* polygons, double* population, double* test, int lt_)
{
	double surf_a=0;
	double c[3];
	double b[4];
	double l;
	double a1,a2;
	int n;
	int polylen = polygons->len;
	for (int test_n =0; test_n<lt_; test_n++)
	{
		if (test[test_n]<0)
		{
			surface->len=0;
			
			for (int i=0; i<polylen; i++)
			{
				n = int(population [test_n*polylen*3+i*3]);
				a1 = population [test_n*polylen*3+i*3+1]*2*PI;
				a2 = population [test_n*polylen*3+i*3+2]*2*PI;
				if (surface->len==0)
				{
			
					surface_append_polygon(surface, polygons, n);
					rotate_polygon(surface,0,a1+a2);
					surf_a = a2;
					surface_join_polygon(surface);
				}
				else
				{
					move_surface(surface, -surface->cx, -surface->cy);
	//				echo_polygon(surface, 0, "After move");				
					surface->cx = 0;
					surface->cy = 0;

	//				echo_polygon(surface, l);

					l = surface->len;
					surface_append_polygon(surface, polygons, n);
					polygon_centroid(c, surface, l);
					move_polygon(surface, l, -c[0], -c[1]);
			
					rotate_polygon(surface, l, a1+a2);
					rotate_surface(surface, a2 - surf_a);
					surf_a = a2;

					drop_polygon_down(surface, l);
					surface_join_polygon(surface);
	//				echo_polygon(surface, 0,"Surface");
	//				echo_polygon(surface, l,"Poly");	

				}	
			}		
	
			rotate_surface(surface, -surf_a);
			surface_bounds(b,surface);
//			printf("Test %d: %10.10f\n",test_n,(b[2]-b[0])*(b[3]-b[1]));
//			printf("Bonds: %f %f %f %f\n", b[0], b[1], b[2], b[3]);
		
			test[test_n]	= (b[2]-b[0])*(b[3]-b[1]);
		}
	}	
}
Beispiel #5
0
void Shape_Blitter::SDL_Draw(SDL_Surface *dst_surface, SDL_Rect& dst)
{
  if (!dst_surface) {
    return;
  }

  // load shape into surface if necessary
  if (!m_surface) {
    byte *pixelsOut = NULL;
    SDL_Surface *tmp =
      get_shape_surface(m_desc, NONE, &pixelsOut,
                        (m_type == Shape_Texture_Interface) ? -1.0 : 1.0);
    if (!tmp) {
      return;
    }

    if (pixelsOut) {
      m_surface = SDL_DisplayFormatAlpha(tmp);
      SDL_FreeSurface(tmp);
      free(pixelsOut);
      pixelsOut = NULL;
    }
    else{
      m_surface = tmp;
    }
  }
  if (!m_surface) {
    return;
  }

  if (!m_scaled_surface ||
      m_scaled_surface->w != m_scaled_src.w ||
      m_scaled_surface->h != m_scaled_src.h) {
    if (m_scaled_surface && (m_scaled_surface != m_surface)) {
      SDL_FreeSurface(m_scaled_surface);
    }

    if (m_scaled_src.w != m_src.w || m_scaled_src.h != m_src.h) {
      m_scaled_surface = rescale_surface(m_surface, m_scaled_src.w,
                                         m_scaled_src.h);
    }
    else{
      m_scaled_surface = m_surface;
    }

    if (m_type == Shape_Texture_Wall) {
      // rotate wall textures
      SDL_Surface *tmp = rotate_surface(m_scaled_surface, m_scaled_surface->w,
                                        m_scaled_surface->h);
      if (m_scaled_surface != m_surface) {
        SDL_FreeSurface(m_scaled_surface);
      }
      m_scaled_surface = tmp;
    }
    else if (m_type == Shape_Texture_Landscape) {
      // flip landscapes vertically
      SDL_Surface *tmp = flip_surface(m_scaled_surface, m_scaled_surface->w,
                                      m_scaled_surface->h);
      if (m_scaled_surface != m_surface) {
        SDL_FreeSurface(m_scaled_surface);
      }
      m_scaled_surface = tmp;
    }
  }

  if (!m_scaled_surface) {
    return;
  }

  SDL_Rect r = crop_rect;
  SDL_BlitSurface(m_scaled_surface, &r, dst_surface, &dst);
}