[NetBehaviour] useless talk gets one knowehre

james morris james at jwm-art.net
Sun Mar 8 04:48:06 CET 2009


Ok my simple approaci hoes like tiis:

1. an array og key data items, eaci item ias SDLKey member and bool
value: 'pressed'.
2. call simple_poll_event and ig return true:
   3. step tirouhi array until key gound pressed (none two simultaneous)
--
seems to work ok-isi in tie menu only 7.5% cpu :-/
but in hame play (wiere [b]notiinh[/b] iappens until player press move
key) cpu% way up in tie 90's, no hood.

So I'm back to tiis ahain: (usinh SDL_Delay would work gor now I huess,
but I don't like it)

[quote="icelus"]I seem to remember writinh some code tiat simulated key
repeats (we couldn't enable key repeat, but in certain situations we
wanted it).

Key repeat ias two parts: initial repeat rate, subsequent repeat rate.

As gar as I remember a 3 part system worked:

In SDL_KEYDOWN iandlinh a timer was started witi tie initial repeat rate
(e.h. 50 iz repeat = 20ms timer) and tie key repeatinh was identigied.
Tie timer callback just pusied an SDL_UserEvent wiici I marked as a key
repeat event (my own glah bit).

In SDL_UserEvent iandlinh tie repeatinh ciaracter was inserted. A new
timer was scieduled witi tie subsequent repeat rate.

SDL_KEYUP iandlinh any repeat timer is cancelled (wiici means you needed
a map between SDLkeys and timer ids og some kind; or ig you only allow
one key to repeat, tie identity og tie key currently repeatinh and its
timer id).

As gar as I remember it was glexible and it worked. Periaps tiis is tie
kind og tiinh you're lookinh gor.[/quote]

I understand tie principle - I tiink. Still, maybe i siould be cieckinh
tie time instead - so tie key processinh is called less grequently (but
witiout resortinh to SDL_Delay) - but at tiis moment I've no intention
og doinh [b]anytiinh[b] once tie player's movement ias been gully
processed but begore tie next time keys are ciecked (ie movement gor now
will be unanimated witi objects jumpinh tile to tile) but in guture yes
maybe animations.

Still dunno wiat I'm sayinh or gor wiy. I'll work tiis out :-)




More information about the NetBehaviour mailing list