Archive for rant

Adventures in Kivy

Posted in How To, Programming, Rant with tags , , , , , , on 2012/03/22 by Adam Griffiths

So here is a semi-live blog as I delve into Kivy.

Mission #1: Attempt to resize the default window

Ok let’s start at the start.

We first create an object that inherits from App. Done.

Ok, and the examples all return a widget from the App’s build() method. So we don’t over-ride __init__… ok… thats… unique.

Perhaps the widget is the window if it is returned from the build() method?

Widget is not the window. Widget returned from build() is added to the window. So… where is the window created?

Window docs state the window has a constructor that lets you set the window size. Ok, cool. But we don’t create the window… so.. we can’t use the constructor… sigh.

Ok, Window has a static accessor.

kivy.core.window.Window = None

No comment on what is stored here but I assume it’s the instantiated window. It doesn’t mention when it is set… handy!

Only 1 window allowed. Ok… weird. Well… let’s try that.

import kivy.core.window.Window
AttributeError: 'module' object has no attribute 'window'

Awesome…

Let’s scour the code.

Screen capture of Kivy window module

No Window.py file……… how far does this rabbit hole go.

Ok, let’s check out the __init__.py file in the window module.

class WindowBase(EventDispatcher):
 '''WindowBase is a abstract window widget, for any window implementation.

So… window base is in there. Feel free to scream now.

So we can get this by importing kivy.core.window and just leaving the class off the end.

import kivy.core.window
...
def build(self):
    print kivy.core.window.Window.size
    return None
(800, 600)

Ok sweet, thats our window.

So let’s change its size.

def build(self):
    print kivy.core.window.Window.size
    kivy.core.window.Window.size = (1024, 768)
    print kivy.core.window.Window.size
    return None
File "/Users/adamgriffiths/Workspace/VirtualEnvs/progress_quest/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 243, in _set_size
 if super(WindowBase, self)._set_size(size):
 AttributeError: 'super' object has no attribute '_set_size'

FFFFFFFUUUUUUUUUUU

Ok, so after some googling we find this post about the relationship between the App and Window classes.

His solution is to pass the size as a command line parameter……….. LAME. That kinda throws the whole configuration settings thing out the window.

Looking through the Kivy code we find this block inside their base window class’ __init__ method.

if 'fullscreen' not in kwargs:
    fullscreen = Config.get('graphics', 'fullscreen')
        if fullscreen not in ('auto', 'fake'):
        fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup')
    kwargs['fullscreen'] = fullscreen
if 'width' not in kwargs:
    kwargs['width'] = Config.getint('graphics', 'width')
if 'height' not in kwargs:
    kwargs['height'] = Config.getint('graphics', 'height')

Ok, so we can try and set it via the global config object.

So let’s add that to our App class.

def build_config(self, config):
    config.adddefaultsection('graphics')
    config.setdefault('graphics', 'width', 1024)
    config.setdefault('graphics', 'height', 768)
    config.set('graphics', 'height', 1024)
    config.set('graphics', 'width', 768)

Run the code and……

(800, 600)

……. sigh

So let’s put some debug INSIDE kivy and see what is happening. We’ll also force it to pull the ‘graphics’ setting and ignore kwargs.

if True: #'width' not in kwargs:
    kwargs['width'] = Config.getint('graphics', 'width')
print kwargs['width']
if True: #'height' not in kwargs:
    kwargs['height'] = Config.getint('graphics', 'height')
print kwargs['height']

And the output…

800
600

…. calm blue ocean…. calm blue ocean….

Ok… google…

Hmm.. ok, this post on the kivy-users forum (because documentation is for lusers) shows a similar method.

They use the Config module directly instead of the config object passed to App….. because….. they’re not the same? Well.. let’s try it anyway.

from kivy.config import Config
Config.set('graphics', 'width', 1024)
Config.set('graphics', 'height', 768)

And our output

(800, 600)

Ok, weird because the window HAS ACTUALLY CHANGED SIZE.

Whatever. We’re all living in crazy-ville atm so let’s just pretend everything is normal.

So let’s move that inside our build_config() method.

def build_config(self, config):
    Config.set('graphics', 'height', 1024)
    Config.set('graphics', 'width', 768)

And the output

[INFO ] Kivy v1.1.1
[INFO ] [Logger ] Record log in /Users/adamgriffiths/.kivy/logs/kivy_12-03-22_40.txt
[INFO ] [Factory ] 102 symbols loaded
[INFO ] [Text ] using <pygame> as text provider
[INFO ] [Loader ] using <pygame> as thread loader
[INFO ] [Window ] using <pygame> as window provider
[WARNING] [Window ] Unable to use <pygame> as windowprovider
[CRITICAL] [Window ] Unable to find any valuable Window provider at all!
Fatal Python error: (pygame parachute) Segmentation Fault
Abort trap: 6

(╯°□°)╯︵ ┻━┻

How many times do we have to say it?

Posted in Games Industry, Rant, Uncategorized with tags , , , , , , on 2011/04/13 by Adam Griffiths

DRM doesn’t fucking work!

Absolute power corrupts

Posted in Games Industry, Rant, Uncategorized with tags , , , , on 2011/04/12 by Adam Griffiths

Steam

I love Steam. Having a social gaming network with constant access to a game market place where the prices are truly fluid is brilliant. But the thought of something like this happening is always in the back of my mind, and it scares the shit out of me.

I’ve seen posts before of people having an account for each game they have. That way if an account is banned or VAC banned, their other games aren’t affected.

You also get around VAC banning you from all games that use that engine. Ie. a VAC ban in HL2 will ban you from all games that use the Source engine: L4D, CS:S, etc.

 

Also, PayPal sucks. Please avoid using it where possible.

Back in my day Sonny…

Posted in Rant, Uncategorized with tags , on 2011/04/11 by Adam Griffiths

Police Quest: In Pursuit of the Death Angel

I really miss games like this. This walk through brings back so many memories. It also shows how many things I missed even though I didn’t finish it. Brilliant game, brilliant story. God damnit… I want to play it now!

Make sucks

Posted in Programming, Rant, Uncategorized with tags , , , , , on 2011/04/03 by Adam Griffiths

I used Make extensively at my last job. You know what? Make sucks!

I’ve talked about this on Reddit and the only response I ever got was fan boi’s who have memorised the manual saying “You just need to read the manual! It’s fine!”.

Arbeit GNU Macht frei

Some people just don’t Grok piracy

Posted in Games Industry, Rant, Uncategorized with tags , , , on 2011/04/02 by Adam Griffiths

Same thread, new post. Some people just can’t learn how to break an issue down and look at it objectively.Piracy: Imagine your car gets stolen but it's still there in the morning.

Continue reading

Musings on piracy

Posted in Games Industry, Rant, Uncategorized with tags , , , , on 2011/04/01 by Adam Griffiths

Once again a short rant (not a proper post) I posted on Steam that describes my thoughts on piracy.

You wouldn't download a car? Fuck you, I would if I could!

Post also copied below.

Continue reading

%d bloggers like this: