Package: wonder
Whenever I have played a great computer game for the first time, I waswondering how they do it. Then I tried to recreate it.Pygame(https://www.pygame.org) is a great library for making your
own game with python.When starting a new game from scratch you always need to build the basic
structure. The game enginewondergives you a collection of
components you can use withPygame.The game enginewonderis only a frame for your programming, so you
have to know Pygame for creating new games.Many ideas inwonderare inspired byUnity 3D(https://unity.com)If you are looking for more simple to use Pygame frameworks:pygame zerohttps://github.com/lordmauve/pgzeropython arcade libraryhttps://arcade.academyThe game enginewonderincludes Box2D as physics engine.Goals:explicit is better then implicit - wonder is only the frame for your
gameComponent based - more components, less classesInspired by Unity 3D - Similar names for object types and methodsPhysics engine includedIf you like it, use it. If you have some suggestions, tell me
(hebi@ninja-python.com).All game assets that I use in examples are free and fromhttps://www.kenney.nl. Thank you.acclaimerYou can use this alpha version 0.1.0 of the game enginewonderbut
there will be some changes in the future.installing wonder game engineInstall with pippip install wonderIf that does not work on your platform you can install the different
components separatelyInstallpygamepip install pygameInstall physics engineBox2Dpip install box2dFor installingwondersimply copy filewonder.pyto your
directory.cp wonder.pywonder game engine - making a new gamemain gamelevel 1 - sceneA scene contains of gameobjectcreateadd gameobjectgameobjectfirst gameobject Racketadd SpriteRender Componentfixed_rotationcreate bordercomponent rigidbody staticcreate blocksmove racketdebugcreate ballrestitutioncomponent rigidbodycomponent circlecollidermove ballcreate blockcomponent rigidbodycomponent boxcollidercreate scoremanagerget_objectstart_tagdraw_textrestrart0 ball level 1next levelwonder game engine - behind the curtaincentral engine and the systemspattern singletongame loop update draweventupdatelate_updatedrawtimingevent systemon_load_sceneobserver patternget_objectGetObjectgameobjectmixintransformcomponentsSpriteRendererscenelayered container for gameobjectrender systemlayered observerComponent SpriteRendererSurfaceload_from_fileconsists of surface and rectchange current sceneadd or remove gameobjectadd or remove componentphysic and collision systemusing Box2Dhttps://box2d.org/documentation/md__d_1__git_hub_box2d_docs_dynamics.htmlpythonhttps://github.com/pybox2d/pybox2dbodiesComponent Rigidbody is b2Bodysynchornize transformbody typesSTATIC_BODYphysic system does not simulate this bodybody has zero velocitybody does not collide with other static or kinematic bodiesKINEMATIC_BODYphysic system simulates this bodybody does not respond to forcesprogram can move body normally by setting velocitybody does not collide with other static or kinematic bodiesDYNAMIC_BODYphysic system simulates this bodybody collides with other bodiesfixturescomponent collider is b2Fixtureboxcolliderdebugjointsdistance jointsget_gameobjectanimator componentanimator has statesstate has clipsparticle systemtile systemATileMapis an GameObject and consists ofwidthxheighttiles.Every tile has a width oftile_widthpixels and a height oftile_height.GRID_WIDTH = 5
GRID_HEIGHT = 7

CELL_WIDTH = 64
CELL_HEIGHT = 64

tilemap = TileMap(GRID_WIDTH,GRID_HEIGHT,CELL_WIDTH,CELL_HEIGHT)The tilemap.transform.position is always the top left position of the
map. With changing position you can move the complete map.A TileMap has apalettewith differentTilePaletteItemyou can
use in a tilemap.ATilePaletteItemhas an uniqueid, an uniquetile_typeand animage.tilemap.palette.add(TilePaletteItem(0, tile_type='ground', image=pygame.image.load('res_tile/ground.png')))
tilemap.palette.add(TilePaletteItem(1, tile_type='wall', image=pygame.image.load('res_tile/wall.png')))
..To create a tile from the palette at a specific position in the tile map
use the functioncreate_tile_from_palette(position_x,position_y,tile_typeorid)tilemap.create_tile_from_palette(0,0,'ground')You can create a complete tile map withset_all_tilestilemap.set_all_tiles([[1,1,1,1,1],
                       [1,0,0,0,1],
                       [1,0,0,0,1],
                       [1,0,0,0,1],
                       [1,0,0,0,1],
                       [1,0,0,0,1],
                       [1,1,1,1,1]])A classTileMapcan have more than one layer of tiles. Negative
values are None.new_layer = tilemap.add_layer()

tilemap.set_all_tiles([[-1,-1,-1,-1,-1],
                       [-1, 4,-1,-1,-1],
                      ..
                       [-1,-1,-1, 2,-1],
                       [-1,-1,-1,-1,-1]],tile_layer=new_layer)To see something tilemap as gameobject needs rendering componenttilemap.add(TileMapRenderer(tilemap))With classTileControllera tile can reacttilemap.palette.add(TilePaletteItem(4, tile_type='player', image=pygame.image.load('res_tile/player_01.png'),
                                    tile_controller_class=Player))ClassPlayeris in gameloop update cycleclass Player(TileController):
    def __init__(self,tile:Tile):
        super().__init__(tile)
        ..

    def update(self, delta_time: float):
        ..ClassTileControllerhas some convinient methods.get_position().. current tile positiontile = self.get_tile(pos).. get tile at postiontile.has_type('ground').. has tile the that typeset_position(new_pos).. change position of tileChangelogVersion0.1.0first version