Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


renman29

Member Since 19 Jul 2006
Offline Last Active Nov 23 2014 02:48 PM

#5194166 Managing spritesheets

Posted by renman29 on 22 November 2014 - 02:34 PM

Difference being on how the spritesheet is put together - like if I made the animation cycle so that each frame is spaced equally apart so the animation module can simply change the source rectangle each frame by some even amount -- then I will use a bit more space on the sheet than if all the source rects were packed tightly together(in which case I couldn't use the same technique and would therefore need precise locations for all the animation frames). I guess this wouldn't be an issue if all your animation frames were close to the same size, however if your character is doing really crazy things in each frame it may be easier to use a sprite sheet packer to assemble the sheet and rectangle definitions for you.

  For more compression (data compression) you could use a DXT type compression in video memory. I know in XNA it is just a matter of changing the properties of the texture in the content pipeline but I'm not sure how it is done otherwise. DXT is lossy so is good for background stuff but I don't know if I recommend it for characters that you will see in front of you all the time if a crisp vibrant image is important to you.

Good luck on your project :)




#5193715 Managing spritesheets

Posted by renman29 on 19 November 2014 - 09:55 PM

I'm agreeing with unbird - also I'd say it depends on how much animation data you end up with. Originally for animated characters, I used even rows for each animation (walk row, run row, jump row, etc... ) but I added tons and tons of animations and started hogging the video ram with numerous 4086x4086 sheets. I found a compressed atlas worked better. The only tricky part then is getting the program to recognize which rectangle sections belong to which animation. If you put each animation frame from your sheet on a separate layer in your image editor and use an export layers to files option (however you do it in your editor) - ie: layers: walk1, walk2, walk3, etc... then use a utility like: Sprite Sheet Packer or something similar which will export a space-saving sprite-sheet as well as a .txt file containing all the rectangles. You can parse the .txt file and use the corresponding names and numbers to automatically match up the animation frames to their place on the sheet and save a lot of video ram (and manual work).  

That being said, however, either approach is good for your purposes I think. Only would be necessary to do it that way if video-ram becomes a concern.




#5193563 Orthographic Projection, width/height

Posted by renman29 on 19 November 2014 - 12:07 AM

Maybe change this:

projection = Matrix.CreateOrthographic(Width,Height,near,far);

to something like this:

projection = Matrix.CreateOrthographicOffCenter(left,right,bottom,top,near,far);

Where left is 0, right is width, bottom is height and top is 0 and near could be say -2000 and far +2000 if you really wanted..

Also good to translate the projection -0.5 up and -0.5 left to get good pixel alignment (could just leave view as identity and use a world matrix to move scene)




#5190524 2D game Terraria-like lighting

Posted by renman29 on 01 November 2014 - 02:14 AM

I think you'd do like with light intensity but the same technique applied to all 3 channels of the color: red_level, green_level, blue_level.. One other thing you can try to speed up the algorithm, is to not finish all the lighting calculations every frame. In other words, you do enough to keep up to a desired accuracy rate in each loop (keeping track of where you left off and perhaps even focusing first more on tiles where changes occurred) and then have the alg continue where you left off in the calculations in the next loop. I don't know if I'm right but I suspect this self-correcting style of lighting might not have any distracting artifacts. It's an idea anyway.




#5190348 Faster 2D Lens Flare Occlusion Fade

Posted by renman29 on 31 October 2014 - 07:05 AM

Aha! I got Method 5 working (just using spriteBatch) and the performance is excellent and the fade-out looks great.

I noticed one thing weird, the foreground needed to use an alpha test (otherwise transparent pixels would have depth and be considered occluding) - but the odd thing was that when I applied the alpha test, the depth values had to go from ( 0f  to  -1.0f ) instead of ( 0f  to +1.0f )... but all other rendering still must be 0-1... what the.....?

biggrin.png  

Oh well, at least it works! Here's how it looks:

obstruct2.jpg




#4997297 2d collisions

Posted by renman29 on 04 November 2012 - 03:21 PM

Not sure which types of collision detection would be most useful to you. If you're doing 2d tile platformer these might help:
Types of tile based collision methods:
http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/
Pixel perfect collision detection:
http://gamedev.stackexchange.com/questions/15191/is-there-a-good-way-to-get-pixel-perfect-collision-detection-in-xna
Here you can find rectangle-based collision detection source code - also links to pixel-collision and others:
http://xbox.create.msdn.com/en-US/education/catalog/tutorial/collision_2d_rectangle

I'm thinking rectangle-rectangle collision detection works for most things (but may want to try bounding-circle [radius-overlap] for some things)


#3865299 D3DXMatrixMultiply implimentation?

Posted by renman29 on 02 January 2007 - 09:15 PM

Most impressive. :)


PARTNERS