Source

fungus / How_to_build_a_fungus_scene.txt

How to build a fungus_scene
===========================

Basic usage
-----------

Building a basic fungus scene is pretty straightforward. 


1. Have a look at fungus_scene.py. It has an example DummyScene which you can use as template for your own scenes. 


2. Start a new Python gamefile for your own Scene (suffix: .py). 


3. Import BaseScene from fungus_scene and add a Scene class which inherits from BaseScene. Your Scene has to take the core as first argument and init its ancestor (BaseScene). 

--- !python
from fungus_scene import BaseScene

class Scene(BaseScene): 
    def __init__(self, core, *args, **kwds): 
        super(Scene, self).__init__(core, *args, **kwds)
...

The core object gives you some useful functions to make scene creation easier. It's defined in fungus_core.py . 


4. Add Stuff to your scene, for example via self.sprite = self.core.sprite(IMAGE_SRC). 

You can show a sprite by adding it to the self.visible list of your scene via "self.visible.append(sprite)". You get the visible list from the BaseScene, so your scene already has it. 


5. You can switch to another scene by importing and initiating it and then setting self.switch_scene = new_scene in your current scene. For example via 

--- !python
        # somewhere in your current scene
        new_scene = NewScene()
        self.switch_scene = new_scene
...


6. Test your scene. You can evoke it via 
python fungus_game.py gamefile.Scene

gamefile is the name of your file without the .py extension. Scene is the name of your Scene (can be anything, as long as it starts with a normal letter - no numbers as first letter, though). 

7. Have fun!