1. Arne Babenhauserheide
  2. fungus


fungus / How_to_build_a_fungus_scene.txt

The default branch has multiple heads

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 within the fungus folder for your own Scene: 
- suffix: .py
- first line: #!/usr/bin/env python

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 

--- !python
        # somewhere in your Scene
	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 Scene
	from new_scene import NewScene
        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. Make the Scene clickable by adding four lines at the beginning of your scene file: 
--- !python
if __name__ == "__main__": 
    from fungus_core import call_this_scene
    from sys import argv
    call_this_scene(__file__, argv)

8. Have fun!