Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/kivent revival: Take 2! #281

Merged
merged 18 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down Expand Up @@ -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)
Expand Down
54 changes: 28 additions & 26 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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") {
Expand All @@ -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") {
Expand Down
1 change: 1 addition & 0 deletions examples/0_empty_kivy_app/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import kivy
import kivent_core
from kivy.app import App
from kivy.uix.widget import Widget

Expand Down
2 changes: 1 addition & 1 deletion examples/0_empty_kivy_app/yourappname.kv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#:kivy 1.9.0
#:kivy 1.11.0

TestGame:

Expand Down
3 changes: 1 addition & 2 deletions examples/10_particles_demo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/10_particles_demo/yourappname.kv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#:kivy 1.9.0
#:kivy 1.11.0

TestGame:

Expand Down
6 changes: 3 additions & 3 deletions examples/11_svg_demo/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'],
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion examples/11_svg_demo/yourappname.kv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#:kivy 1.9.0
#:kivy 1.11.0

TestGame:

Expand Down
3 changes: 1 addition & 2 deletions examples/12_drawing_shapes/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion examples/12_drawing_shapes/yourappname.kv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#:kivy 1.9.0
#:kivy 1.11.0

TestGame:

Expand Down
3 changes: 1 addition & 2 deletions examples/13_tilemap/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion examples/13_tilemap/yourappname.kv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#:kivy 1.9.0
#:kivy 1.11.0
#:import get_asset_path __main__.get_asset_path

TestGame:
Expand Down
9 changes: 6 additions & 3 deletions examples/14_tmx_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
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)

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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/14_tmx_loader/yourappname.kv
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
70 changes: 47 additions & 23 deletions examples/15_camera_rotate/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,15 +21,17 @@
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'))



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'],
Expand All @@ -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))
Expand All @@ -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',
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion examples/15_camera_rotate/yourappname.kv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#:kivy 1.9.0
#:kivy 1.11.0
#:import path os.path
#:import dirname os.path.dirname
#:import main __main__
Expand Down
Loading