[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pygame] Introducing Pyzzle (long)




--- Michael Robin <vimakefile@yahoo.com> wrote:
> >Since I'm new to pygame and game developing I
> thought id ask you how to go
> >about coding Myst style interface. Which really
> just is lots (100s) of pics

Don't forget animation sequences and sounds.

> You could also probably write a hot-spot editor in
> python+tkinter pretty quickly if your up on it.

It seems to me that you could write a hotspot editor
with pygame + pyui fairly easily.  All you actually
need is the ability to represent a series of named
rectangles over top of an image.  Other than that, you
just need a file load/save dialog and a rectangle
function name editor.  You may want a couple of
function names for mouseover and click.

The core of your actual game engine can then be a
mouse-map processor which receives mouse events,
figures out which rectangle they're in and translates
them into appropriate function calls (possibly using
the builtin python function getattr).  By keeping a
library of high-level functions that these game
specific functions & objects can call, you make it
very easy to code.  Some examples:

set_mouse_map(file)
# sets the mouse map that's currently driving the game
draw_image(image_file [, rect] )
# draw an image onto the screen
animation=load_animation(animation_file)
# load an animation sequence from a file
animation.once( [rect] )
# play the animation to completion once
animation.loop( start_stop, [rect] )
# play or stop playing the animation continuously

Lets suppose you have a setting with some doors which
may be opened and walked through and that you have
this python:

door_open=0
open_anim=load_animation("open_door.flc")
close_anim=load_animation("close_door.flc")

def door_switch_click():
    if door_open:
        close_door.once()
    else:
        open_door.once()
    door_open=not door_open

def doorway_click():
    if door_open:
        # proceed to new room
        draw_image("newroom.png")
        set_mouse_map("newroom.map")

Then you'd load the image in your hotspot editor, draw
two rectangles (being the door and the switch) and
label them door_switch_click and doorway_click and
you're done.  The rects and labels (obviously, I
guess) are only seen in the editor.

Finally, it occurs to me that you'll probably want a
couple of higher level constructs which will occur
repeatedly in this type of game:  a Scene, a Button
and a MultiPositionSwitch.

A Scene is a collection of images, animations and
mouse maps that represent a single room or puzzle to
make switching from room to room / puzzle to puzzle
easy.

A Button is a rectangle which, when clicked plays an
animation and calls a function to change the game
state.

A MultiPosition switch is a rectangle which, when
clicked, cycles through a series of possible settings.
 Each setting has a seperate image and optionally a
function to call when that setting is reached.  There
may also be transition animations between consecutive
settings.  Finally, you want to be able to query the
switch setting from other functions to see how it's
set.

Your hotspot editor could be aware of scenes, buttons
and switches with minimal extra effort.

Phew, impromptu brain dump.  Hope it's helpful.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org