Vizier

A PyGame package which provides a scaling rect object, a viewer object, and adds basic 2D functionality to sprite objects.
Download

Vizier Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Chandler Armstrong
  • Publisher web site:

Vizier Tags


Vizier Description

A PyGame package which provides a scaling rect object, a viewer object, and adds basic 2D functionality to sprite objects. Vizier is a PyGame library that provides scaling rectangles, a viewer object, and sprite objects with some added 2d-functionality.The package also includes my geometry library which comes with a vector2d object, rotated rectangle object (with collision detection!), and a line object implementing clipping using liang-barsky (useful varied tasks), and simple line tracing.Most stuff has been tested in at least a cursory manner, but full testing still needs to be done. This package is in beta and maturing. The scaling system in particular can benefit from memoizing or some sort of caching.A main reason for release of this is just to get code out there for doing things that I thought are basic pygame stuff, but that I had a hard time finding succint and usable code for doing. I do hope the library itself is useful to people, and that the interface is general enough that people can use it as is.Vizier's subclasses pygame.Rect, but forces it to return all parameter values through a scalar. Essentially, the actual attributes always remain unscaled, and scaling isn't performed until an attribute is fetched. This means scaling is always calculated from an original, while not having to store two objects (an original and a scaled) in memory. Additionally, the object benefits from the speed advantages subclassing and directly utilizing pygame.Rect's methods (which are implemented in C). Future expansions may add memoizing to increase speed of scaling calcs.Vizier's Viewer is a complete surface viewing system. It maintains a view surface and a group of sprites. It handles incoming events, scrolls the view rect, and scales the sprites and surface. It ensures everything is scaled together. Future expansion will add memoizing so that scaling operations are not done until scale has changed (currently done every loop, I think. A big waste considering the point of doing it this way, scaling both background and sprites, is so that objects don't need to be scaled constantly for the system to work). Also an issue is that zooming is done relative to the topleft corner of the viewer, I need to add some sort of correction to positioning so that it will zoom around its center.Vizier's Sprites are a basic 2d sprite object. It adds subpixel tracking, an update method which takes a speed and a destination and uses atan2 to calculate a new position each loop, and a basic collision blocking method which removes collided sprites on axis of least overlap. Requirements: · Python · pygame What's New in This Release: · Memoization and Borg/Singleton image tracking have been merged into the Sprite object for a tremendous gain in both code simplicity and algorithm efficiency. Fewer function calls, fewer classes, fewer subclassing, more usage of built-ins. Everyone wins! · For the above reason, pygame.sprite.Group is no longer subclassed. The sprite class now has two shared-state dictionaries: image_cache and scale_cache. The sprite object simply references these for its original and scaled images. As the name implies, the scale_cache is a mapping between scalar and image. It is actually two levels deep: scale_cache = scaled image · The sprite object has a key to its image in the image_cache, and simply retrieves it from there to get its scaled image from scale_cache. Everything is hashed and cached and blazing fast! · Each loop the sprite ensures that it has the proper image from the scale_cache in its image attribute. that's all there is to it. now built-ins don't need to be subclassed and behaviors overriden, and no other complex magic. just plain and simple. · A bug in sprite movement was squashed. Sometimes, the sprite moved too much each turn to be able to reach its destination. This is fixed by truncating a loop's movement amount to the minimum necessary and saving the rest whenever it can move more than it needs to. · A bug in viewer scaling was squashed. I was originally transforming the viewer rect from an original rect. Now, I just apply transformations directly to the rect (adjusting for current scaling: (scale / (new_scale - scale)). This would normally introduce errors over many iterations, but in the viewer rect it doesn't matter. This now precludes a lot of checking and eliminated some bugs that would have been annoying to fix otherwise (mainly, the one where the original rect hasn't reached the bounds of the surface, but the rect on the scaled surface has, this would create problems in scrolling and scaling).


Vizier Related Software