The Art of Writing Wargames in Python Using Kivy

The Art of Writing Wargames in Python Using Kivy

The Art of Writing Wargames in Python Using Kivy Presented by Dorian Pula / @dorianpula 1 Prologue 2 . 1 Who am I? Software Developer @ Points Develop eCommerce platform for Loyalty Programs Dockerized Flask REST API microservices Open Source Rookeries - CMS for developers & designers Contributor to Fabric, Ansible & core Python Board gamer → Video gamer → Developer Apparently too late to the wargaming scene. Started programming from copying/porting Apple 2 Basic games to Microsoft QBasic. First open source project was a game: justCheckers. 2 . 2 Building a Game in Kivy @ PyCon Day 1 - Sprinting on Flask Day 2-4 - Kivy Game Camp sprinting. Because making a game is more fun, than submitting PRs for a web framework... Hosted by Amy & Kjell Woodling from Leap, Learn, Fly! Improved Game Camp and Kivy documentation. 2 . 3 Setting the Board 3 . 1 PyQt / PySide PySide / PyQt Python bindings for C++ based on Qt framework. Powerful screen + widget managements. Need C++ experience to effectively use. PyOtherside - QML bindings for Python. 3 . 2 PyGTK, Pyglet, PyGame, etc. PyGTK Python bindings for C based GTK. PyGame Bindings for SDL, more low-level. Pyglet OpenGL based scene-graph library. Electron Javascript frontend. Can use Python backend. Tcl 3 . 3 Kivy Pythonic! Flexible due to OpenGL rendering. Event loop is good for games and interactive apps. UI layout with declarative KV (Classic widget + layout container). Reasonable cross-platform build setup. 3 . 4 Crafting the Game 4 . 1 Kivy Basics Standard UI widget / layout based. Widgets encapsulate behaviour and look. Layout (with nesting) to position widgets. Use of KV language to declare the UI. Can mix Python and KV. Standard event loop to update the screen. Nothing drawn outside of the event loop. 4 . 2 KV Example #:import random random <Widget>: canvas.after: Color: rgba: 1,1,1,.5 Line: rectangle: self.x, self.y, self.width, self.height width: 2 <DebugLabel@Button>: size: self.parent.size pos: self.parent.pos background_color: random.random(), random.random(), random.random(), 0.6 text: 'debuglabel' Pro Tip: Use randomly coloured translucent elements to help with layouts! 4 . 3 Hexagon Layouts Standard Layouts: Grid Box Float (free floating absolute positioning) No such thing as a Hexagon Grid layout. :( Gotta build your own. Lots of math involved: Positioning hexes together. Adding map positional coordinates. Using a cubic coordinates for movement and distance. Thankfully Amy & Kjell are mathematicians. :) 4 . 4 Map Building 4 . 5 Unit Control via Events Having the ability to select and control a unit. Give it commands (like move or attack). Kivy has a rich input event system: Multiple touch events out of the box. Each Widget can has hooks for on_EVENT(). e.g. on_touch_down(), on_pressed() Events broadcast from parent to children. Can create and use custom events. 4 . 6 Kivy Gotchas Three different phases for running painting instruction on a canvas. before, during and after initialization. Kivy allows for changeable window sizes. Need to be aware of positioning in a dynamic manner. Events don't propagate unless you return true, in the event handler method. 4 . 7 Forward Into the World 5 . 1 Targetting Desktops with PyInstaller PyInstaller is NOT an installer. PyInstaller is a bundler for Python modules + libraries. Single directory mode Single binary mode (runnable zip archive) Relatively straight forward with "recipes" for Kivy. Works for all desktop OS: Windows, Linux, OS X. 5 . 2 How about mobile devices? Kivy project: python-for-android Deals with bundling of an app into an APK. Use Buildozer for building apps: Automates lot of the setup and linking. Three easy steps: 1. buildozer init 2. Edit the spec file 3. buildozer android debug deploy 4. Debug/fix when things break Works with iOS and Android. 5 . 3 Building Game Engines + Map Editors Real game devs usually don't build game engines. Game engines can be time intensive and complex. Standard use of third-party engines. Use a entity-component architecture. Every on-screen entity is made of a bunch of self-contained components. Use a tile or map editor. 5 . 4 KivEnt + Tiled KivEnt: entity-component game engine for Kivy​ Similar to Unity3d conceptually. Tiled map editor support Recent support for hex- based layouts from Tiled in KivEnt (Thanks to Google Summer of Code contrib) 5 . 5 Epilogue 6 . 1 Aftermath Kivy makes game development possible and easy. App development in general in Python. Game dev means lots and lots of math and tweaking. Experiment, run, tweak, run, repeat. Use KivEnt for more serious game dev. Cross-platform app / game development possible in Python with Kivy. 6 . 2 Thank you! Twitter - @dorianpula WWW - http://dorianpula.ca/ Doric game engine: https://bitbucket.org/dorianpula/doric-engine/ Kivy: https://kivy.org/ Questions? 7.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    23 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us