Cirdan Posted March 29, 2005 Posted March 29, 2005 I'm making a ORPG and I was wondering, have this big sprite.bmp image, and each sprite is 32x32, how would I clip the image so it would only show the 32x32 image? Thankyou in advanced. Also, if I created a tile editor, how would I select each tile in a picture box? what would the math formula be to find out what tile the user clicked on? (again, 32x32) Quote
JNewt Posted March 30, 2005 Posted March 30, 2005 Well, if you're using DirectX, you need to use normal Draw function instead of the DrawFast. One of the parameters is a source rectangle that will allow you to specify a particular area of the source surface to blit from. TileX=MouseX\32 TileY=MouseY\32 The forward slashes perform integer division (returns a whole number). So a mouseclick at X=42, Y=10 will be on the tile at 1,0. Quote
EFileTahi-A Posted May 27, 2005 Posted May 27, 2005 (edited) I'm making a ORPG and I was wondering, have this big sprite.bmp image, and each sprite is 32x32, how would I clip the image so it would only show the 32x32 image? Thankyou in advanced. Also, if I created a tile editor, how would I select each tile in a picture box? what would the math formula be to find out what tile the user clicked on? (again, 32x32) Hi cirdan, It would help to know if you're using DirectDraw or Direct3D to process your game's graphics. Also, it would be wise for you to create the game's editor in first place. Doing this you are not only developing the game but you will also be forced to think of all aspects of the game. It's like pseu-doing the game. And just to finish: If your skills are not enough to build the game's editor that also means that you are less ready to build the game itself. Edited May 27, 2005 by EFileTahi-A Quote
nihuo13 Posted June 2, 2005 Posted June 2, 2005 if I using Direct3D to process the game graphics. How can i get the 32x32 sprite from the big sprite bmp ? Quote
EFileTahi-A Posted June 2, 2005 Posted June 2, 2005 (edited) if I using Direct3D to process the game graphics. How can i get the 32x32 sprite from the big sprite bmp ? You mean streching the image or simply cutting it off? Either way, this is one of some ways you can set up the sprites size (pseucoding) Sprite mySprite; Texture myTexture; //defining a texture Rectangle recTextureSize = new Rectangle(); //defining a new rectangle //Setting up the rectangles size of 32*32 pixels recTextureSize = new Rectangle(32,32); //Setting up the texture with some picture myTexture = TextureLoader.FromFile(image_name); //Draw the texture with the correspondent size mySprite.Draw(myTexture, recTextureSize (...),(...)); Am skiping here some important things like the sprite initialization, sprite.Begin, sprite.End etc. as I think you already know it. However, if not, let me know about it. Edited June 2, 2005 by EFileTahi-A Quote
nihuo13 Posted June 2, 2005 Posted June 2, 2005 Thanks :) I can't using Texture or Sprite to bitblt another texture , Can you help me? Quote
EFileTahi-A Posted June 2, 2005 Posted June 2, 2005 Thanks :) I can't using Texture or Sprite to bitblt another texture , Can you help me? Never used bitblt. However, what exactly are you trying to achieve? (be detailed) Quote
nihuo13 Posted June 3, 2005 Posted June 3, 2005 I have a Texture t1 with colorkey(TextureLoader.FromFile) and another Texture t2(no colorkey) Surface s1=t1.GetSurfaceLevel(0); Surface s2=t2.GetSurfaceLevel(0); Rectangle r=new Rectangle(0,0,s2.Description.Width,s2.Description.Height); SurfaceLoader.FromSurface(s2,r,s1,Filter.None,0); sprite.Begin(SpriteFlags.None); sprite.Draw2D(t2,Rectangle.Empty, Rectangle.Empty,new Point(0,0), Color.White) sprite.End(); //the t1 colorkey to be replaced with transparent black // how can I remove the transparent black //I don't want to separate it from another,like this: sprite.Begin(SpriteFlags.None); sprite.Draw2D(t2,Rectangle.Empty, Rectangle.Empty,new Point(0,0), Color.White) sprite.End(); sprite.Begin(SpriteFlags.AlphaBlend); sprite.Draw2D(t1,Rectangle.Empty, Rectangle.Empty,new Point(0,0), Color.White) sprite.End(); Quote
EFileTahi-A Posted June 3, 2005 Posted June 3, 2005 //the t1 colorkey to be replaced with transparent black // how can I remove the transparent black //I don't want to separate it from another,like this: So, you want to remove the transparency of t1 or you just want to change the colorkey transparency to another one? I'm kinda confused here... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.