Forum Archive

Character Selection using the Scene Module

techteej

I would like to build a Character Selection scene with the scene module using images saved to the device, but I'm not quite sure how exactly to start it. Any help would be appreciated.

ccc

draggableImages.py https://gist.github.com/cclauss/5380169 or ImageCongaLine.py https://gist.github.com/cclauss/6414599 might help ( make sure you are not in a folder when running the second).

techteej

Here's what I have so far. It has some errors that I'm not quite sure how to work through.

from scene import *

class bug_rect (object):
        rect(50, 350, 260, 260)

class key_rect (object):
        rect(405, 350, 260, 260)

class MyScene (Scene):
    def setup(self):
        center = self.bounds.center()

    def draw(self):
        background(0.40, 0.80, 1.00) 
        fill(0.00, 0.50, 1.00)
        image('PC_Enemy_Bug', 55, 350, 250, 250)
        image('PC_Key', 405, 350, 250, 250)

        fill(1, 0, 0)
        for touch in bug_rect():
            rect(touch.location.x - 50, touch.location.y - 50, 100, 100)
        for touch in key_rect():
            rect(touch.location.x - 50, touch.location.y - 50, 100, 100)

    def touch_began(self, touch):
        pass

    def touch_moved(self, touch):
        pass

    def touch_ended(self, touch):
        pass

run(MyScene())
ccc
import scene, sound, time

bug_rect = scene.Rect(50, 350, 260, 260)
key_rect = scene.Rect(405, 350, 260, 260)

def play_notes(in_notes):
    if isinstance(in_notes, str):
        in_notes = in_notes.split()
    for note in in_notes:
        sound.play_effect('Piano_' + note)
        time.sleep(0.5)

class MyScene(scene.Scene):
    def __init__(self):
        scene.run(self)

    def setup(self):
        center = self.bounds.center()

    def draw(self):
        scene.background(0.40, 0.80, 1.00) 
        scene.fill(0.00, 0.50, 1.00)
        scene.image('PC_Enemy_Bug', *bug_rect)
        scene.image('PC_Key', *key_rect)
        scene.fill(1, 0, 0)

    def touch_began(self, touch):
        if touch.location in bug_rect:
            play_notes('C3 D3 E3 C3')
        elif touch.location in key_rect:
            play_notes('E3 D3 C3 E3')

    def touch_moved(self, touch):
        pass

    def touch_ended(self, touch):
        pass

MyScene()
techteej

I'm having a little trouble implementing it into the game.