SDL Digest, Vol 3, Issue 17

Simple Again, to animate using SDL, When you load your images load them
into an array, something like ths pseudo code

SDL_Surface * FootFrames[2];

 FootFrames[1]  = LoadIMG("FootImage1")
 FootFrames[2]  = LoadIMG("FootImage2")
 int       footAnim=0;

on your key events

if key pressed
footAnim++;

on your draw bitmaps part

SDL_BlitSurface(FootFrames[footAnim&1], NULL, Screen, NULL);

the important part here is that your footAnim just keeps incrementing but
the footAnim&1 is a bit wise AND, giving you only 0 or 1.

I hope this helps

Trish

PS please dont anyone say i have missed my error checks :pOn 3/8/07, sdl-request at lists.libsdl.org wrote:

Send SDL mailing list submissions to
sdl at lists.libsdl.org

To subscribe or unsubscribe via the World Wide Web, visit
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
or, via email, send a message with subject or body ‘help’ to
sdl-request at lists.libsdl.org

You can reach the person managing the list at
sdl-owner at lists.libsdl.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of SDL digest…”

Today’s Topics:

  1. SDL_CondSignal usage (sanjay kumar gupta)
  2. Re: SDL_CondSignal usage (Alexis Naveros)
  3. Quick Question about animation. (Lamonte(Scheols/Demonic))
  4. Re: Quick Question about animation. (Scott Harper)

Message: 1
Date: 7 Mar 2007 20:02:00 -0000
From: “sanjay kumar gupta”
Subject: [SDL] SDL_CondSignal usage
To: sdl at lists.libsdl.org
Message-ID: <20070307200200.17794.qmail at webmail99.rediffmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

Hi,
man page of function SDL_CondSignal(cond) says that it will Restart a
thread which is waiting on condition variable (here it is cond).
What if one thread is calling function SDL_CondSignal(cond) and none of
the other threads has called SDL_CondWait(cond,mutex).
what will be the effect of calling SDL_CondSignal(cond) in this case even
if no one is waiting on this condition variable?

Thanks & regards,
Sanjay
-------------- next part --------------
An HTML attachment was scrubbed…
URL:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070307/8629991e/attachment-0001.html


Message: 2
Date: Wed, 07 Mar 2007 15:34:26 -0500
From: Alexis Naveros
Subject: Re: [SDL] SDL_CondSignal usage
To: sdl at lists.libsdl.org
Cc: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID: <20070307153426.ceafa9e4.alexis at rayforce.net>
Content-Type: text/plain; charset=US-ASCII

man page of function SDL_CondSignal(cond) says that it will Restart a
thread which is waiting on condition variable (here it is cond).
What if one thread is calling function SDL_CondSignal(cond) and none of
the other threads has called SDL_CondWait(cond,mutex).
what will be the effect of calling SDL_CondSignal(cond) in this case
even if no one is waiting on this condition variable?

Same as with Pthreads signal surely, SDL_CondSignal has no effect and
execution continues. After the condition variable has been signaled, any
threading waiting on it will block as usual.

Alexis


Message: 3
Date: Wed, 7 Mar 2007 16:33:19 -0600
From: “Lamonte(Scheols/Demonic)”
Subject: [SDL] Quick Question about animation.
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID:
<5b0fce7a0703071433ya66db91ob2ad688b3753b16e at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello,
I was wondering whats the best way to switch between 2 image frames
every time I would press a key. For example, If I loaded 2 bitmaps
one will have its foot back and the other would have its foot forward
so if I would to keep running the frames back and forth it would look
like my sprite was walking. Any suggestions on the BEST way to do
this?

Thanks in advanced for any suggestions giving.
-Lamonte


Join phpdiscovery.com Now!


Message: 4
Date: Wed, 7 Mar 2007 16:09:39 -0700
From: Scott Harper
Subject: Re: [SDL] Quick Question about animation.
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID: <4BCB6C1E-560F-4BB2-A9D7-9E13614EB186 at comcast.net>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

On Mar 7, 2007, at 3:33 PM, Lamonte(Scheols/Demonic) wrote:

Hello,
I was wondering whats the best way to switch between 2 image frames
every time I would press a key. For example, If I loaded 2 bitmaps
one will have its foot back and the other would have its foot forward
so if I would to keep running the frames back and forth it would look
like my sprite was walking. Any suggestions on the BEST way to do
this?

Unfortunately (as I’m sure many have discovered and I am currently
discovering), there’s no “best” way to do something like this. You
could set a variable and draw one or the other image based on that
variable’s value (meaning one more if() statement each frame), or you
could set some pointer variable to a drawing structure to point to a
different image each time it needs to switch… Those are the only
two reasonable ones I can come up with. The others a far more
obscure and unlikely.

Do either of those help at all?

I think a lot of “best” depends on how you’re structuring your
entities, also.

– Scott



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

End of SDL Digest, Vol 3, Issue 17



In a time of universal deceit, telling the truth is a revolutionary act.

Trish & Thy also Available on

Skype tranmaithy63,