Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 31 Oct 2012
Offline Last Active May 08 2015 02:05 PM

Topics I've Started

C#: leaving unused reference-types

21 January 2015 - 08:43 PM

So, I wasn't really sure what to call this thread, so let me explain. I have an array of objects (reference-type) that I'm changing (both the contents and the number of things held by the array) once-per-update. I figure there are really two ways of handling this: 


1.) create a new List<object> of the type I'll be using on each cycle (or clearing at the end of each cycle, after it has served its purpose and repopulate again during the next update).


2.) create a finite-sized array (object[]) that only increases in size when the current maximum has been reached (so that the size of the array will only ever reach the greatest size it has ever been). This method requires that a variable be used to count how many items are currently stored in the array (because array.Count() will return the maximum size). Instead of clearing the contents or re-initializing the array, however, clearing this array (functionally), would simply require that the counting variable be set to zero. During the next update, when objects are being added, they simply replace whatever was previously in that spot.


The benefit of the first method is that it's empty when it's empty and only ever contains just what it needs to contain. I've heard/read (though I don't remember where), though, that dynamically-sized arrays are a little slower due to the increase in flexibility (needs to account for a broader set of circumstances). The second method doesn't use a dynamically-sized array, so, if that is true, it should hypothetically be faster. The caveat here is that it can still contain references to objects that the program is no longer using (because "clearing" the array doesn't de-reference them, but merely sets the count to zero). Because of this, the new keyword is rarely called (and is called less and less frequently as the size of the array increases).


My questions, then, are these: 1.) Are my assumptions about dynamic- vs. static-sized arrays correct? 2.) Which of these is likely to be faster, and is there a scenario that one may perform better (few objects held at a time) but less well in another scenario (many objects held at once). 3.) Are there other methods I'm not considering (I assume there are, but are they worth considering?)?

Those last few jitters

14 January 2015 - 09:59 PM

So, I'm finishing up my semi-home-brew physics engine, and there is a small amount of jittering when multiple shapes are stacked on top of each other. They go to sleep pretty quickly, but it's still there momentarily. I'm currently using debug-graphics (vector-graphics, really) so I can't really tell how visible this will be once I start using sprites instead. 


Still, I'd just like to ask those of you have made your own physics-systems: how much jittering do you tolerate? How do you get rid of that last little bit (I've gotten rid of almost all of it... it really is very minor)? 


To be clear, I'm not trying to create a be-all & end-all physics engine. This was somewhere between a pet project and a learning exercise and really just needs to perform basic game-style physics. 


More realistic jumping physics

31 December 2014 - 03:35 PM

So, I've been working on a 2D side-scrolling platform game and I'm a little unsatisfied with the way I handle jumping characters. Currently, jumping is essentially just adding a given amount to the Y-component of velocity. The problem is that this method only affects the jumping character, without applying a force in the opposite direction. I'd like jumping to behave a little more realistically, such that, a character standing on a see-saw (assume he/she is on the end lifted off of the ground), for example, would jump less far because the force applied would push the see-saw toward the ground in addition to propelling the character upward.


I'm not sure if that made any sense. I hope it did.


So, I was watching David Rosen's talk on animation and got an idea: using two circles to represent the character, stacked vertically but overlapping (similar to what is seen at about 4 minutes in that video I linked to), and applying a downward force on the bottom circle (assuming the circles are attached by a sort of spring) should, hypothetically create the scenario that I'm looking for.


So, I'm planning on prototyping this method in the next few days, but I was wondering if I'm over-thinking this. Is there a simpler way of handling this situation? Is there a better way of handling this problem? Have you done anything like this?

Interesting 2D Level Design

06 February 2014 - 12:41 AM

So, I've been watching the Wolfire game-development videos for Overgrowth, and I really like their level-design and art-style. Between their level-design and their basic gameplay mechanics, it seems to really support the feeling of adventuring, and I'm trying to incorporate something like that into my own game.


The main difference is that I'm making a 2D platforming-style game. A lot of their ideas seem to depend on the third dimension, but I really don't want to make a 3D game (this is a solo project, and while I'm a pretty decent artist, 3D modeling is something I've never really gotten into). 


A lot of 2D platforming games rely on a combination of uni-directional platforms (you can stand on them, but jump through them) and flat, ladder-like platforming areas. These aren't necessarily the direction I want my game to go.


I just finished the roughest version of my rigidbody-physics engine (there are things to add, but I'm ready to start prototyping with it while I add more), and I'm starting to think about general level-design and what I might need to account for with respect to physics. 


Without getting too bogged down in the physical details or code (which is why I'm posing in the Game Design forum), I'm wondering if anyone has ideas about how to get a similar feeling of adventure and discovery that the Wolfire development team seems to get. There are no wrong answers, I'm just curious if anyone has thought of anything that I haven't (I'm withholding my ideas for the time-being just to see what people suggest without my biasing input).



OpenGL sprite display problem

31 October 2012 - 04:55 PM

I'm having a problem with a texture I'm trying to display using OpenGL (I'm coding in C#). I've got the sprite class all set up, and it works for small things. As you can see in the picture I've attached, the background sprite is displaying its texture incorrectly. Actually, what you see in the picture is one large image used as a tile map with 4 tiles displaying different fourths of the overall image. The raw image is 1600x900 pixels, but when I replace it with the same exact image but scaled down to 900x506 pixels, it displays perfectly. Note that the distortion isn't necessarily corresponding to the 4 tiles.

I'm not asking for actual code to fix this, but some sort of idea of where to look in my code to find the problem (I've gone over so much and run quite a few tests on this).

Also, the image seems to have been distorted in the shrinking process, but it still gets the idea across, i think.

Thanks for any help.