osdir.com
mailing list archive

Subject: Animating sprites - msg#00044

List: python.pygame

Date: Prev Next Index Thread: Prev Next Index
What's the best way to animate a sprite in the background? I am
writing a turn based strategy game (http://www.spqr-game.co.uk/),
which I've written a gui for. I need to animate a sprite in the
background (actually mainly flashing on and off, or, if python is fast
enough, fade it in and out). No mention of this sort of stuff in the
sprite module and I'd rather avoid using threads if possible :-) Any
ideas?

- Chris

--
Science is open source religion



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Advice on Game Engine (OpenGL)

David wrote: Ben: I would hope that people putting in hundreds of hours into a game would want that game played and enjoyed by the widest range of users. > Almost every PC on today's Desktops has an OpenGL - compatible 3d card in them, I did some searching for the drivers for ATI RADEON 9100 IGP (that's on my most recent XP PC) and found a drivers update & utility package - tried installing and the installation failed. The original installation CD doesn't include openGL drivers. On my Win ME laptop, there's a SiS 630/730. Yes, it supports OpenGL but the drivers are for XP only! If you use the latest hardware features, I strongly suggest you have a way of turning them off so that people with lesser hardware can still play your game. Case in point: I've got an ATI Radeon 320 IGP laptop graphics card, apparently based on the Radeon 7000 series. It's a good card, capable of running "Unreal Tournament 2004" and my own OpenGL demos, but when I tried to play "Second Life," my machine crashed. The company's position was, "Your card may be good, but it's not on our approved list. It doesn't support the sexy new graphics features we use, and we won't bother to make those features optional, so go away." So they lost a customer. Don't let this happen to you. Kris

Next Message by Date: click to view message preview

Re: Animating sprites

Well, that sprite should belong to a group, so you have your animation code in its update method. I prefer a list of images, ImageList, from which you can create loops with tuples (for example, go_up = (1,2,3,4), go_down = (5,6,7,8), etc.). Then, depending on its state, current_loop = whatever loop you need. Then, in your update method, you just check how long it's been since your last frame, and if it's time to update frames, then: if self.frame_count >= len(self.current_loop): self.frame_count = 0 else: self.frame_count++ when displayed, the Sprite should display the image: self.ImageList[self.current_loop[self.frame_count]] That should do it, nicely :D On 5/7/05, Chris Smith <maximinus-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote: > What's the best way to animate a sprite in the background? I am > writing a turn based strategy game (http://www.spqr-game.co.uk/), > which I've written a gui for. I need to animate a sprite in the > background (actually mainly flashing on and off, or, if python is fast > enough, fade it in and out). No mention of this sort of stuff in the > sprite module and I'd rather avoid using threads if possible :-) Any > ideas? > > - Chris > > -- > Science is open source religion > -- Andrew Ulysses Baker "failrate"

Previous Message by Thread: click to view message preview

Two Quick Questions

First mp3's what do I need to do to convert a wav to an mp3 that pygame will like. Secondly is there a way to freeze python/pygame applications on the Mac

Next Message by Thread: click to view message preview

Re: Animating sprites

Well, that sprite should belong to a group, so you have your animation code in its update method. I prefer a list of images, ImageList, from which you can create loops with tuples (for example, go_up = (1,2,3,4), go_down = (5,6,7,8), etc.). Then, depending on its state, current_loop = whatever loop you need. Then, in your update method, you just check how long it's been since your last frame, and if it's time to update frames, then: if self.frame_count >= len(self.current_loop): self.frame_count = 0 else: self.frame_count++ when displayed, the Sprite should display the image: self.ImageList[self.current_loop[self.frame_count]] That should do it, nicely :D On 5/7/05, Chris Smith <maximinus-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote: > What's the best way to animate a sprite in the background? I am > writing a turn based strategy game (http://www.spqr-game.co.uk/), > which I've written a gui for. I need to animate a sprite in the > background (actually mainly flashing on and off, or, if python is fast > enough, fade it in and out). No mention of this sort of stuff in the > sprite module and I'd rather avoid using threads if possible :-) Any > ideas? > > - Chris > > -- > Science is open source religion > -- Andrew Ulysses Baker "failrate"
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by