Jump to content
  • Advertisement
Sign in to follow this  
Ekim_Gram

SdlDotNet Appreciation Thread

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm overjoyed at how well the SdlDotNet API is coming along! It was only at the start of this summer that I had even heard of such a thing and after the past few weeks of fiddeling around with it (only slightly though) I must say that if this keeps progressing as it is, I may just completely switch from C++/SDL to C#/SdlDotNet. The wrappers that were created are absolutely wonderful, especially the TextSprite class to manipulate the SDL_FreeType/TrueType libraries. I'm just looking to see who else has been messing around with this (with Rob Loach as exception because he's a developer now) and I'd like to know everybody elses opinions. Although I'm taking a break from game programming and I'm trying out some 3D Modeling as well as doing some web development for a friend of mine, I am definately going to start work on another C#/SdlDotNet project. Since I'm still learning both, I'm thinking of creating a breakout clone that is complete with a level editor and a little (going to be my first) particle engine.

Share this post


Link to post
Share on other sites
Advertisement
SDL.NET is truly a great library. The only thing I dislike about it is the limitations provided by SDL [wink]. Jendave and I have been talking about the design and a lot is planned for the next major release. Is there anything you would have made said about it? Anything that it's missing?

Post some screenshots of what you've done with it, I'd be interested in seeing. This is a screenshot of a quick and dirty tile engine I put together using SDL.NET:

Share this post


Link to post
Share on other sites
Thanks for the comments! Many thanks go to Rob for putting some much needed new blood into the project. The next release is shaping up to be a major one (maybe v 4.0 is more appropriate than a v3.2?).

Share this post


Link to post
Share on other sites
I remember there was one main issue I had with how SdlDotNet handled key presses; the problem came up while I was trying to familiarize myself with the basics.

The problem was with holding down the key. The following (crude) C++/SDL snippet allowed movement of an object with ease:


...
Uint8 *keys;
...
keys = SDL_GetKeyState(NULL);

if (!paused)
{
if (keys[SDLK_UP])
Object.AddY(2);
}




That's all good and down, you can hold the UP arrow on the keyboard and the object will keep moving up the Y-axis until it hits the boundaries or something. But in C#/SDL.NET I have to use the following:


// delegates for the keypresses
Events.KeyboardDown += new KeyboardEventHandler(Keyboard);
Events.KeyboardUp += new KeyboardEventHandler(Keyboard);

// Keyboard delegate
private void Keyboard(object sender, KeyboardEventArgs e)
{
switch (e.Key)
{
case Key.UpArrow:
Object.up = e.Down;
break;
}
}

private void UpdateGameWorld()
{
if (Object.up == true)
Object.MoveUp(3);
}




It's a little bit more to type and having a number of bools declared for each object that can be moved, that can get a little sloppy and cumbersome. Maybe I'm just going about this the wrong way, but this is what I saw in that little bomb gmae thing in the demo that was zipped along with the rest of the SDL.NET stuff.

If there's another way to go about this, please, let me know. It'd be much appreciated. [smile]

Share this post


Link to post
Share on other sites
There's a wrapper function in SDL.NET that does exactly what you posted in C [smile]:
if( SdlDotNet.Keyboard.IsKeyPressed(SdlDotNet.Key.UpArrow) )
// do stuff.
Although, it is much better to use events rather then straight function calls (faster and better memory management).

But getting the current keystate in an array would be great. I think it would be something like this:

		/// <summary>
/// Gets an array of the current status of the keyboard.
/// </summary>
/// <returns>An array filled with boolean values determining the state of each key.</returns>
public static bool[] GetKeyState()
{
int numberOfKeys;
byte[] keys;
keys = Sdl.SDL_GetKeyState(out numberOfKeys);
bool[] keystates = new bool[numberOfKeys];
for(int key = 0; key < numberOfKeys; key++)
keystates[key] = (keys[key] == 1);
return keystates;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!