diff --git a/.travis.yml b/.travis.yml index 3fdd24a6..f8015543 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,13 @@ language: python python: - - 2.7 - - 3.4 - 3.5 + - 3.6 + - 3.7 sudo: required -dist: trusty +dist: xenial before_install: - - yes | sudo add-apt-repository ppa:mc3man/trusty-media - - sudo apt-get update - - sudo apt-get install build-essential ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev + - sudo apt update + - sudo apt install -y build-essential ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev - pip install -U pip - pip install Cython - pip install -r ./requirements.txt diff --git a/README.md b/README.md index b0dfb0a7..900c9de8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -KivEnt 2.2 +KivEnt 3.0 ========== KivEnt is a framework for building performant, dynamic real-time scenes in [Kivy](http://kivy.org/#home) for Python2 and Python3. At the moment it is 2d oriented. The only dependency for the kivent_core module is Kivy itself. Additional modules may have other requirements, such as kivent_cymunk module being based on [Chipmunk2d](https://chipmunk-physics.net/) and its [cymunk wrapper](https://github.com/tito/cymunk). @@ -38,7 +38,7 @@ Other modules may have other dependecies, listed here: ### kivent_maps * [kivy](https://github.com/kivy/kivy) * [kivent_core](https://github.com/kivy/KivEnt/tree/master/modules/core) -* also Tiled based deps, udiboy1209 we need to add the deps here +* [python-tmx](https://savannah.nongnu.org/projects/python-tmx/) ### kivent_projectiles * [kivy](https://github.com/kivy/kivy) diff --git a/appveyor.yml b/appveyor.yml index 419fe5af..483b4600 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,18 +10,18 @@ environment: MSYSTEM: MINGW64 CHERE_INVOKING: 1 matrix: - - PYVER: 27 + - PYVER: 35 BITTNESS: 86 - COMPILER: mingw - - PYVER: 27 + - PYVER: 35 BITTNESS: 64 - COMPILER: mingw - - PYVER: 34 + - PYVER: 36 BITTNESS: 86 - COMPILER: mingw - - PYVER: 34 + - PYVER: 36 + BITTNESS: 64 + - PYVER: 37 + BITTNESS: 86 + - PYVER: 37 BITTNESS: 64 - COMPILER: mingw install: - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-desktop.ps1')) build_script: @@ -124,13 +124,6 @@ build_script: Check-Error - if ($env:COMPILER -ne "msvc") { - python -c "with open(r'$PYTHON_ROOT\Lib\distutils\distutils.cfg', 'wb') as fh: fh.write(b'[build]\ncompiler = mingw32\n')" - Check-Error - pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy - Check-Error - } - pip install mock cython pygments docutils nose kivy.deps.glew_dev kivy.deps.glew kivy.deps.sdl2_dev kivy.deps.sdl2 Check-Error @@ -141,28 +134,33 @@ build_script: # get kivy version at runtime later, magically - pip install "$kivy_url/Kivy-1.10.1.dev0-${CP}" + pip install "$kivy_url/Kivy-2.0.0.dev0-${CP}" Check-Error # Create cymunk wheel (kivent_cymunk dependency) + echo "requisite lib cymunk not installing on windows in python 3.5+, see https://github.com/kivy/cymunk/issues/52" + $cymunk_fixed = False - git clone -q --branch=master https://github.com/kivy/cymunk.git C:\projects\cymunk + if ($cymunk_fixed -eq "True") { - Check-Error + git clone -q --branch=master https://github.com/kivy/cymunk.git C:\projects\cymunk - cd C:\projects\cymunk + Check-Error - python setup.py bdist_wheel -d "${WD}" + cd C:\projects\cymunk - Check-Error + python setup.py bdist_wheel -d "${WD}" - # find a way how to check version dynamically (same as kivy) + Check-Error - pip install "${WD}\cymunk-0.0.0.dev0-${CP}" + # find a way how to check version dynamically (same as kivy) - Check-Error + pip install "${WD}\cymunk-0.0.0.dev0-${CP}" + + Check-Error + } cd $env:APPVEYOR_BUILD_FOLDER @@ -185,7 +183,9 @@ build_script: if ($mod -eq "core") { $CORE_V = python -c "${R}${mod}${X}" } elseif ($mod -eq "cymunk") { - $CYM_V = python -c "${R}${mod}${X}" + if ($cymunk_fixed -eq "True") { + $CYM_V = python -c "${R}${mod}${X}" + } } elseif ($mod -eq "maps") { $MAPS_V = python -c "${R}${mod}${X}" } elseif ($mod -eq "particles") { @@ -208,7 +208,9 @@ build_script: if ($mod -eq "core") { pip install "${WD}\KivEnt_Core-${CORE_V}-${CP}" } elseif ($mod -eq "cymunk") { - pip install "${WD}\KivEnt_Cymunk-${CYM_V}-${CP}" + if ($cymunk_fixed -eq "True") { + pip install "${WD}\KivEnt_Cymunk-${CYM_V}-${CP}" + } } elseif ($mod -eq "maps") { pip install "${WD}\KivEnt_maps-${MAPS_V}-${CP}" } elseif ($mod -eq "particles") { diff --git a/examples/0_empty_kivy_app/main.py b/examples/0_empty_kivy_app/main.py index e87a2aba..3bba5d09 100644 --- a/examples/0_empty_kivy_app/main.py +++ b/examples/0_empty_kivy_app/main.py @@ -1,4 +1,5 @@ import kivy +import kivent_core from kivy.app import App from kivy.uix.widget import Widget diff --git a/examples/0_empty_kivy_app/yourappname.kv b/examples/0_empty_kivy_app/yourappname.kv index 9dce253a..b2fe2246 100644 --- a/examples/0_empty_kivy_app/yourappname.kv +++ b/examples/0_empty_kivy_app/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 TestGame: diff --git a/examples/10_particles_demo/main.py b/examples/10_particles_demo/main.py index 54165602..e668579b 100644 --- a/examples/10_particles_demo/main.py +++ b/examples/10_particles_demo/main.py @@ -9,8 +9,7 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld(['position', 'scale', 'rotate', 'color', 'particles', 'emitters', 'particle_renderer', 'renderer'], callback=self.init_game) diff --git a/examples/10_particles_demo/yourappname.kv b/examples/10_particles_demo/yourappname.kv index 0481c9bc..4e46b0de 100644 --- a/examples/10_particles_demo/yourappname.kv +++ b/examples/10_particles_demo/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 TestGame: diff --git a/examples/11_svg_demo/main.py b/examples/11_svg_demo/main.py index 1cfaa95a..11ddb125 100644 --- a/examples/11_svg_demo/main.py +++ b/examples/11_svg_demo/main.py @@ -1,5 +1,6 @@ import kivy from kivy.app import App +from kivy.logger import Logger from kivy.uix.widget import Widget import kivent_core from kivent_core.rendering.svg_loader import SVG @@ -9,8 +10,7 @@ class TestGame(Widget): entity_id = NumericProperty(None) - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.uuids = {} self.gameworld.init_gameworld( ['position', 'poly_renderer'], @@ -46,7 +46,7 @@ def load_svg(self): for model_info in final_infos: model_name = load_model_from_model_info(model_info, svg_name) model = model_manager.models[model_name] - print(model.vertex_count) + Logger.info(model.vertex_count) model.add_all_vertex_attribute('pos', neg_center) create_dict = { 'position': (300, 300), diff --git a/examples/11_svg_demo/yourappname.kv b/examples/11_svg_demo/yourappname.kv index faf92bd8..ad765502 100644 --- a/examples/11_svg_demo/yourappname.kv +++ b/examples/11_svg_demo/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 TestGame: diff --git a/examples/12_drawing_shapes/main.py b/examples/12_drawing_shapes/main.py index 04ca4c41..77958bc7 100644 --- a/examples/12_drawing_shapes/main.py +++ b/examples/12_drawing_shapes/main.py @@ -116,8 +116,7 @@ class TestGame(Widget): shape_to_draw = StringProperty(None, allownone=True) - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.shapes = {} self.gameworld.init_gameworld( ['position', 'poly_renderer'], diff --git a/examples/12_drawing_shapes/yourappname.kv b/examples/12_drawing_shapes/yourappname.kv index 33ec3008..e5b8f580 100644 --- a/examples/12_drawing_shapes/yourappname.kv +++ b/examples/12_drawing_shapes/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 TestGame: diff --git a/examples/13_tilemap/main.py b/examples/13_tilemap/main.py index 27133686..f2590e9f 100644 --- a/examples/13_tilemap/main.py +++ b/examples/13_tilemap/main.py @@ -12,8 +12,7 @@ def get_asset_path(asset, asset_loc): return join(dirname(dirname(abspath(__file__))), asset_loc, asset) class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['map_layer0', 'position', 'camera1', 'map_layer0_animator', 'tile_map'], diff --git a/examples/13_tilemap/yourappname.kv b/examples/13_tilemap/yourappname.kv index 6572caec..9bd3043e 100644 --- a/examples/13_tilemap/yourappname.kv +++ b/examples/13_tilemap/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import get_asset_path __main__.get_asset_path TestGame: diff --git a/examples/14_tmx_loader/main.py b/examples/14_tmx_loader/main.py index 80fdac8a..9a1f6833 100644 --- a/examples/14_tmx_loader/main.py +++ b/examples/14_tmx_loader/main.py @@ -8,6 +8,7 @@ from os.path import dirname, join, abspath from kivent_maps import map_utils from kivent_maps.map_system import MapSystem +from kivy.logger import Logger Window.size = (640, 640) @@ -15,8 +16,9 @@ def get_asset_path(asset, asset_loc): return join(dirname(dirname(abspath(__file__))), asset_loc, asset) class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + """Testgame to show off kivent_maps functionality.""" + + def on_kv_post(self, *args): # Args required for Renderer init map_render_args = { @@ -73,6 +75,7 @@ def setup_tile_map(self): self.gameworld.init_entity) self.tilemap = map_manager.maps[map_name] + Logger.info('timemap set') def setup_states(self): # We want renderers to be added and unpaused @@ -90,7 +93,7 @@ def screen_touched(self,event): x -= self.pos[0] + cx y -= self.pos[1] + cy - print('Tile %d,%d clicked' % self.tilemap.get_tile_index(x,y)) + Logger.info('Tile %d,%d clicked' % self.tilemap.get_tile_index(x,y)) class DebugPanel(Widget): fps = StringProperty(None) diff --git a/examples/14_tmx_loader/yourappname.kv b/examples/14_tmx_loader/yourappname.kv index 1802b820..6ed83c66 100644 --- a/examples/14_tmx_loader/yourappname.kv +++ b/examples/14_tmx_loader/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import get_asset_path __main__.get_asset_path #:set map_layers ['map_layer%d' % i for i in range(4)] diff --git a/examples/15_camera_rotate/main.py b/examples/15_camera_rotate/main.py index c7967c96..09e4c26a 100644 --- a/examples/15_camera_rotate/main.py +++ b/examples/15_camera_rotate/main.py @@ -1,3 +1,9 @@ +"""15_camera_rotate + +This example shows off the ability to rotate the camera. +To do this, simply start the example and use the scroll +wheel to rotate the camera. +""" from kivy.app import App from kivy.uix.widget import Widget from kivy.clock import Clock @@ -15,6 +21,7 @@ from kivy.properties import StringProperty, NumericProperty from functools import partial from os.path import dirname, join, abspath +from kivy.logger import Logger texture_manager.load_atlas(join(dirname(dirname(abspath(__file__))), 'assets', 'background_objects.atlas')) @@ -22,8 +29,9 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + """Test Game to show off camera rotation functionality.""" + + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['cymunk_physics', 'rotate_renderer', 'rotate', 'position', 'cymunk_touch', 'camera1'], @@ -32,30 +40,33 @@ def __init__(self, **kwargs): def init_game(self): self.setup_states() self.set_state() + self.gameview = self.gameworld.system_manager['camera1'] def draw_some_stuff(self): - gameview = self.gameworld.system_manager['camera1'] - x, y = int(-gameview.camera_pos[0]), int(-gameview.camera_pos[1]) - w, h = int(gameview.size[0] + x), int(gameview.size[1] + y) + x, y = int(-self.gameview.camera_pos[0]), int(-self.gameview.camera_pos[1]) + w, h = int(self.gameview.size[0] + x), int(self.gameview.size[1] + y) create_asteroid = self.create_asteroid - gameview.camera_rotate = radians(180) - ent_follow = 0 - gameview.camera_pos[0] = 100; gameview.camera_pos[1] = 100; - for i in range(5): - pos = i*100, 0 - ent_id = create_asteroid(pos) - ent_follow = ent_id - for i in range(1,5): - pos = 0, i*100 - ent_id = create_asteroid(pos) - - # gameview.entity_to_focus = ent_follow - # gameview.camera_pos[0] = 200 - # gameview.camera_pos[1] = 300 + rows_cols = (4, 5) + + # Spread out the drawn asteroids all over the non-rotated gamewindow + rows = 5 + cols = 4 + rows_offset = w * 1 / rows / 2 + cols_offset = h * 1 / cols / 2 + + for i in range(rows): + for j in range(cols): + ent_id = create_asteroid( + ( + x + w*i/rows + rows_offset, + y + h*j/cols + cols_offset + ) + ) + self.app.count += 100 - def create_asteroid(self, pos): + def create_asteroid(self, pos): x_vel = randint(-500, 500) y_vel = randint(-500, 500) angle = radians(randint(-360, 360)) @@ -66,11 +77,11 @@ def create_asteroid(self, pos): 'collision_type': 1, 'shape_info': shape_dict, 'friction': 1.0} col_shapes = [col_shape] physics_component = {'main_shape': 'circle', - 'velocity': (1,0), + 'velocity': (x_vel,y_vel), 'position': pos, 'angle': angle, 'angular_velocity': angular_velocity, - 'vel_limit': 250, - 'ang_vel_limit': radians(200), + 'vel_limit': 1250, + 'ang_vel_limit': radians(1200), 'mass': 50, 'col_shapes': col_shapes} create_component_dict = {'cymunk_physics': physics_component, 'rotate_renderer': {'texture': 'asteroid1', @@ -96,6 +107,19 @@ def set_state(self): self.gameworld.state = 'main' + def on_touch_down(self, arg): + """Implement scrollwheel camera rotation.""" + if arg.button == 'scrollup': + self.gameview.camera_rotate -= radians(3) + if arg.button == 'scrolldown': + self.gameview.camera_rotate += radians(3) + + # Afte checking for mouse wheel events, still + # support dragging asteroids around, as it + # is quite fun: + super().on_touch_down(arg) + + class DebugPanel(Widget): fps = StringProperty(None) diff --git a/examples/15_camera_rotate/yourappname.kv b/examples/15_camera_rotate/yourappname.kv index 8badf88b..557b13df 100644 --- a/examples/15_camera_rotate/yourappname.kv +++ b/examples/15_camera_rotate/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/16_svg_phys_objects/main.py b/examples/16_svg_phys_objects/main.py index 754f2a86..c3fc893b 100644 --- a/examples/16_svg_phys_objects/main.py +++ b/examples/16_svg_phys_objects/main.py @@ -25,8 +25,7 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['cymunk_physics', 'poly_renderer', 'rotate', 'position', 'cymunk_touch' ], callback=self.init_game) diff --git a/examples/16_svg_phys_objects/yourappname.kv b/examples/16_svg_phys_objects/yourappname.kv index cb50eb26..031ee4ca 100644 --- a/examples/16_svg_phys_objects/yourappname.kv +++ b/examples/16_svg_phys_objects/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/17_joints/main.py b/examples/17_joints/main.py index 42014645..c44498c5 100644 --- a/examples/17_joints/main.py +++ b/examples/17_joints/main.py @@ -31,8 +31,7 @@ def get_asset_path(asset, asset_loc): class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['cymunk_physics', 'rotate_renderer', 'rotate', 'position', 'cymunk_touch'], diff --git a/examples/17_joints/yourappname.kv b/examples/17_joints/yourappname.kv index d16eddcb..07f89f7b 100644 --- a/examples/17_joints/yourappname.kv +++ b/examples/17_joints/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/1_empty_kivent_app/main.py b/examples/1_empty_kivent_app/main.py index bd45f97a..b1087332 100644 --- a/examples/1_empty_kivent_app/main.py +++ b/examples/1_empty_kivent_app/main.py @@ -4,8 +4,7 @@ import kivent_core class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld([], callback=self.init_game) def init_game(self): diff --git a/examples/1_empty_kivent_app/yourappname.kv b/examples/1_empty_kivent_app/yourappname.kv index 70ba0fe2..a30566ac 100644 --- a/examples/1_empty_kivent_app/yourappname.kv +++ b/examples/1_empty_kivent_app/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 TestGame: diff --git a/examples/2_basic_app/main.py b/examples/2_basic_app/main.py index 9a13cab2..6fd4a6c7 100644 --- a/examples/2_basic_app/main.py +++ b/examples/2_basic_app/main.py @@ -1,4 +1,5 @@ import kivy + from kivy.app import App from kivy.uix.widget import Widget from kivy.clock import Clock @@ -15,9 +16,9 @@ texture_manager.load_atlas(join(dirname(dirname(abspath(__file__))), 'assets', 'background_objects.atlas')) + class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['renderer', 'position'], callback=self.init_game) diff --git a/examples/2_basic_app/yourappname.kv b/examples/2_basic_app/yourappname.kv index a4813e7d..51addcff 100644 --- a/examples/2_basic_app/yourappname.kv +++ b/examples/2_basic_app/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/3_creating_a_gamesystem/README.md b/examples/3_creating_a_gamesystem/README.md new file mode 100644 index 00000000..dc9819ef --- /dev/null +++ b/examples/3_creating_a_gamesystem/README.md @@ -0,0 +1,17 @@ +# Creating a GameSystem + +This example shows how to create a KivEnt gamesystem. + +To run the main_with_cython.py example, first cythonize the velocity module: + +``` +$ cythonize -a -i ./velocity_module/velocity.pyx +``` + +This will create shared object files alongside the cython source, which python +can import directly. Then run the example as usual: + +``` +$ python ./main_with_cython.py +``` + diff --git a/examples/3_creating_a_gamesystem/cythonvel.kv b/examples/3_creating_a_gamesystem/cythonvel.kv index 0500a982..e5dee733 100644 --- a/examples/3_creating_a_gamesystem/cythonvel.kv +++ b/examples/3_creating_a_gamesystem/cythonvel.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/3_creating_a_gamesystem/main.py b/examples/3_creating_a_gamesystem/main.py index d0d5ea68..5e9fe9f5 100644 --- a/examples/3_creating_a_gamesystem/main.py +++ b/examples/3_creating_a_gamesystem/main.py @@ -31,8 +31,7 @@ def update(self, dt): Factory.register('VelocitySystem2D', cls=VelocitySystem2D) class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['renderer', 'position', 'velocity'], callback=self.init_game) diff --git a/examples/3_creating_a_gamesystem/main_with_cython.py b/examples/3_creating_a_gamesystem/main_with_cython.py index 888d84da..eafb2edb 100644 --- a/examples/3_creating_a_gamesystem/main_with_cython.py +++ b/examples/3_creating_a_gamesystem/main_with_cython.py @@ -18,8 +18,7 @@ 'background_objects.atlas')) class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['renderer', 'position', 'velocity'], callback=self.init_game) diff --git a/examples/3_creating_a_gamesystem/yourappname.kv b/examples/3_creating_a_gamesystem/yourappname.kv index ac7a48c2..7e6f161e 100644 --- a/examples/3_creating_a_gamesystem/yourappname.kv +++ b/examples/3_creating_a_gamesystem/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/4_adding_physics_objects/main.py b/examples/4_adding_physics_objects/main.py index 4dffe7d4..97e8a3b4 100644 --- a/examples/4_adding_physics_objects/main.py +++ b/examples/4_adding_physics_objects/main.py @@ -20,8 +20,7 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['cymunk_physics', 'rotate_renderer', 'rotate', 'position',], callback=self.init_game) diff --git a/examples/4_adding_physics_objects/yourappname.kv b/examples/4_adding_physics_objects/yourappname.kv index 1202bbca..9fdf5d43 100644 --- a/examples/4_adding_physics_objects/yourappname.kv +++ b/examples/4_adding_physics_objects/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/5_interacting_with_physics/main.py b/examples/5_interacting_with_physics/main.py index 016d4646..1a4244cc 100644 --- a/examples/5_interacting_with_physics/main.py +++ b/examples/5_interacting_with_physics/main.py @@ -22,8 +22,7 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['cymunk_physics', 'rotate_renderer', 'rotate', 'position', 'cymunk_touch'], @@ -62,8 +61,8 @@ def create_asteroid(self, pos): 'velocity': (x_vel, y_vel), 'position': pos, 'angle': angle, 'angular_velocity': angular_velocity, - 'vel_limit': 250, - 'ang_vel_limit': radians(200), + 'vel_limit': 250, + 'ang_vel_limit': radians(200), 'mass': 50, 'col_shapes': col_shapes} create_component_dict = {'cymunk_physics': physics_component, 'rotate_renderer': {'texture': 'asteroid1', diff --git a/examples/5_interacting_with_physics/yourappname.kv b/examples/5_interacting_with_physics/yourappname.kv index f6d41527..7351317c 100644 --- a/examples/5_interacting_with_physics/yourappname.kv +++ b/examples/5_interacting_with_physics/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/6_controlling_the_viewing_area/main.py b/examples/6_controlling_the_viewing_area/main.py index bff75a2d..113a2c47 100644 --- a/examples/6_controlling_the_viewing_area/main.py +++ b/examples/6_controlling_the_viewing_area/main.py @@ -22,8 +22,7 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['cymunk_physics', 'rotate_renderer', 'rotate', 'position', 'cymunk_touch', 'camera1'], diff --git a/examples/6_controlling_the_viewing_area/yourappname.kv b/examples/6_controlling_the_viewing_area/yourappname.kv index 690ad7d3..19ab664d 100644 --- a/examples/6_controlling_the_viewing_area/yourappname.kv +++ b/examples/6_controlling_the_viewing_area/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/7_star_fade/main.py b/examples/7_star_fade/main.py index e36208f1..4c4b1a78 100644 --- a/examples/7_star_fade/main.py +++ b/examples/7_star_fade/main.py @@ -50,8 +50,7 @@ def update(self, dt): class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['color', 'position', 'renderer', 'fade'], callback=self.init_game) diff --git a/examples/7_star_fade/yourappname.kv b/examples/7_star_fade/yourappname.kv index 91b2e814..15995c34 100644 --- a/examples/7_star_fade/yourappname.kv +++ b/examples/7_star_fade/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/8_simple_animation/main.py b/examples/8_simple_animation/main.py index f151e5f4..676ccae5 100644 --- a/examples/8_simple_animation/main.py +++ b/examples/8_simple_animation/main.py @@ -36,8 +36,7 @@ def update(self, dt): Factory.register('MyAnimationSystem', cls=MyAnimationSystem) class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['color', 'position', 'renderer'], callback=self.init_game) diff --git a/examples/8_simple_animation/yourappname.kv b/examples/8_simple_animation/yourappname.kv index 0e34887c..9e950730 100644 --- a/examples/8_simple_animation/yourappname.kv +++ b/examples/8_simple_animation/yourappname.kv @@ -1,4 +1,4 @@ -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/examples/9_twinkling_stars/main.py b/examples/9_twinkling_stars/main.py index 99a80d0d..9b73d71e 100644 --- a/examples/9_twinkling_stars/main.py +++ b/examples/9_twinkling_stars/main.py @@ -29,8 +29,7 @@ class TestGame(Widget): - def __init__(self, **kwargs): - super(TestGame, self).__init__(**kwargs) + def on_kv_post(self, *args): self.gameworld.init_gameworld( ['renderer', 'position', 'animation'], callback=self.init_game) diff --git a/examples/9_twinkling_stars/yourappname.kv b/examples/9_twinkling_stars/yourappname.kv index 9735f11b..0891647e 100644 --- a/examples/9_twinkling_stars/yourappname.kv +++ b/examples/9_twinkling_stars/yourappname.kv @@ -1,5 +1,4 @@ -#:kivy 1.9.0 -#:kivy 1.9.0 +#:kivy 1.11.0 #:import path os.path #:import dirname os.path.dirname #:import main __main__ diff --git a/modules/core/kivent_core/gameworld.pyx b/modules/core/kivent_core/gameworld.pyx index c75da543..71c4816a 100644 --- a/modules/core/kivent_core/gameworld.pyx +++ b/modules/core/kivent_core/gameworld.pyx @@ -4,6 +4,7 @@ from kivy.uix.widget import Widget, WidgetException from kivy.properties import (StringProperty, ListProperty, NumericProperty, DictProperty, BooleanProperty, ObjectProperty) from kivy.clock import Clock +from kivy.logger import Logger from functools import partial from kivy.graphics import RenderContext from kivent_core.systems.gamesystem cimport GameSystem @@ -38,11 +39,11 @@ def test_gameworld(): for x in range(150): component_list = ['position'] creation_dict = {'position': (10., 10.)} - print('making entity', x) + Logger.info('making entity', x) ent_id = init_entity(creation_dict, component_list) - print(ent_id) + Logger.info(ent_id) for entity in memrange(gameworld.entities): - print(entity.entity_id, entity.position.x, entity.position.y) + Logger.info(entity.entity_id, entity.position.x, entity.position.y) class GameWorldOutOfSpaceError(Exception): @@ -348,7 +349,7 @@ class GameWorld(Widget): except KeyError: self.state = 'initial' self._last_state = 'initial' - print('State does not exist, resetting to initial') + Logger.info('State does not exist, resetting to initial') return gamescreenmanager = self.gamescreenmanager gamescreenmanager.state = value diff --git a/modules/core/kivent_core/memory_handlers/block.pxd b/modules/core/kivent_core/memory_handlers/block.pxd index ef5bd388..d2c19ca2 100644 --- a/modules/core/kivent_core/memory_handlers/block.pxd +++ b/modules/core/kivent_core/memory_handlers/block.pxd @@ -1,4 +1,4 @@ -from membuffer cimport Buffer +from kivent_core.memory_handlers.membuffer cimport Buffer cdef class MemoryBlock(Buffer): cdef Buffer master_buffer diff --git a/modules/core/kivent_core/memory_handlers/block.pyx b/modules/core/kivent_core/memory_handlers/block.pyx index 10463869..8ba8fc85 100644 --- a/modules/core/kivent_core/memory_handlers/block.pyx +++ b/modules/core/kivent_core/memory_handlers/block.pyx @@ -1,6 +1,6 @@ # cython: profile=True # cython: embedsignature=True -from membuffer cimport Buffer +from kivent_core.memory_handlers.membuffer cimport Buffer cdef class MemoryBlock(Buffer): '''The MemoryBlock is like the Buffer, except instead of allocating its diff --git a/modules/core/kivent_core/memory_handlers/indexing.pxd b/modules/core/kivent_core/memory_handlers/indexing.pxd index 478992ef..40f3d911 100644 --- a/modules/core/kivent_core/memory_handlers/indexing.pxd +++ b/modules/core/kivent_core/memory_handlers/indexing.pxd @@ -1,4 +1,4 @@ -from zone cimport MemoryZone +from kivent_core.memory_handlers.zone cimport MemoryZone cdef class BlockIndex: diff --git a/modules/core/kivent_core/memory_handlers/indexing.pyx b/modules/core/kivent_core/memory_handlers/indexing.pyx index ab401905..a351a3a3 100644 --- a/modules/core/kivent_core/memory_handlers/indexing.pyx +++ b/modules/core/kivent_core/memory_handlers/indexing.pyx @@ -73,10 +73,10 @@ This way when renderer is processing it can run through all of its components in a row, and when renderer2 is processing it can do the same, just a little offset into the position component array. ''' -from block cimport MemoryBlock -from zone cimport MemoryZone -from pool cimport MemoryPool -from membuffer cimport Buffer +from kivent_core.memory_handlers.block cimport MemoryBlock +from kivent_core.memory_handlers.zone cimport MemoryZone +from kivent_core.memory_handlers.pool cimport MemoryPool +from kivent_core.memory_handlers.membuffer cimport Buffer cdef class BlockIndex: diff --git a/modules/core/kivent_core/memory_handlers/pool.pxd b/modules/core/kivent_core/memory_handlers/pool.pxd index b96c8308..428bda3e 100644 --- a/modules/core/kivent_core/memory_handlers/pool.pxd +++ b/modules/core/kivent_core/memory_handlers/pool.pxd @@ -1,5 +1,5 @@ -from membuffer cimport Buffer -from block cimport MemoryBlock +from kivent_core.memory_handlers.membuffer cimport Buffer +from kivent_core.memory_handlers.block cimport MemoryBlock cdef class MemoryPool: cdef unsigned int count diff --git a/modules/core/kivent_core/memory_handlers/pool.pyx b/modules/core/kivent_core/memory_handlers/pool.pyx index 890c02e5..4c56eea5 100644 --- a/modules/core/kivent_core/memory_handlers/pool.pyx +++ b/modules/core/kivent_core/memory_handlers/pool.pyx @@ -1,5 +1,5 @@ -from membuffer cimport Buffer -from block cimport MemoryBlock +from kivent_core.memory_handlers.membuffer cimport Buffer +from kivent_core.memory_handlers.block cimport MemoryBlock cdef class MemoryPool: '''The MemoryPool is suitable for pooling C data of the same type. diff --git a/modules/core/kivent_core/memory_handlers/tests.pyx b/modules/core/kivent_core/memory_handlers/tests.pyx index 1fb1a332..738ca080 100644 --- a/modules/core/kivent_core/memory_handlers/tests.pyx +++ b/modules/core/kivent_core/memory_handlers/tests.pyx @@ -1,9 +1,9 @@ -from block cimport MemoryBlock -from membuffer cimport Buffer -from zone cimport MemoryZone -from pool cimport MemoryPool -from utils cimport memrange -from indexing cimport IndexedMemoryZone, ZoneIndex, BlockIndex +from kivent_core.memory_handlers.block cimport MemoryBlock +from kivent_core.memory_handlers.membuffer cimport Buffer +from kivent_core.memory_handlers.zone cimport MemoryZone +from kivent_core.memory_handlers.pool cimport MemoryPool +from kivent_core.memory_handlers.utils cimport memrange +from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone, ZoneIndex, BlockIndex ctypedef struct Test: float x @@ -254,7 +254,7 @@ def test_indexed_memory_zone(size_in_kb, pool_block_size, print(entity._id, index, 'in creation 2') for entity in memrange(memory_index): - print entity._id + print(entity._id) for entity in memrange(memory_index, zone='test'): - print entity._id + print(entity._id) diff --git a/modules/core/kivent_core/memory_handlers/utils.pxd b/modules/core/kivent_core/memory_handlers/utils.pxd index a5e32195..1fff014b 100644 --- a/modules/core/kivent_core/memory_handlers/utils.pxd +++ b/modules/core/kivent_core/memory_handlers/utils.pxd @@ -1,4 +1,4 @@ -from indexing cimport IndexedMemoryZone +from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone cdef class memrange_iter: cdef IndexedMemoryZone memory_index diff --git a/modules/core/kivent_core/memory_handlers/utils.pyx b/modules/core/kivent_core/memory_handlers/utils.pyx index 91c721ce..8530b7d7 100644 --- a/modules/core/kivent_core/memory_handlers/utils.pyx +++ b/modules/core/kivent_core/memory_handlers/utils.pyx @@ -1,6 +1,6 @@ # cython: embedsignature=True -from indexing cimport IndexedMemoryZone, ZoneIndex -from zone cimport MemoryZone +from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone, ZoneIndex +from kivent_core.memory_handlers.zone cimport MemoryZone cdef class memrange: ''' diff --git a/modules/core/kivent_core/memory_handlers/zone.pxd b/modules/core/kivent_core/memory_handlers/zone.pxd index 5f346e9f..918ce9bc 100644 --- a/modules/core/kivent_core/memory_handlers/zone.pxd +++ b/modules/core/kivent_core/memory_handlers/zone.pxd @@ -1,6 +1,6 @@ -from membuffer cimport Buffer -from pool cimport MemoryPool -from block cimport MemoryBlock +from kivent_core.memory_handlers.membuffer cimport Buffer +from kivent_core.memory_handlers.pool cimport MemoryPool +from kivent_core.memory_handlers.block cimport MemoryBlock cdef class MemoryZone: cdef unsigned int block_size_in_kb diff --git a/modules/core/kivent_core/memory_handlers/zone.pyx b/modules/core/kivent_core/memory_handlers/zone.pyx index e5a22125..7445b9e4 100644 --- a/modules/core/kivent_core/memory_handlers/zone.pyx +++ b/modules/core/kivent_core/memory_handlers/zone.pyx @@ -1,6 +1,6 @@ -from membuffer cimport Buffer -from pool cimport MemoryPool -from block cimport MemoryBlock +from kivent_core.memory_handlers.membuffer cimport Buffer +from kivent_core.memory_handlers.pool cimport MemoryPool +from kivent_core.memory_handlers.block cimport MemoryBlock cdef class MemoryZone: '''The MemoryZone splits one type of data storage up into several zones diff --git a/modules/core/kivent_core/rendering/batching.pxd b/modules/core/kivent_core/rendering/batching.pxd index 99fb3aa5..888730ca 100644 --- a/modules/core/kivent_core/rendering/batching.pxd +++ b/modules/core/kivent_core/rendering/batching.pxd @@ -2,9 +2,9 @@ from kivy.graphics.cgl cimport GLuint from kivent_core.memory_handlers.block cimport MemoryBlock from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone from kivent_core.memory_handlers.membuffer cimport Buffer -from vertex_format cimport KEVertexFormat +from kivent_core.rendering.vertex_format cimport KEVertexFormat from cpython cimport bool -from frame_objects cimport FixedFrameData +from kivent_core.rendering.frame_objects cimport FixedFrameData from kivent_core.systems.staticmemgamesystem cimport ComponentPointerAggregator from kivent_core.managers.resource_managers import texture_manager diff --git a/modules/core/kivent_core/rendering/batching.pyx b/modules/core/kivent_core/rendering/batching.pyx index b0df8bce..be81716a 100644 --- a/modules/core/kivent_core/rendering/batching.pyx +++ b/modules/core/kivent_core/rendering/batching.pyx @@ -3,11 +3,11 @@ from kivent_core.memory_handlers.block cimport MemoryBlock from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone from kivent_core.memory_handlers.membuffer cimport Buffer -from fixedvbo cimport FixedVBO -from frame_objects cimport FixedFrameData -from vertex_format cimport KEVertexFormat +from kivent_core.rendering.fixedvbo cimport FixedVBO +from kivent_core.rendering.frame_objects cimport FixedFrameData +from kivent_core.rendering.vertex_format cimport KEVertexFormat from cpython cimport bool -from cmesh cimport CMesh +from kivent_core.rendering.cmesh cimport CMesh from kivent_core.managers.resource_managers import texture_manager from kivent_core.systems.staticmemgamesystem cimport ComponentPointerAggregator from kivy.logger import Logger diff --git a/modules/core/kivent_core/rendering/cmesh.pxd b/modules/core/kivent_core/rendering/cmesh.pxd index 54e9cf9b..3f12fe7c 100644 --- a/modules/core/kivent_core/rendering/cmesh.pxd +++ b/modules/core/kivent_core/rendering/cmesh.pxd @@ -1,5 +1,5 @@ from kivy.graphics.instructions cimport VertexInstruction -from batching cimport IndexedBatch +from kivent_core.rendering.batching cimport IndexedBatch cdef class CMesh(VertexInstruction): cdef IndexedBatch _batch diff --git a/modules/core/kivent_core/rendering/fixedvbo.pxd b/modules/core/kivent_core/rendering/fixedvbo.pxd index ce7ac39a..b5fe569c 100644 --- a/modules/core/kivent_core/rendering/fixedvbo.pxd +++ b/modules/core/kivent_core/rendering/fixedvbo.pxd @@ -1,5 +1,5 @@ from kivent_core.memory_handlers.block cimport MemoryBlock -from vertex_format cimport KEVertexFormat +from kivent_core.rendering.vertex_format cimport KEVertexFormat from kivy.graphics.cgl cimport GLuint cdef class FixedVBO: diff --git a/modules/core/kivent_core/rendering/fixedvbo.pyx b/modules/core/kivent_core/rendering/fixedvbo.pyx index ae500036..70a56cc2 100644 --- a/modules/core/kivent_core/rendering/fixedvbo.pyx +++ b/modules/core/kivent_core/rendering/fixedvbo.pyx @@ -4,7 +4,7 @@ from kivy.graphics.cgl cimport (GL_ARRAY_BUFFER, GL_STREAM_DRAW, GL_ELEMENT_ARRAY_BUFFER, cgl) from kivent_core.rendering.gl_debug cimport gl_log_debug_message from kivent_core.memory_handlers.block cimport MemoryBlock -from vertex_format cimport KEVertexFormat +from kivent_core.rendering.vertex_format cimport KEVertexFormat cdef short V_NEEDGEN = 1 << 0 cdef short V_NEEDUPLOAD = 1 << 1 diff --git a/modules/core/kivent_core/rendering/frame_objects.pxd b/modules/core/kivent_core/rendering/frame_objects.pxd index beb612cf..214ad3ce 100644 --- a/modules/core/kivent_core/rendering/frame_objects.pxd +++ b/modules/core/kivent_core/rendering/frame_objects.pxd @@ -1,4 +1,4 @@ -from fixedvbo cimport FixedVBO +from kivent_core.rendering.fixedvbo cimport FixedVBO cdef class FixedFrameData: cdef FixedVBO index_vbo diff --git a/modules/core/kivent_core/rendering/frame_objects.pyx b/modules/core/kivent_core/rendering/frame_objects.pyx index 693d0bf7..25f517f5 100644 --- a/modules/core/kivent_core/rendering/frame_objects.pyx +++ b/modules/core/kivent_core/rendering/frame_objects.pyx @@ -1,6 +1,6 @@ from kivent_core.memory_handlers.block cimport MemoryBlock -from vertex_format cimport KEVertexFormat -from fixedvbo cimport FixedVBO +from kivent_core.rendering.vertex_format cimport KEVertexFormat +from kivent_core.rendering.fixedvbo cimport FixedVBO cdef class FixedFrameData: '''The FixedFrameData manages 2 FixedVBO, suitable for rendering using the diff --git a/modules/core/kivent_core/rendering/model.pxd b/modules/core/kivent_core/rendering/model.pxd index b21dd80a..3a3ad9d6 100644 --- a/modules/core/kivent_core/rendering/model.pxd +++ b/modules/core/kivent_core/rendering/model.pxd @@ -1,6 +1,6 @@ from kivent_core.memory_handlers.membuffer cimport Buffer from kivent_core.memory_handlers.block cimport MemoryBlock -from vertex_formats cimport FormatConfig +from kivent_core.rendering.vertex_formats cimport FormatConfig cdef class Vertex: diff --git a/modules/core/kivent_core/rendering/model.pyx b/modules/core/kivent_core/rendering/model.pyx index a1b377e5..c57936e9 100644 --- a/modules/core/kivent_core/rendering/model.pyx +++ b/modules/core/kivent_core/rendering/model.pyx @@ -1,8 +1,8 @@ # cython: embedsignature=True cdef extern from "string.h": void *memcpy(void *dest, void *src, size_t n) -from vertex_formats cimport VertexFormat4F, FormatConfig -from vertex_formats import vertex_format_4f, vertex_format_7f +from kivent_core.rendering.vertex_formats cimport VertexFormat4F, FormatConfig +from kivent_core.rendering.vertex_formats import vertex_format_4f, vertex_format_7f from kivy.graphics.cgl cimport (GLfloat, GLbyte, GLubyte, GLint, GLuint, GLshort, GLushort) from kivent_core.memory_handlers.membuffer cimport Buffer diff --git a/modules/core/kivent_core/rendering/svg_loader.pyx b/modules/core/kivent_core/rendering/svg_loader.pyx index 3c3e661b..846ebedb 100644 --- a/modules/core/kivent_core/rendering/svg_loader.pyx +++ b/modules/core/kivent_core/rendering/svg_loader.pyx @@ -1023,7 +1023,7 @@ cdef class SVG: if self.fill: tess = Tesselator() for loop in self.path: - tess.add_contour_data(loop.data.as_voidptr, len(loop) / 2) + tess.add_contour_data(loop.data.as_voidptr, (len(loop) / 2)) tess.tesselate() tris = tess.vertices @@ -1071,7 +1071,7 @@ cdef class SVG: cdef float *f_tris cdef float x, y, r, g, b, a - cdef int count = len(path) / 2 + cdef int count = (len(path) / 2) vertices = malloc(sizeof(float) * count * 8) if vertices == NULL: return @@ -1138,7 +1138,7 @@ cdef class SVG: if mode == 0: #polygon - for i in range(count / 2): + for i in range((count / 2)): indices.extend((i, (count - i - 1))) else: if count % 2 == 1: @@ -1156,7 +1156,7 @@ cdef class SVG: # Caps and joint are missing cdef int index, vindex = 0, odd = 0, i cdef float ax, ay, bx, _by, r = 0, g = 0, b = 0, a = 0 - cdef int count = len(path) / 2 + cdef int count = (len(path) / 2) cdef float *vertices = NULL cdef float width = line_width vindex = 0 @@ -1231,7 +1231,7 @@ cdef class SVG: vindex += 32 cdef SVGModelInfo info = self.get_model_info( - vertices, vindex, (vindex / 32) * 4, mode=1) + vertices, vindex, (vindex / 32) * 4, mode=1) free(vertices) return info diff --git a/modules/core/kivent_core/systems/color_systems.pxd b/modules/core/kivent_core/systems/color_systems.pxd index f397dc0f..9844a35c 100644 --- a/modules/core/kivent_core/systems/color_systems.pxd +++ b/modules/core/kivent_core/systems/color_systems.pxd @@ -1,4 +1,4 @@ -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent ctypedef struct ColorStruct: diff --git a/modules/core/kivent_core/systems/color_systems.pyx b/modules/core/kivent_core/systems/color_systems.pyx index f70049f0..648ea04c 100644 --- a/modules/core/kivent_core/systems/color_systems.pyx +++ b/modules/core/kivent_core/systems/color_systems.pyx @@ -1,5 +1,5 @@ # cython: embedsignature=True -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent from kivent_core.memory_handlers.zone cimport MemoryZone from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone from kivent_core.memory_handlers.membuffer cimport Buffer diff --git a/modules/core/kivent_core/systems/gamemap.pxd b/modules/core/kivent_core/systems/gamemap.pxd index 9c2794fe..1f76cd11 100644 --- a/modules/core/kivent_core/systems/gamemap.pxd +++ b/modules/core/kivent_core/systems/gamemap.pxd @@ -1,4 +1,4 @@ -from gamesystem cimport GameSystem +from kivent_core.systems.gamesystem cimport GameSystem cdef class GameMap(GameSystem): pass diff --git a/modules/core/kivent_core/systems/gamemap.pyx b/modules/core/kivent_core/systems/gamemap.pyx index 9090e2e6..d2bad452 100644 --- a/modules/core/kivent_core/systems/gamemap.pyx +++ b/modules/core/kivent_core/systems/gamemap.pyx @@ -1,5 +1,5 @@ # cython: embedsignature=True -from gamesystem cimport GameSystem +from kivent_core.systems.gamesystem cimport GameSystem from kivy.core.window import Window from kivy.properties import (StringProperty, ListProperty, BooleanProperty) from kivy.factory import Factory diff --git a/modules/core/kivent_core/systems/gameview.pxd b/modules/core/kivent_core/systems/gameview.pxd index c1811c96..8a7f4cea 100644 --- a/modules/core/kivent_core/systems/gameview.pxd +++ b/modules/core/kivent_core/systems/gameview.pxd @@ -1,4 +1,4 @@ -from gamesystem cimport GameSystem +from kivent_core.systems.gamesystem cimport GameSystem from kivy.graphics.transformation cimport Matrix diff --git a/modules/core/kivent_core/systems/gameview.pyx b/modules/core/kivent_core/systems/gameview.pyx index 47bcc336..f9650be2 100644 --- a/modules/core/kivent_core/systems/gameview.pyx +++ b/modules/core/kivent_core/systems/gameview.pyx @@ -1,5 +1,5 @@ # cython: embedsignature=True -from gamesystem cimport GameSystem +from kivent_core.systems.gamesystem cimport GameSystem from kivy.properties import (StringProperty, ListProperty, NumericProperty, BooleanProperty, ObjectProperty) from kivy.clock import Clock diff --git a/modules/core/kivent_core/systems/position_systems.pxd b/modules/core/kivent_core/systems/position_systems.pxd index 7f80077d..5c8a078b 100644 --- a/modules/core/kivent_core/systems/position_systems.pxd +++ b/modules/core/kivent_core/systems/position_systems.pxd @@ -1,4 +1,4 @@ -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent ctypedef struct PositionStruct2D: diff --git a/modules/core/kivent_core/systems/position_systems.pyx b/modules/core/kivent_core/systems/position_systems.pyx index 14e17ebe..6bfc384d 100644 --- a/modules/core/kivent_core/systems/position_systems.pyx +++ b/modules/core/kivent_core/systems/position_systems.pyx @@ -1,5 +1,5 @@ # cython: embedsignature=True -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent from kivent_core.memory_handlers.zone cimport MemoryZone from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone from kivent_core.memory_handlers.membuffer cimport Buffer diff --git a/modules/core/kivent_core/systems/renderers.pxd b/modules/core/kivent_core/systems/renderers.pxd index b893569b..d8c04d33 100644 --- a/modules/core/kivent_core/systems/renderers.pxd +++ b/modules/core/kivent_core/systems/renderers.pxd @@ -1,5 +1,5 @@ from kivent_core.rendering.cmesh cimport CMesh -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent from kivent_core.rendering.batching cimport BatchManager from kivent_core.rendering.vertex_format cimport KEVertexFormat from kivent_core.memory_handlers.membuffer cimport Buffer diff --git a/modules/core/kivent_core/systems/renderers.pyx b/modules/core/kivent_core/systems/renderers.pyx index 92d589d5..d7415b1b 100644 --- a/modules/core/kivent_core/systems/renderers.pyx +++ b/modules/core/kivent_core/systems/renderers.pyx @@ -26,7 +26,7 @@ from kivy.graphics.opengl import ( ) cimport cython from kivy.graphics.cgl cimport GLfloat, GLushort -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent from kivent_core.systems.position_systems cimport PositionStruct2D from kivent_core.systems.rotate_systems cimport RotateStruct2D from kivent_core.systems.scale_systems cimport ScaleStruct2D diff --git a/modules/core/kivent_core/systems/rotate_systems.pxd b/modules/core/kivent_core/systems/rotate_systems.pxd index 78149055..e556920d 100644 --- a/modules/core/kivent_core/systems/rotate_systems.pxd +++ b/modules/core/kivent_core/systems/rotate_systems.pxd @@ -1,4 +1,4 @@ -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent ctypedef struct RotateStruct2D: diff --git a/modules/core/kivent_core/systems/rotate_systems.pyx b/modules/core/kivent_core/systems/rotate_systems.pyx index 13bc939e..1376b5eb 100644 --- a/modules/core/kivent_core/systems/rotate_systems.pyx +++ b/modules/core/kivent_core/systems/rotate_systems.pyx @@ -1,5 +1,5 @@ # cython: embedsignature=True -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent from kivent_core.memory_handlers.zone cimport MemoryZone from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone from kivent_core.memory_handlers.membuffer cimport Buffer diff --git a/modules/core/kivent_core/systems/scale_systems.pxd b/modules/core/kivent_core/systems/scale_systems.pxd index 5172b228..0c27f5e2 100644 --- a/modules/core/kivent_core/systems/scale_systems.pxd +++ b/modules/core/kivent_core/systems/scale_systems.pxd @@ -1,4 +1,4 @@ -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent ctypedef struct ScaleStruct2D: diff --git a/modules/core/kivent_core/systems/scale_systems.pyx b/modules/core/kivent_core/systems/scale_systems.pyx index 8cdc735f..ce5ecc20 100644 --- a/modules/core/kivent_core/systems/scale_systems.pyx +++ b/modules/core/kivent_core/systems/scale_systems.pyx @@ -1,5 +1,5 @@ # cython: embedsignature=True -from staticmemgamesystem cimport StaticMemGameSystem, MemComponent +from kivent_core.systems.staticmemgamesystem cimport StaticMemGameSystem, MemComponent from kivent_core.memory_handlers.zone cimport MemoryZone from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone from kivent_core.memory_handlers.membuffer cimport Buffer diff --git a/modules/core/kivent_core/systems/staticmemgamesystem.pxd b/modules/core/kivent_core/systems/staticmemgamesystem.pxd index bae8b617..4328472d 100644 --- a/modules/core/kivent_core/systems/staticmemgamesystem.pxd +++ b/modules/core/kivent_core/systems/staticmemgamesystem.pxd @@ -1,5 +1,5 @@ from kivent_core.memory_handlers.indexing cimport IndexedMemoryZone -from gamesystem cimport GameSystem +from kivent_core.systems.gamesystem cimport GameSystem from kivent_core.memory_handlers.block cimport MemoryBlock from kivent_core.memory_handlers.zonedblock cimport ZonedBlock from cpython cimport bool diff --git a/modules/core/kivent_core/systems/staticmemgamesystem.pyx b/modules/core/kivent_core/systems/staticmemgamesystem.pyx index f7f8f590..e5551c64 100644 --- a/modules/core/kivent_core/systems/staticmemgamesystem.pyx +++ b/modules/core/kivent_core/systems/staticmemgamesystem.pyx @@ -12,7 +12,7 @@ from kivy.properties import (NumericProperty, ObjectProperty, ListProperty, BooleanProperty) from kivent_core.memory_handlers.membuffer cimport Buffer from kivent_core.memory_handlers.zonedblock cimport ZonedBlock -from gamesystem cimport GameSystem +from kivent_core.systems.gamesystem cimport GameSystem from kivent_core.managers.system_manager cimport SystemManager from cpython cimport bool from kivent_core.memory_handlers.utils import memrange diff --git a/modules/core/kivent_core/uix/cwidget.pxd b/modules/core/kivent_core/uix/cwidget.pxd index ffdd8498..35b1357e 100644 --- a/modules/core/kivent_core/uix/cwidget.pxd +++ b/modules/core/kivent_core/uix/cwidget.pxd @@ -3,4 +3,5 @@ from kivy._event cimport EventDispatcher cdef class CWidget(EventDispatcher): cdef object _context cdef object canvas - cdef object _proxy_ref + cdef object _disabled_value + cdef object _disabled_count diff --git a/modules/core/kivent_core/uix/cwidget.pyx b/modules/core/kivent_core/uix/cwidget.pyx index 4625cafb..25e3f402 100644 --- a/modules/core/kivent_core/uix/cwidget.pyx +++ b/modules/core/kivent_core/uix/cwidget.pyx @@ -19,12 +19,21 @@ cdef class CWidget(EventDispatcher): '''Widget class. See module documentation for more information. :Events: - `on_touch_down`: - Fired when a new touch event occurs - `on_touch_move`: - Fired when an existing touch moves - `on_touch_up`: - Fired when an existing touch disappears + `on_touch_down`: `(touch, )` + Fired when a new touch event occurs. `touch` is the touch object. + `on_touch_move`: `(touch, )` + Fired when an existing touch moves. `touch` is the touch object. + `on_touch_up`: `(touch, )` + Fired when an existing touch disappears. `touch` is the touch + object. + `on_kv_post`: `(base_widget, )` + Fired after all the kv rules associated with the widget + and all other widgets that are in any of those rules have had + all their kv rules applied. `base_widget` is the base-most widget + whose instantiation triggered the kv rules (i.e. the widget + instantiated from Python, e.g. ``MyWidget()``). + + .. versionchanged:: 3.0 .. warning:: Adding a `__del__` method to a class derived from Widget with Python @@ -59,7 +68,7 @@ cdef class CWidget(EventDispatcher): ''' __metaclass__ = WidgetMetaclass - __events__ = ('on_touch_down', 'on_touch_move', 'on_touch_up') + __events__ = ('on_touch_down', 'on_touch_move', 'on_touch_up', 'on_kv_post') property canvas: def __get__(self): @@ -79,6 +88,18 @@ cdef class CWidget(EventDispatcher): def __set__(self, value): self._context = value + property _disabled_value: + def __get__(self): + return self._disabled_value + def __set__(self, value): + self._disabled_value = value + + property _disabled_count: + def __get__(self): + return self._disabled_count + def __set__(self, value): + self._disabled_count = value + def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() @@ -88,12 +109,15 @@ cdef class CWidget(EventDispatcher): self._context = get_current_context() no_builder = '__no_builder' in kwargs + self._disabled_value = False if no_builder: del kwargs['__no_builder'] on_args = {k: v for k, v in kwargs.items() if k[:3] == 'on_'} for key in on_args: del kwargs[key] + self._disabled_count = 0 + super(CWidget, self).__init__(**kwargs) # Create the default canvas if it does not exist. @@ -102,13 +126,14 @@ cdef class CWidget(EventDispatcher): # Apply all the styles. if not no_builder: - #current_root = Builder.idmap.get('root') - #Builder.idmap['root'] = self - Builder.apply(self) - #if current_root is not None: - # Builder.idmap['root'] = current_root - #else: - # Builder.idmap.pop('root') + rule_children = [] + self.apply_class_lang_rules( + ignored_consts=self._kwargs_applied_init, + rule_children=rule_children) + + for widget in rule_children: + widget.dispatch('on_kv_post', self) + self.dispatch('on_kv_post', self) # Bind all the events. if on_args: @@ -148,6 +173,61 @@ cdef class CWidget(EventDispatcher): def __self__(self): return self + def apply_class_lang_rules( + self, root=None, ignored_consts=set(), rule_children=None): + ''' + Method that is called by kivy to apply the kv rules of this widget's + class. + :Parameters: + `root`: :class:`Widget` + The root widget that instantiated this widget in kv, if the + widget was instantiated in kv, otherwise ``None``. + `ignored_consts`: set + (internal) See :meth:`~kivy.lang.builder.BuilderBase.apply`. + `rule_children`: list + (internal) See :meth:`~kivy.lang.builder.BuilderBase.apply`. + This is useful to be able to execute code before/after the class kv + rules are applied to the widget. E.g. if the kv code requires some + properties to be initialized before it is used in a binding rule. + If overwriting remember to call ``super``, otherwise the kv rules will + not be applied. + In the following example, + .. code-block:: python + class MyWidget(Widget): + pass + class OtherWidget(MyWidget): + pass + .. code-block:: kv + : + my_prop: some_value + : + other_prop: some_value + When ``OtherWidget`` is instantiated with ``OtherWidget()``, the + widget's :meth:`apply_class_lang_rules` is called and it applies the + kv rules of this class - ```` and ````. + Similarly, when the widget is instantiated from kv, e.g. + .. code-block:: kv + : + height: 55 + OtherWidget: + width: 124 + ``OtherWidget``'s :meth:`apply_class_lang_rules` is called and it + applies the kv rules of this class - ```` and + ````. + .. note:: + It applies only the class rules not the instance rules. I.e. in the + above kv example in the ``MyBox`` rule when ``OtherWidget`` is + instantiated, its :meth:`apply_class_lang_rules` applies the + ```` and ```` rules to it - it does not + apply the ``width: 124`` rule. The ``width: 124`` rule is part of + the ``MyBox`` rule and is applied by the ``MyBox``'s instance's + :meth:`apply_class_lang_rules`. + .. versionchanged:: 1.11.0 + ''' + Builder.apply( + self, ignored_consts=ignored_consts, + rule_children=rule_children) + # # Collision # @@ -245,6 +325,9 @@ cdef class CWidget(EventDispatcher): if child.dispatch('on_touch_up', touch): return True + def on_kv_post(self, base_widget): + pass + def on_disabled(self, instance, value): for child in self.children: child.disabled = value @@ -940,9 +1023,46 @@ cdef class CWidget(EventDispatcher): if canvas is not None: canvas.opacity = value + '''Canvas of the widget. + The canvas is a graphics object that contains all the drawing instructions + for the graphical representation of the widget. + There are no general properties for the Widget class, such as background + color, to keep the design simple and lean. Some derived classes, such as + Button, do add such convenience properties but generally the developer is + responsible for implementing the graphics representation for a custom + widget from the ground up. See the derived widget classes for patterns to + follow and extend. + See :class:`~kivy.graphics.Canvas` for more information about the usage. + ''' + + def get_disabled(self): + return self._disabled_count > 0 + + def set_disabled(self, value): + if value != self._disabled_value: + self._disabled_value = value + if value: + self.inc_disabled() + else: + self.dec_disabled() + return True + + def inc_disabled(self, count=1): + self._disabled_count += count + if self._disabled_count - count < 1 <= self._disabled_count: + self.property('disabled').dispatch(self) + for c in self.children: + c.inc_disabled(count) + + def dec_disabled(self, count=1): + self._disabled_count -= count + if self._disabled_count <= 0 < self._disabled_count + count: + self.property('disabled').dispatch(self) + for c in self.children: + c.dec_disabled(count) + disabled = AliasProperty(get_disabled, set_disabled) - disabled = BooleanProperty(False) '''Indicates whether this widget can interact with input or not. .. note:: diff --git a/modules/core/setup.py b/modules/core/setup.py index bb62c17c..cade3e62 100644 --- a/modules/core/setup.py +++ b/modules/core/setup.py @@ -161,7 +161,7 @@ def build_extensions_for_modules_cython(ext_list, modules): if environ.get('READTHEDOCS', None) == 'True': ext.pyrex_directives = {'embedsignature': True} ext_a(ext) - return cythonize(ext_list) + return cythonize(ext_list, compiler_directives={'language_level': '3'}) def build_extensions_for_modules(ext_list, modules): @@ -187,7 +187,7 @@ def build_extensions_for_modules(ext_list, modules): setup( name='KivEnt Core', - version='2.2.0.dev0', + version='3.0.0', description='''A game engine for the Kivy Framework. https://github.com/Kovak/KivEnt for more info.''', author='Jacob Kovac', diff --git a/modules/cymunk/kivent_cymunk/physics.pyx b/modules/cymunk/kivent_cymunk/physics.pyx index ae96c4b5..2997f6c3 100644 --- a/modules/cymunk/kivent_cymunk/physics.pyx +++ b/modules/cymunk/kivent_cymunk/physics.pyx @@ -2,6 +2,7 @@ # cython: embedsignature=True from kivy.properties import (StringProperty, ListProperty, ObjectProperty, BooleanProperty, NumericProperty) +from kivy.logger import Logger import cymunk from kivent_core.systems.position_systems cimport (PositionStruct2D, PositionSystem2D) @@ -406,7 +407,7 @@ cdef class CymunkPhysics(StaticMemGameSystem): shape_info['a'], shape_info['b']) else: - print('error: shape ', a_shape['shape_type'], + Logger.warn('error: shape ' + a_shape['shape_type'] + 'not supported') if args['mass'] == 0: body = Body(None, None) @@ -439,7 +440,7 @@ cdef class CymunkPhysics(StaticMemGameSystem): new_shape = Segment(body, shape_info['a'], shape_info['b'], shape_info['radius']) else: - print 'shape not created' + Logger.warn('shape not created') new_shape.friction = shape['friction'] new_shape.elasticity = shape['elasticity'] new_shape.collision_type = shape['collision_type'] diff --git a/modules/cymunk/setup.py b/modules/cymunk/setup.py index a1efd466..56977e0a 100644 --- a/modules/cymunk/setup.py +++ b/modules/cymunk/setup.py @@ -131,7 +131,7 @@ def build_extensions_for_modules_cython(ext_list, modules): if environ.get('READTHEDOCS', None) == 'True': ext.pyrex_directives = {'embedsignature': True} ext_a(ext) - return cythonize(ext_list) + return cythonize(ext_list, compiler_directives={'language_level' : "3"}) def build_extensions_for_modules(ext_list, modules): @@ -157,7 +157,7 @@ def build_extensions_for_modules(ext_list, modules): setup( name='KivEnt Cymunk', - version='1.0.0', + version='2.0.0', description='''A game engine for the Kivy Framework. https://github.com/Kovak/KivEnt for more info.''', author='Jacob Kovac', diff --git a/modules/maps/setup.py b/modules/maps/setup.py index 79ec2768..66facb20 100644 --- a/modules/maps/setup.py +++ b/modules/maps/setup.py @@ -66,7 +66,7 @@ def build_extensions_for_modules_cython(ext_list, modules): if environ.get('READTHEDOCS', None) == 'True': ext.pyrex_directives = {'embedsignature': True} ext_a(ext) - return cythonize(ext_list) + return cythonize(ext_list, compiler_directives={'language_level' : "3"}) def build_extensions_for_modules(ext_list, modules): ext_a = ext_list.append @@ -93,7 +93,7 @@ def build_extensions_for_modules(ext_list, modules): setup( name='KivEnt maps', - version='1.0.0', + version='3.0.0', description='''Module to render maps in the KivEnt game engine along with Tiled maps support.''', author='Meet Udeshi', diff --git a/modules/particles/setup.py b/modules/particles/setup.py index 5fcb0ff3..985dd6eb 100644 --- a/modules/particles/setup.py +++ b/modules/particles/setup.py @@ -137,7 +137,7 @@ def build_extensions_for_modules_cython(ext_list, modules): if environ.get('READTHEDOCS', None) == 'True': ext.pyrex_directives = {'embedsignature': True} ext_a(ext) - return cythonize(ext_list) + return cythonize(ext_list, compiler_directives={'language_level' : "3"}) def build_extensions_for_modules(ext_list, modules): @@ -164,7 +164,7 @@ def build_extensions_for_modules(ext_list, modules): setup( name='KivEnt particles', - version='1.0.0', + version='2.0.0', description='''A game engine for the Kivy Framework. https://github.com/Kovak/KivEnt for more info.''', author='Jacob Kovac', diff --git a/modules/projectiles/setup.py b/modules/projectiles/setup.py index 99287b71..1764d901 100644 --- a/modules/projectiles/setup.py +++ b/modules/projectiles/setup.py @@ -127,7 +127,7 @@ def build_extensions_for_modules_cython(ext_list, modules): if environ.get('READTHEDOCS', None) == 'True': ext.pyrex_directives = {'embedsignature': True} ext_a(ext) - return cythonize(ext_list) + return cythonize(ext_list, compiler_directives={'language_level' : "3"}) def build_extensions_for_modules(ext_list, modules): @@ -153,7 +153,7 @@ def build_extensions_for_modules(ext_list, modules): setup( name='KivEnt projectiles', - version='1.0.0', + version='2.0.0', description='''A game engine for the Kivy Framework. https://github.com/Kovak/KivEnt for more info.''', author='Jacob Kovac', diff --git a/requirements.txt b/requirements.txt index be83aee9..896317ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -Cython==0.24.1 -Kivy==1.9.1 -git+git://github.com/tito/cymunk \ No newline at end of file +Cython>=0.29.10 +Kivy>=1.11.1 +git+git://github.com/tito/cymunk diff --git a/scripts/install_all.sh b/scripts/install_all.sh index 80047a76..39b27b2a 100755 --- a/scripts/install_all.sh +++ b/scripts/install_all.sh @@ -7,7 +7,7 @@ ROOT=$(pwd) function safe_cmd { "$@" if [ $? != 0 ]; then - exit $ERROR_CODE + exit $? fi }