A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Adventure game look/use

  1. #1
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    Adventure game look/use

    Im almost done with my adventure game engine, unfortunately I just got in a small trouble, in order to keep it simple, my engine automatically chooses if you want to look at, go to, use or open an item, that has been working fine, but Ive run into some items, you want to look and then use.

    How would you guys do that? any ideas are welcome.

    I tried to do renderhjs menu inside an item, but I wasnt able to add a button inside myitem class, how is this done? (sorry if its a newb question, I havent tried to do that before)

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    I tried to do renderhjs menu inside an item
    whats that , at least I did not name that, or did I?

    I would give your system 3 states,
    1. auto (default state)
    2. look/search/inspect (kind of reading label only)
    3. action

    and just like the Maniac Manson games just 2 buttons (look & action) if you click on one it will set the mode to either look or action. If you click again on the button it will set it to the default auto mode.
    And after you executed a action always set the mode again to auto. Wich lets the user always specify if he wants to.

    Maybe give each object credit points or some mechanic that evaluates if inpsecting the object (e.g first meeting with the object) is rather import than doing a action. The action itself however could be more important if you triggered other objects that stand in a sequence with the current one.

  3. #3
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409
    whats that , at least I did not name that, or did I?
    is the best example I could think right now.

    Thanks Renderhjs those are good ideas actually I think the one about doing one action checking a flag then triggering the other could work.

    Er.. I dont suppose you could share some info on how you managed to get the menu inside your items in your portfolio work right? anyway the thing that is bothering me is that a button inside a movieclip (which uses a "item" class) for some reason wont trigger a function from the class. that means I added a button that says "open" to an item mc, then I added this code to it.

    Code:
    on(release){
     trace ("opening")
     _parent.open(); //open is a function inside my "item" class
    }
    Its showing "opening" in the trace window, but it wont run the "open" method.

  4. #4
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    have you thought about using xml for the objects? - thats how I did it a central xml file that lists the objects with ids, attributes and commands. That way you can place objects in your level with just the ids and let a function fetch all other attributes that belong ot that id from the xml file.

    the pro is that you can easily edit the xml database without editing code- wich is great for text heavy games such as adventures where descriptions and other text elements do matter. You could even add a dual language in the xml file (wich is something I did in the past - adventure website with 5 languages).

    Ill give you a look at my xml file to inspire you by chance:
    PHP Code:
    <objects prefix_ico="inv/">
        <
    o id="coke" ico="coke_can.gif" space="1*2" sprite="inv/coke_can.gif" n="coke" desc="coke can from the supermarket">
            <
    opt if="$inv.coke_inv!=undefined" label="pick up" >
                <do do=
    "$inv_add:coke_inv"/>
                <do do=
    "rem_sprite()"/>
            </
    opt>
            <
    opt if="" label="drink" />
            <
    opt if="" label="destroy" />
            <do do=
    "rem_sprite()"/>
        </
    o>
        <
    o id="wending" n="wending machine" desc="wending machine, offering drinks and food">
            <
    opt label="buy 1x chips, 5 cents" >
                <do if=
    "$obj.money>4" do="$obj.money-=5">
                    <do do=
    "$inv.chips+=1"/>
                </do>
                <do if=
    "$inv.chips>4" do="msg:dont you think I have enough?"/>
            </
    opt>
            <
    opt if="" label="buy 1x coke, 1 cents" />
            <
    opt if="" label="buy 1x juice, 1 cents" />
            <
    opt if="" label="buy 1x coffee, 2 cents" />
            
        </
    o>
        <
    o id="lamp1" btn="50,44,0,-26" sprite="levels/_sprites/lighter_ceil_black.swf" n="ceil lamp" desc="lamp on the ceiling">
            <
    opt if="" label="look at" />
        </
    o>
        <
    o id="lamp2" btn="24,80,0,20" sprite="levels/_sprites/lamp1.swf" n="flooter" desc="art deco lamp">
            <
    opt if="" label="look at" />
        </
    o>
        
        
        
        <
    o id="rope" ico="rope.gif" space="1*3" sprite="inv/rope.gif" n="rope" desc="bunch of rope">
            <
    opt if="" label="make knot" />
            <
    opt if="" label="pick up" />
            <
    opt if="" label="play lasso" />
        </
    o>
        <
    o id="bin" btn="24,56,0,0" sprite="levels/_sprites/trash_bin.swf" n="bin" desc="trash bin...">
            <
    opt if="" label="check inside" />
            <
    opt if="" label="kick bin" />
        </
    o>
        <
    o id="bepin" btn="60,50,0,-10" ico="" sprite="levels/_sprites/bepin.swf" n="wash basin" desc="wash basin to clean my hands">
            <
    opt if="" label="wash hands" />
            <
    opt if="" label="pick up soap" />
        </
    o>
        <
    o id="toilet" btn="60,86,0,-4" ico="" sprite="levels/_sprites/toilet.swf" n="toilet" desc="toilet">
            <
    opt if="" label="pee" />
            <
    opt if="" label="drop a bomb" />
            <
    opt if="" label="flush" />
        </
    o>
        <
    o id="plant1" btn="30,180,4,8" sprite="levels/_sprites/plant_2.swf" n="plant" desc="big plant">
            <
    opt if="" label="take a leaf" />
            <
    opt if="" label="bend a branch" />
            <
    opt if="" label="move plant" />
        </
    o>
        <
    o id="plant2" btn="30,88,-2,8" ico="" sprite="levels/_sprites/plant_3.swf" n="plant" desc="decoration plant">
            <
    opt if="" label="take a leaf" />
            <
    opt if="" label="bend a branch" />
            <
    opt if="" label="move plant" />
        </
    o>
        <
    o id="plant3" btn="30,88,-2,8" ico="" sprite="levels/_sprites/plant_4.swf" n="plant" desc="decoration plant">
            <
    opt if="" label="take a leaf" />
            <
    opt if="" label="bend a branch" />
            <
    opt if="" label="move plant" />
        </
    o>
        <
    o id="bench1" btn="96,70,0,0" sprite="levels/_sprites/bank2.swf" n="bench" desc="red bench">
            <
    opt if="" label="take a nap" />
            <
    opt if="" label="sit down" />
        </
    o>
        <
    o id="angel" btn="40,190,0,0" sprite="levels/_sprites/angel_sprite.swf" n="statue" desc="big angel statue">
            <
    opt if="" label="look at" />
            <
    opt if="" label="move it" />
        </
    o>
        <!--   --------------------------------------------------------------------        -->
        <
    o id="knight" btn="40,120,0,0" sprite="levels/_sprites/knight.swf" n="Dark Knight" desc="Knight Armor">
            <
    opt if="" label="look at" />
            <
    opt if="" label="move it" />
        </
    o>
        <
    o id="table_a" btn="60,40,0,0" sprite="levels/_sprites/table_a.swf" n="Desk" desc="little desk">
            <
    opt if="" label="open" />
        </
    o>
        <
    o id="kermin" btn="110,70,0,0" sprite="levels/_sprites/kermin.swf" n="K" desc="K">
            <
    opt if="" label="make a fire" />
        </
    o>
        <
    o id="chair1" btn="70,60,0,0" sprite="levels/_sprites/chair_a.swf" n="Chair" desc="comfortable chair">
            <
    opt if="" label="have a seat" />
        </
    o>
        <!--   --------------------------------------------------------------------        -->
        
        <
    o id="coffee" btn="18,24" ico="coffee.gif" space="1*2" sprite="inv/coffee.gif" n="coffee" desc="a cup of coffee">
            <
    opt if="" label="pick up" />
            <
    opt if="" label="look at" />
        </
    o>
        
        <
    o id="tpaper" btn="18,24,0,-10" ico="tpaper.gif" space="2*2" sprite="inv/tpaper.gif" n="toilet paper" desc="toilet paper roll">
            <
    opt if="" label="pick up" />
            <
    opt if="" label="look at" />
        </
    o>
        <
    o id="coin" btn="14,10" ico="coin.gif" space="1*1" sprite="inv/coin.gif" n="coin" desc="1 cent">
            <
    opt if="" label="pick up" />
            <
    opt if="" label="look at" />
            <
    opt if="" label="play with" />
        </
    o>
        
        <
    o id="big key" ico="key_1.gif" sprite="inv/key_1.gif" space="1*3" n="key" desc="a big key">
            <
    opt if="" label="pick up" />
            <
    opt if="" label="look at" />
        </
    o>
        <
    o id="smal key" ico="smal_key.gif" space="1*2" n="key" desc="">
            <
    opt if="" label="pick up" />
        </
    o>
        <
    o id="zippo" ico="zippo.gif" space="1*1" n="lighter" desc="a firelighter">
            <
    opt if="" label="lighten" />
            <
    opt if="" label="smoke a cigarette" />
            <
    opt if="" label="pick up" />
        </
    o>
        <
    o id="snickers" ico="snickers.gif" space="2*1" n="snickers" desc="soap from the toilet room">
            <
    opt if="" label="eat" />
            <
    opt if="" label="pick up" />
        </
    o>
        <
    o id="spray" ico="spray.gif" space="1*3" n="spray" desc="soap from the toilet room">
            <
    opt if="" label="pick up" />
            <
    opt if="" label="spray hair" />
        </
    o>
        <
    o id="md" ico="minidisc.gif" space="2*2" n="minidisc" desc="soap from the toilet room">
            <
    opt if="" label="pick up" />
            <
    opt if="" label="look at" />
        </
    o>
    </
    objects
    though even now its not final but it has the very important id- attribute (wich is used in my map to place objects) and others (wich are not even final as of today) like:
    - space = required space in inventory (w*h)
    - sprite = wich sprite to display
    - n = name (what appears ontop of the info boxes or interface
    - desc = description for info box
    then I used sub- nodes like <opt if="" label="drink" /> for the list of actions.
    I am not done with it but I planned on storing dynamic variables that arent stored at all in AS but rather through the xml attributes.

    of course youd need to load the xml before the game starts but then also only once as it would store all objects gloabl in the xml file.


    about the buttons or GUI you saw its all coded so it relies purely on drawingAPI and dynamic textfields. Esspecially the dynamic textfields are very important as it lets you define a textfield with the property .autosize = true; wich then lets you check the required textspace and thus build the buttons underneath it ect.
    Even the buttons are createEmptyMovieClip(); with drawing api and hovering is done using my custom tween set.
    once you created a emptyMovieClip and used the drawinApi to render the button you can add:
    PHP Code:
    createdMc.useHandCursor false;
    createdMc.onRollOver = function(){
        
    //
    }
    createdMc.onPress = function(){
        
    //

    hope that is some insigjt for you, if you need a little help with the xml stuff ask me

  5. #5
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409
    Thanks! that did helped a lot, I just implemented a better formatted xml type for my item with options and is working like a charm!

    Thank you very much!

  6. #6
    Truimagz.com everfornever's Avatar
    Join Date
    Sep 2006
    Location
    St. Louis
    Posts
    1,306
    nvm, I miss read somethig

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center