[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] I have a quick question... again...



On Sat, Jun 16, 2007 at 09:32:09AM -0700, Casey Duncan wrote:
> On Jun 16, 2007, at 8:56 AM, Laura Creighton wrote:
> [..]
> >
> >If you use Model-View-Controller like separation of your code,
> >None.  All your changes will be in the drawing.
> 
> I'm curious how many of you actually employ MVC using pygame, since  
> the library encourages mixing the model and view via sprites. I'd be  
> interested to see a "canonical" example of a pygame that uses MVC.

I don't know about canonical, but PySpaceWar uses pure MVC.  I think; I
never fully understood the "controller" part of it; my views are often
also controllers.

http://mg.pov.lt/pyspacewar/http://mg.pov.lt/pyspacewar/

There were two reasons for making the model independent of views:

  * I wanted beautiful and understandable code
  * I want to add network play at some undetermined point in the future

> MVC has strong advantages when you need to present and interact with  
> the same data in multiple ways, but often in simple games data is  
> only presented a single way. Using MVC has advantages for unit  
> testing as well, but how many pygames actually employ unit tests in a  
> meaningful way?

For some low-level functions (e.g. vector math) unit tests were rather
useful.  Also, I couldn't have refactored the AI code that Ignas
Mikalajūnas wrote for me without writing a set of unit tests for it.
Other than that, my initial resolution to have everything covered by
unit tests evaporated pretty rapidly when I got caught in the frenzy of
prototyping the fun stuff.

> Also, is unit testing something that the gaming  
> industry at large embraces?

(I'm completely clueless about the gaming industry.)

> I'm curious how widespread these practices really are in the pygame  
> community, not to make a point for or against them, but to better  
> understand theory vs. practice.

Marius Gedminas
-- 
Never trust an operating system you don't have sources for.

Attachment: signature.asc
Description: Digital signature