User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Item/Object 'Collected'

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Item/Object 'Collected'

    Okay, say for example, You only have ONE item in your objects inventory list ([I]: Item)
    You place a few of these objects on the stage.

    When you first enter the stage, it looks like this as you placed them.
    ___I___I___I___


    You collect one of the items shown here, looks like this.
    ___I_______I___


    - Level/Frame restarted -
    When you die, or restart the level (Type of condition/event: -> Restart frame). The item you collected should not return again, like so.
    ___I_______I___


    How do I go about doing this?

  2. #2
    mojofltr
    Guest

    Re: Item/Object 'Collected'

    You could probably do it by setting a global value.

    or...

    Instead of restarting the frame, you could just respawn your character at the start and tell your program to take one away from the life bar.

    //Edit//

    Here is an example I made up using Global & Alterable Strings. There are better ways (and probably easier ways) to do it, but it might give you an idea of how you might like to implement it yourself.

    http://www.mediafire.com/download.php?xdtmwynyynf

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Item/Object 'Collected'

    Do you think Spread value would work here as well? o_O
    Or would that just confuse the items in frame when the spread value always gets fixed when restarting the level?

    Also, I don't think just "repositioning" the player back at start will work. When I mean 'restart frame', I want to to go back as far as the level fading out, fading back in, then saying "Ready". Ya know the drill.


    EDIT: Okay, I tried your example. Seems to look pretty good, but I don't understand the code. X_X
    What's all this with the Str$( Str$(Y)? Some sort of string script? I thought strings were text based events?

  4. #4
    mojofltr
    Guest

    Re: Item/Object 'Collected'

    My experience with spread values is minimal... I would imagine it is possible, but you would still need to use a global value or string so that it will be stored when the level is reset.

    I used strings instead of values, because I tend to need values more for other functions... and feel it is crazy to waste them... I don't use strings too much. Hopefully I can explain it so that it makes sense.

    In my example, I set it that an objects position values are stored in a global string as an object is picked up - and then I destroy it.

    Breaking down the code:

    Set Global String (NObjects("star")) to Str$(X("Star"))+" , " + Str$(Y("Star"))

    /// Set Global String (NObjects("star)) ///

    Picks the name of the global string by the number of stars. Once a star is picked up (and destroyed), the number changes... so it will not store the same string twice.

    /// Str$(X("Star"))+" , " + Str$(Y("Star")) ///

    Sets the string to the String name of the star's x position SPACE COMMA SPACE and the string of the star's y position. So it ends up looking something like this:

    300 , 65

    I could have used values, but again, I hate to waste them.

    Each star is set to always have an Alterable String A containing it's position... using the same string format. This will allow us to compare the strings later.

    An Always event adds 1 to Global Value A (this could have been set as an alterable value, timer, whatever...) and another event instructs MMF to set Global Value A to 0 when it is higher than the number of star objects. In my example, it counts 0,1,2,3,0,1,2,3...

    Finally the magical event that makes it happen:

    Alterable String A of (Star) = Global String (Global Value A)
    ... Destroy Star

    Again, each star has an alterable String A with it's coordinates. When a star is destroyed, these coordinates are stored in a global string. So what this even does is sifts through each of the Global Strings stored and compares them to the Alterable Strings stored in each star object. When there is a match, it destroys the star.

    I set up an extra event that hides the star at the start of the frame until this process is finished (see line 13). If that line is removed, you will see that the stars actually are present when the game resets, but are quickly destroyed when the strings are compared.

    Long-winded, I'm sure... but I hope it clears things up a bit...?

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Item/Object 'Collected'

    So, as long as global values are used, the code should work with other values? In other words, can I replace your whatever Str$ with value of something else?

    Sorry, just that I'm not really familiar with using those extra Str$ areas yet. @_@


  6. #6
    mojofltr
    Guest

    Re: Item/Object 'Collected'

    Here is an example that doesn't use strings...

    Well, there is a string in there, but it wouldn't need to be in your code... it is only there to illustrate what I've found concerning spread values. The source is fully commented, so I won't explain it here.

    //edit//

    Oops, found a bug. I'll repost when I get it worked out.

    //edit 2//

    Found it. Apparently, setting a spread value from 0 was the problem. The counter used to destroy objects at the beginning of the screen was not hitting 0, so one object would never be destroyed, regardless of whether a value had been set.

    Here is the updated source:

    http://www.mediafire.com/download.php?luubzdq5fjn

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Item/Object 'Collected'

    I hate to argue, but why is there a delay for when they appear? Your first example didn't have this delay, if memory serves. I checked the code and I didn't see anything that would relate to time based events. I guess that counter you have there checks if a certain value of the object is different and destroys it? I'm not sure.

    Seems so many ways of doing this. Though whatever method you use, global value has to be used in this case? Makes sense, I suppose.

  8. #8
    mojofltr
    Guest

    Re: Item/Object 'Collected'

    The first actually did have a delay... it was just not as long because I was only checking 3 stars.

    If you put the event in a fastloop, you could probably minimize or eliminate the delay altogether.

    //edit//

    Here's a quick modification where the check is done in a fastloop. This eliminates any delay:

    http://www.mediafire.com/download.php?znwxw0jdzjx

    ...

    I need to take the time and work out how to use the array object. I suspect it would be a much better way of handling this sort of thing... without wasting all those precious global values.

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Item/Object 'Collected'

    Interesting.... When I moved your "start of frame: start fast loop" from the bottom, all the way at the top, it freezes the application. Maybe this is a MMF2 bug that Clickteam needs to investigate?
    Or is this an error in the creators script that makes it freeze because the fast loop event is positioned in the wrong place? I didn't know there was a difference between putting the start fast loop on the bottom or the top.

    EDIT: Actually, on further investigation, I created my own simple fastloop counter thing, and see what the problem was. I made the start fast loop on the top, and the 'on loop' at the bottom of the event, and it seemed to work fine, no freeze.
    So maybe the freeze is a glitch in your collected items code if I move the start loop at the top?

  10. #10
    mojofltr
    Guest

    Re: Item/Object 'Collected'

    Event order does matter. When you put that event at the very top of the event list, the maximum value of the counter has not been set yet when the loop is started. I do that line 2 of the unmodified code. So this seemingly simple modification tells the program to run the loop 999999999 times (this is the default max value of a counter) rather than the 25 times it would have been if the counter had been set by the event. That is why it freezes.

    LOL! So we used a fast loop to eliminate the delay and created a huge delay. I'm not sure you want to wait each time for that loop to complete - haha!

    I just checked to verify... and moving the event up the list, but still underneath the event where the counter is set will work. You can even combine it with the event that sets the counter as long as it is underneath the counter setting event on the list.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. pick up item
    By gamebuilder in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 18th June 2012, 11:31 PM
  2. Why does "Create Object" make multiples instead of one item
    By rubes in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 5th May 2012, 11:01 PM
  3. Get item name with ini++
    By MikeB in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th June 2009, 09:02 PM
  4. Compare Ini Item to Value
    By Gerblegod7 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 3rd March 2007, 04:26 PM

Posting Permissions

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