Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Kivy Blueprints

You're reading from   Kivy Blueprints Build your very own app-store-ready, multi-touch games and applications with Kivy!

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher Packt
ISBN-13 9781783987849
Length 282 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Introducing Kivy Bird


Next on our list is the playable character, that is, the biologically improbable Kivy Bird:

Rare species, the Kivy Bird sprite

There will be nothing fancy related to textures this time; in fact, the Bird class will be derived from Kivy's Image widget (kivy.uix.image.Image) to completely avoid doing any clever rendering whatsoever.

In kivybird.kv we need a bare minimum of properties involving the bird image depicted earlier; its initial position and size are given as follows:

Bird:
    id: bird
    pos_hint: {'center_x': 0.3333, 'center_y': 0.6}
    size: (54, 54)
    size_hint: (None, None)
    source: 'bird.png'

This is the initial implementation of the Bird class in Python:

from kivy.uix.image import Image as ImageWidget

class Bird(ImageWidget):
    pass

Yup, it does nothing at all. Soon, we're going to spoil it by adding rudimentary physics and other things, but first we need to lay some groundwork in the application class in order to make the game stateful.

Revised application...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image