Can you help me with SIMPLE KEYBOARD INPUT READ (no Events class) -C# SDL

Hello Ladies and Guys from SDL List
?
A?few days ago I launched a mail to the list asking help?about Threads in C# SDL, and perhaps it was difficult, or I didn t explain or specify properly the issue, so nobody replied my message at all
?
Today, about 3 days after, I feel the must to comment to you, that I have found hardly a solution for the Threads problem (nevertheless, if someone has a little example of a SDL app with Threads, sincronization, and so, I ll thank her/him) … then, the only matter it s failing now is that the keyboard input doesn t work … obviously I had to ignore the Events class for being able to introduce multithreading, so NO
?
Events.Tick += …
Events.KeyboardDown += …
Events.Fps = …
Events.Run();
?
will you find in my program …
?
then, what did I do? I distributed all the stuff in the game loop in Threads, and in one of them I put this
?
void KeyboardInput()
{
??? while (true)
??? {
???if (Keyboard.IsKeyPressed(Key.RightArrow)) {?//move right?}?
???else …
??? …
??? Thread.Sleep(20);? // that s about 50 Fps
??? }
}
?
Thread input = new Thread(new ThreadStart(KeyboardInput));

input.Start();

// and other Threads Start too

I could see the game screen almost perfect, with no slow down, but the little circumstance that the main character didn t react to the keyboard input …

Please, if there any way to read keyboard input ignoring the Events class, any trick, or what did I do wrong?
I had tried Console.ReadKey, then I tried, as I commented here, with Keyboard class from C#SDL, its IsKeyPressed(Key key) method …

Thank you

Pablo

Asesinar y comer un perro o un gato es lo mismo q hacerlo a una vaca, un pollo, un cerdo o un pez. El genocidio no discrimina. No seas complice de genocidas. No seas genocida. En la vida tarde o temprano todo vuelve. No comas cadaveres. No seas necr?fago.

Hi Pablo,

Is your code posted in more detail somewhere? Based on what you have
provided, I’m not sure how easy it is to determine what is wrong with your
program. Have you been able to confirm that the key-checking code runs as
frequently as you think? Did you confirm that, if the key is judged to be
pressed (which you can simulate), that your character moves?

Good luck,

ChristianOn Mon, Aug 20, 2012 at 2:39 AM, Pablo Marty < tigrepotrazosalvaje at yahoo.com.ar> wrote:

Hello Ladies and Guys from SDL List

A few days ago I launched a mail to the list asking help about Threads in
C# SDL, and perhaps it was difficult, or I didn t explain or specify
properly the issue, so nobody replied my message at all

Today, about 3 days after, I feel the must to comment to you, that I have
found hardly a solution for the Threads problem (nevertheless, if someone
has a little example of a SDL app with Threads, sincronization, and so, I
ll thank her/him) … then, the only matter it s failing now is that the
keyboard input doesn t work … obviously I had to ignore the Events class
for being able to introduce multithreading, so NO

Events.Tick += …
Events.KeyboardDown += …
Events.Fps = …
Events.Run();

will you find in my program …

then, what did I do? I distributed all the stuff in the game loop in
Threads, and in one of them I put this

void KeyboardInput()
{
while (true)
{
if (Keyboard.IsKeyPressed(Key.RightArrow)) { //move right }
else …

Thread.Sleep(20); // that s about 50 Fps
}
}

Thread input = new Thread(new ThreadStart(KeyboardInput));

input.Start();

// and other Threads Start too

I could see the game screen almost perfect, with no slow down, but the
little circumstance that the main character didn t react to the keyboard
input …

Please, if there any way to read keyboard input ignoring the Events class,
any trick, or what did I do wrong?
I had tried Console.ReadKey, then I tried, as I commented here, with
Keyboard class from C#SDL, its IsKeyPressed(Key key) method …

Thank you

Pablo

Asesinar y comer un perro o un gato es lo mismo q hacerlo a una vaca, un
pollo, un cerdo o un pez. El genocidio no discrimina. No seas complice de
genocidas. No seas genocida. En la vida tarde o temprano todo vuelve. No
comas cadaveres. No seas necr?fago.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi Christian and all Ladies and Guys from the list
?
During this time I continued experimenting. For your question if the character would have moved if the Keyboard method had reacted fine, the answer is Yes, I inverted the condition in the jump/swim (spacebar) key -that s compare to false or preced the method with an ! -, and the character didn t stop diving and then jumping from the water surface
?
What I found out is the Keyboard.IsKeyPressed(Key key) method, -that should return true if the Key key is pressed, false if not- returns ALWAYS false. Could these be an SDL?bug? I m using version 6.1.1 beta, the latest version, downloaded from C# SDL Main page -cs-sdl.sourceforge.net-?.. I supposse perhaps being a beta version it could have a bug. Not only did it happen trying the input method?(IsKeyPressed()) from into the game loop (well, into the loop of?one of the?Threads), but also trying it out of the game and of any Thread. Should I use an older version of SDL.NET?
?
About the code, it has to be in English for you? May I upload it to minus and send the link to the list? You will need the data files and at least one level to be able to test it. I m afraid just I understand my code (short var names, a great disorder), that only fits in my own RAM. But with just understanding the highest level functions it will be enough. Maybe with a bit more time I will traduce, comment,?and make understandable for others my program code, and upload it so?begginers could learn … I only see “Pong” and “Tic Tac Toc” tutorial examples on the Internet … no Mario nor Sonic up to date
?
Thanks, Christian, and all members
?
Pablo
?

Asesinar y comer un perro o un gato es lo mismo q hacerlo a una vaca, un pollo, un cerdo o un pez. El genocidio no discrimina. No seas complice de genocidas. No seas genocida. En la vida tarde o temprano todo vuelve. No comas cadaveres. No seas necr?fago.De: Christian Leger <chrism.leger at gmail.com>
Para: Pablo Marty <@Pablo_Marty>; SDL Development List
Enviado: lunes, 20 de agosto de 2012 7:54
Asunto: Re: [SDL] can you help me with SIMPLE KEYBOARD INPUT READ (no Events class) -C# SDL

Hi Pablo,?

Is your code posted in more detail somewhere? Based on what you have provided, I’m not sure how easy it is to determine what is wrong with your program. Have you been able to confirm that the key-checking code runs as frequently as you think? Did you confirm that, if the key is judged to be pressed (which you can simulate), that your ?character moves??

Good luck,?

Christian

On Mon, Aug 20, 2012 at 2:39 AM, Pablo Marty <@Pablo_Marty> wrote:

Hello Ladies and Guys from SDL List

?
A?few days ago I launched a mail to the list asking help?about Threads in C# SDL, and perhaps it was difficult, or I didn t explain or specify properly the issue, so nobody replied my message at all
?
Today, about 3 days after, I feel the must to comment to you, that I have found hardly a solution for the Threads problem (nevertheless, if someone has a little example of a SDL app with Threads, sincronization, and so, I ll thank her/him) … then, the only matter it s failing now is that the keyboard input doesn t work … obviously I had to ignore the Events class for being able to introduce multithreading, so NO
?
Events.Tick += …
Events.KeyboardDown += …
Events.Fps = …
Events.Run();
?
will you find in my program …
?
then, what did I do? I distributed all the stuff in the game loop in Threads, and in one of them I put this
?
void KeyboardInput()
{
??? while (true)
??? {
???if (Keyboard.IsKeyPressed(Key.RightArrow)) {?//move right?}?
???else …
??? …
??? Thread.Sleep(20);? // that s about 50 Fps
??? }
}
?
Thread input = new Thread(new ThreadStart(KeyboardInput));

input.Start();

// and other Threads Start too

I could see the game screen almost perfect, with no slow down, but the little circumstance that the main character didn t react to the keyboard input …

Please, if there any way to read keyboard input ignoring the Events class, any trick, or what did I do wrong?
I had tried Console.ReadKey, then I tried, as I commented here, with Keyboard class from C#SDL, its IsKeyPressed(Key key) method …

Thank you

Pablo

Asesinar y comer un perro o un gato es lo mismo q hacerlo a una vaca, un pollo, un cerdo o un pez. El genocidio no discrimina. No seas complice de genocidas. No seas genocida. En la vida tarde o temprano todo vuelve. No comas cadaveres. No seas necr?fago.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org