Announcement

Collapse
No announcement yet.

Sprite Editor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • resetting stuff to 0 seemed to work. I tried a few turns and it worked and made another, boat, sprite. but then I loaded a new sprite, it ran etc and I did it just like the other ones, then at the end of the turn the game crashed. Then reloading the game I didnt add any of the other ones and now the settler sprite crashes again. not sure whats going on.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • As far as I hav been able to figure it out the fields are as follows:

      Sprite Num Frames = the number of actual images available for the selected animation.

      Sprite First Frame = this is the number of the first image imported when using makespr.exe (the Apolyton sprite generator) What it does in the game, or the sprite-file I don't know. Just keep it at 0 or 1 to be safe

      Anim Type = the way the animation is played in ctp. sequential plays through from the first frame to the last defined frame, looped starts over at the first frame when it's gone through all of the frames, back-n-forth reverses direction of playback when it reaches the last frame, and playes back to the first before reversing direction again.

      Anim Num Frames = the number of frames in the animation, these frames are realy just a list of numbers, refering to Sprite Frames.

      Anim Playback Time = the time to play the animation sequence, not used in Civ:CTP, not sure about CTP2

      Anim Delay = Amount of time to display the last frame before repeating, don't know how it is messured.

      If you have not done this yet, it is a good idea to read the first part of documentation that came with makespr.exe (I have attached it to this post)

      I have not had the time to look into why SpriteEdit allows import of wrong-sized images. I won't be home much over the next week or so, so I can't promise anything.
      Attached Files
      Visit my CTP-page and get TileEdit and a few other CTP related programs.
      Download and test SpriteEdit development build.

      Comment


      • Martin spritedit does not save the image size. on build 12. this means that the sprite may be displayed distorted or as e said not appear.
        "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
        The BIG MC making ctp2 a much unsafer place.
        Visit the big mc’s website

        Comment


        • I just checked, the size is saved to the sprite-file, but somehow I have managed to eliminate the check for image-size on import. (Probably happend when I rewrote the import routeens) I'll add a check in the next build, but when that will be I don't know.

          E, if you have the time, I would apreciate it if you could try using the same size for all images, and see if this solves the problem. This will help eleminate other causes for the problem.
          Visit my CTP-page and get TileEdit and a few other CTP related programs.
          Download and test SpriteEdit development build.

          Comment


          • I will say something I think e image is innocent of the bug I replaced the north walk with a image I knew could not case a problem (a giant blue box) this also caused the game to crash . but I can’t shake the thought I had a similar problem with the active$ion sprite maker.
            "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
            The BIG MC making ctp2 a much unsafer place.
            Visit the big mc’s website

            Comment


            • Yeah,
              I eventually went in and redid the sprites to keep them all the same size. I thought it worked, one game I did a few turns and everything was going great (for 3 sprites I made using sprite edit no less) then a crash happened and since then I'm back to square one, where a settler moving crashes it again. I'm loss at to what else to do now. I too shall take a break and maybe think of something I did wrong.

              thanks guys.
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • Martin,

                I glanced through the source code would any of this help:

                Code:
                #include "c3.h"
                
                #include "pixelutils.h"
                #include "spriteutils.h"
                
                extern sint32 g_is565Format;
                
                void spriteutils_EncodeShadowRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	uint8			alpha;
                	sint32			runLen = 0;
                	Pixel16			footer=0;
                	Pixel16			shadowPixel;
                
                	if (g_is565Format) shadowPixel = k_SHADOW_PIXEL_565;
                	else shadowPixel = k_SHADOW_PIXEL_555;
                
                	RGB32Info(**inBuf, &pix16, &alpha);
                	while (pix16 == shadowPixel && (*pos < width)) {
                		
                		(*inBuf)++;
                
                		
                		(*pos)++;
                
                		
                		runLen++;
                
                		RGB32Info(**inBuf, &pix16, &alpha);
                	}
                
                	
                	footer = (Pixel16)(k_SHADOW_RUN_ID << 8 | runLen);
                
                	
                	if (*pos >= width) footer |= k_EOLN_ID << 8;
                	
                	
                	**outBufPtr = footer;
                	(*outBufPtr)++;
                }
                
                void spriteutils_EncodeCopyRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	uint8			alpha;
                	sint32			runLen = 0;
                	Pixel16			footer=0;
                	Pixel16			*headerPtr;
                	Pixel16			shadowPixel;
                
                	if (g_is565Format) {
                		shadowPixel = k_SHADOW_PIXEL_565;
                	} else { 
                		shadowPixel = k_SHADOW_PIXEL_555;
                	}
                
                	headerPtr = *outBufPtr;
                	(*outBufPtr)++;
                
                	RGB32Info(**inBuf, &pix16, &alpha);
                
                	while (pix16 != shadowPixel && alpha == k_ALL_ALPHA && (*pos < width)) {
                
                		
                		if (pix16 == 0x0000) pix16 = 0x0001;
                
                		
                		**outBufPtr = pix16;
                
                		
                		(*outBufPtr)++;
                		
                		
                		(*inBuf)++;
                
                		
                		(*pos)++;
                
                		
                		runLen++;
                
                		RGB32Info(**inBuf, &pix16, &alpha);
                	}
                	
                	
                	footer = (Pixel16) (k_COPY_RUN_ID << 8 | runLen);
                
                	
                	if (*pos >= width) footer |= k_EOLN_ID << 8;
                
                	*headerPtr = footer;
                }
                
                char spriteutils_EncodeChromakeyRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	uint8			alpha;
                	sint32			runLen = 0;
                	Pixel16			footer=0;
                
                	RGB32Info(**inBuf, &pix16, &alpha);
                	while (pix16 == k_CHROMAKEY_PIXEL && alpha == k_NO_ALPHA && (*pos < width)) {
                		
                		(*inBuf)++;
                
                		
                		(*pos)++;
                
                		
                		runLen++;
                
                		RGB32Info(**inBuf, &pix16, &alpha);
                	}
                
                	
                	if (runLen < width) {
                		
                		footer = (Pixel16)(k_CHROMAKEY_RUN_ID << 8 | runLen);
                
                		
                		if (*pos >= width) footer |= k_EOLN_ID << 8;
                		
                		
                		**outBufPtr = footer;
                		(*outBufPtr)++;
                	} else {
                		
                		return TRUE;
                	}
                
                	return FALSE;
                }
                
                char spriteutils_EncodeChromakeyWshadowRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	uint8			alpha;
                	sint32			runLen = 0;
                	Pixel16			footer=0;
                
                	RGB32Info(**inBuf, &pix16, &alpha);
                	while ( ((pix16 == k_CHROMAKEY_PIXEL && alpha == k_NO_ALPHA) ||  (pix16 == k_SHADOWBACKGD_PIXEL))  && (*pos < width) ) {
                		
                		(*inBuf)++;
                
                		
                		(*pos)++;
                
                		
                		runLen++;
                
                		RGB32Info(**inBuf, &pix16, &alpha);
                	}
                
                	
                	if (runLen < width) {
                		
                		footer = (Pixel16)(k_CHROMAKEY_RUN_ID << 8 | runLen);
                
                		
                		if (*pos >= width) footer |= k_EOLN_ID << 8;
                		
                		
                		**outBufPtr = footer;
                		(*outBufPtr)++;
                	} else {
                		
                		return TRUE;
                	}
                
                	return FALSE;
                }
                
                void spriteutils_EncodeFeatheredRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	Pixel16			footer=0;
                	uint8			alpha;
                
                	RGB32Info(**inBuf, &pix16, &alpha);
                
                	
                	if (pix16 == 0x0000) pix16 = 0x0001;
                
                	(*inBuf)++;
                	(*pos)++;
                
                	footer = (k_FEATHERED_RUN_ID << 8) | alpha;
                
                	
                	if (*pos >= width)
                		footer |= k_EOLN_ID << 8;
                
                	
                	**outBufPtr = footer;
                	(*outBufPtr)++;
                
                	
                	**outBufPtr = pix16;
                	(*outBufPtr)++;
                
                }
                
                
                char spriteutils_EncodeScanline(Pixel32 *scanline, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	Pixel32			pix32;
                	Pixel32			*scanPtr = scanline;
                	uint8			alpha;
                	sint32			pos;
                	Pixel16			*startPtr;
                	BOOL			empty;
                	Pixel16			shadowPixel;
                
                	if (g_is565Format) {
                		shadowPixel = k_SHADOW_PIXEL_565;
                	} else { 
                		shadowPixel = k_SHADOW_PIXEL_555;
                	}
                
                
                	pos = 0;
                
                	
                	startPtr = *outBufPtr;
                
                	
                
                	while (scanPtr < (scanline + width)) 
                	{
                		pix32 = *scanPtr;
                		
                		empty = FALSE;
                
                		RGB32Info(pix32, &pix16, &alpha);
                		
                		
                		
                		
                		
                		
                
                		if ((pix16 == k_CHROMAKEY_PIXEL)&&(alpha == k_NO_ALPHA)) 
                		
                		{
                
                			
                			empty = spriteutils_EncodeChromakeyRun(&scanPtr, &pos, width, outBufPtr);
                		}
                		else
                		if (pix16 == shadowPixel) 
                		{
                			
                			spriteutils_EncodeShadowRun(&scanPtr, &pos, width, outBufPtr);
                		}
                		else
                		if ((alpha!=k_NO_ALPHA) && (alpha!=k_ALL_ALPHA)) 
                		{
                			
                			spriteutils_EncodeFeatheredRun(&scanPtr, &pos, width, outBufPtr);			
                		}
                		else {
                			
                			if (alpha == k_ALL_ALPHA)
                				spriteutils_EncodeCopyRun(&scanPtr, &pos, width, outBufPtr);
                			else 
                			{
                
                			   	printf("\nError in bitmap data.  Pixel with no associated alpha.\n");
                			   
                			   	exit(-1);
                			}
                		}
                	}
                
                	return empty;
                }
                
                
                char spriteutils_EncodeScanlineWshadow(Pixel32 *scanline, sint32 width, Pixel16 **outBufPtr)
                {
                	Pixel16			pix16;
                	Pixel32			pix32;
                	Pixel32			*scanPtr = scanline;
                	uint8			alpha;
                	sint32			pos;
                	Pixel16			*startPtr;
                	BOOL			empty;
                	Pixel16			shadowPixel;
                
                	if (g_is565Format) {
                		shadowPixel = k_SHADOW_PIXEL_565;
                	} else { 
                		shadowPixel = k_SHADOW_PIXEL_555;
                	}
                
                
                	pos = 0;
                
                	
                	startPtr = *outBufPtr;
                
                	
                
                	while (scanPtr < (scanline + width)) {
                		pix32 = *scanPtr;
                		
                		empty = FALSE;
                
                		RGB32Info(pix32, &pix16, &alpha);
                
                		if ( (pix16 == k_CHROMAKEY_PIXEL  && alpha == k_NO_ALPHA) ||  (pix16 == k_SHADOWBACKGD_PIXEL) ) 
                		{
                			
                			empty = spriteutils_EncodeChromakeyWshadowRun(&scanPtr, &pos, width, outBufPtr);
                		}
                		else
                		if (pix16 == shadowPixel) {
                			
                			spriteutils_EncodeShadowRun(&scanPtr, &pos, width, outBufPtr);
                		}
                		else
                		if (alpha != k_NO_ALPHA && alpha != k_ALL_ALPHA) {
                			
                			spriteutils_EncodeFeatheredRun(&scanPtr, &pos, width, outBufPtr);			
                		}
                		else {
                			
                			if (alpha == k_ALL_ALPHA)
                				spriteutils_EncodeCopyRun(&scanPtr, &pos, width, outBufPtr);
                			else {
                				printf("\nError in bitmap data.  Pixel with no associated alpha.\n");
                				exit(-1);
                			}
                		}
                	}
                
                	return empty;
                }
                
                void spriteutils_MergeShadowMap(Pixel32 *buf, Pixel32 *shadowBuf, uint16 width, uint16 height)
                {
                	Pixel32		*pixPtr, pix;
                	Pixel32		*shadowPixPtr, shadowPix;
                
                	
                	
                	BOOL		whiteBackground = FALSE;
                	if ((*shadowBuf & 0x00FFFFFF) == 0x00FFFFFF) {
                		whiteBackground = TRUE;
                	} else {
                		if ((*shadowBuf & 0x00FFFFFF) != 0x00000000) {
                			printf("\nShadow file is in invalid format.\n");
                			exit(-1);
                		}
                	}
                
                	for (sint32 j=0; j> 8) {
                					case k_CHROMAKEY_RUN_ID	:
                							destPixel += (tag & 0x00FF);
                						break;
                					case k_COPY_RUN_ID			: {
                							short len = (tag & 0x00FF);
                
                							for (short i=0; i>4);
                								destPixel++;
                								rowData--;
                							} else {
                								*destPixel++ = *rowData--;
                							}
                							tag = *rowData--;
                						break;
                					default:
                						Assert(FALSE);
                				}
                				tag = *rowData--;
                			}
                		}
                	}
                }
                
                Pixel32 spriteutils_AveragePixel32(Pixel32 pixel1, Pixel32 pixel2, Pixel32 pixel3, Pixel32 pixel4)
                {
                	Pixel16		r1, r2, r3, r4;
                	Pixel16		g1, g2, g3, g4;
                	Pixel16		b1, b2, b3, b4;
                	Pixel16		a1, a2, a3, a4;
                	Pixel32		r, g, b, a;
                	Pixel32		result;
                
                	RGB32Components(pixel1, &r1, &g1, &b1, &a1);
                	RGB32Components(pixel2, &r2, &g2, &b2, &a2);
                	RGB32Components(pixel3, &r3, &g3, &b3, &a3);
                	RGB32Components(pixel4, &r4, &g4, &b4, &a4);
                
                	r = (Pixel32)ceil((r1 + r2 + r3 + r4) / 4.0);
                	g = (Pixel32)ceil((g1 + g2 + g3 + g4) / 4.0);
                	b = (Pixel32)ceil((b1 + b2 + b3 + b4) / 4.0);
                	a = (Pixel32)ceil((a1 + a2 + a3 + a4) / 4.0);
                
                	result =  ( r | (g << 8) | (b << 16) | (a << 24));
                	
                	return result;
                }
                
                void spriteutils_CreateQuarterSize(Pixel32 *srcBuf, sint32 srcWidth, sint32 srcHeight, Pixel32 **destBuf, BOOL aa)
                {
                	sint32		destWidth = srcWidth / 2;
                	sint32		destHeight = srcHeight / 2;
                	sint32		i,j;
                	Pixel32		pixel, pixel1, pixel2, pixel3, pixel4;
                	Pixel32		*outBuf;
                
                	outBuf = (Pixel32 *)malloc(destWidth * destHeight * sizeof(Pixel32) );
                	
                	for (i=0; i> 8) {
                					case k_CHROMAKEY_RUN_ID	:
                						break;
                					case k_COPY_RUN_ID		: {
                							short len = (tag & 0x00FF);
                							for (short i=0; i> 8) {
                					case k_CHROMAKEY_RUN_ID	:
                						break;
                					case k_COPY_RUN_ID		: {
                							short len = (tag & 0x00FF);
                							for (short i=0; i 0) return 5;
                		else return 6;
                	} else {
                		if (x > 0) {
                			if (y < 0) return 1;
                			else if (y > 0) return 3;
                			else return 2;
                		} else {
                			
                			if (y < 0) return 0;
                			else if (y > 0) return 4;
                			else return 4;
                		}
                	}
                }
                I can dig more if there smething specific you need....
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • And this in Sprite.cpp
                  Code:
                  void Sprite::ImportTGA(uint16 index, char **imageFiles,Pixel32 **imageData)
                  {
                  	int		bpp; 
                  	int     w,h;
                  
                  	
                  	if (!Get_TGA_Dimension(imageFiles[index], w, h, bpp)) 
                  	{
                  		printf("Bad TGA Sprite File(%s)\n",imageFiles[index]);
                  		*imageData = NULL;
                  		fcloseall();
                  		exit(0);
                  		return;
                  	}
                  
                  	if (bpp!=4)
                  	{
                  		printf("TGA Sprite File not 32-bits\n",imageFiles[index]);
                  		*imageData=NULL;
                  		fcloseall();
                  		exit(0);
                  		return;
                  	}
                  	
                  	*imageData = new Pixel32[w*h];
                  
                  	Load_TGA_File_Simple(imageFiles[index],(unsigned char *)*imageData,w*sizeof(Pixel32),w,h);
                  
                  	m_width  = (uint16)w;
                  	m_height = (uint16)h;
                  
                  	
                  	TGA2RGB32((Pixel32 *)*imageData,w*h);
                  }
                  
                  
                  
                  
                  
                  void Sprite::Import(uint16 nframes, char **imageFiles, char **shadowFiles)
                  {
                  	m_numFrames = nframes;
                  
                  	
                  	if (m_frames != NULL) 
                  	{
                  		free(m_frames);
                  		m_frames = NULL;
                  	}
                  
                  	
                  	m_frames = new Pixel16*[m_numFrames];
                  
                  	
                  	if (m_frames == NULL) 
                  		return;
                  
                  	
                  	if (m_miniframes != NULL) 
                  	{
                  		free(m_miniframes);
                  		m_miniframes = NULL;
                  	}
                  
                  	
                  	m_miniframes = new Pixel16*[m_numFrames];
                  
                  	
                  	if (m_miniframes == NULL) 
                  		return;
                  
                  	
                  	Pixel32 *image,*miniimage;
                  	Pixel32 *shadow,*minishadow;
                  
                  	
                  	for (uint16 i=0; i> 1, m_height >> 1);
                  		}
                  
                  		
                  		if (image) 		delete []image;
                  		if (shadow)		delete []shadow;
                  		if (miniimage) 	delete []miniimage;
                  		if (minishadow)	delete []minishadow;
                  
                  		printf(".");
                  	}
                  }
                  Formerly known as "E" on Apolyton

                  See me at Civfanatics.com

                  Comment


                  • Where can I find a good sprite packer/extractor that works with any sprites? All of them I have found only work for a certain game/program. I am trying to make graphics for my buddy's game, and I cant find anything that will work.

                    Comment


                    • That’s probably because there are different types of sprite file for example

                      In ctp the sprite files hold graphical data however in another activsion game called star trek armada sprites contain text which can be edited in note pad so to answer you question I don't think there is one or will be one.


                      however if you buddies game is ctp there is the sprite edit on martin the dane signature will work.
                      "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
                      The BIG MC making ctp2 a much unsafer place.
                      Visit the big mc’s website

                      Comment


                      • Martin, BigMC

                        I revisited my crashing setler sprite. here are somethings I notice.

                        At start up the fidget is great, then I move and it crashes BUT if I add an archer (another sprite I created) and move it, then I can move the settler BUT then it crashes I think its when the AI moves its settler.

                        If I make everything visible and do the same add an archer it seems to work fine for awhile

                        THE REAL WEIRD test was that I decided to swap my galley sprite I made in place of settler and it worked on start up. So I thought maybe it was an error with the settler sprite I copied over. So I copied settler graphics over the galley AND it still crashes!!!!!!!!!

                        I think the game recognizes something unique with a settler sprite which might be the problem or maybe it is my graphics.... any suggestions???????????
                        Formerly known as "E" on Apolyton

                        See me at Civfanatics.com

                        Comment


                        • I THINK I Achieved SUCCESS

                          I finally went and redid my death.tgas which were at 104x77 instead of 96x72. Before my graphics were mixed and Martin when you wanted me to mae them one size I changed them all to 104x77 and it still crashed. I think your problem is in the handling of different sizes because all ofmy 96x72 sprites work perfect.
                          Formerly known as "E" on Apolyton

                          See me at Civfanatics.com

                          Comment


                          • Martin,
                            Sprie editingis going well, but I noticed that if I add fraes to a sprite the animations won't show because it remembers the original sprite frame delay. Also changing the center points do nothing also.
                            Formerly known as "E" on Apolyton

                            See me at Civfanatics.com

                            Comment


                            • Hi E,

                              I must admit I have not been working on SpriteEdit lately. I am aware of the problem with handling frame size, this is one of the reasons SpriteEdit canot create sprites from scratch. I'll have to look into the frames not beeing played.
                              Visit my CTP-page and get TileEdit and a few other CTP related programs.
                              Download and test SpriteEdit development build.

                              Comment


                              • Martin,
                                Thanks. I'd say if anything adding the playing of all frames would be ore important than the resizing (mainly since a lot of sprites can be used as templates and I can post any bigger ones if people need them).
                                Formerly known as "E" on Apolyton

                                See me at Civfanatics.com

                                Comment

                                Working...
                                X