User Tag List

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

Thread: Set Initial Direction based on conditions

  1. #1
    Clicker Fusion 2.5

    Join Date
    Aug 2014
    Location
    Hawaii
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Set Initial Direction based on conditions

    Hey CT forum,

    So I'm going slow, just started, decided to try and make a small "Missile Command" type of game to learn the ins and outs of CTF. So go easy on me, and please be specific, I'm still not comfortable with where / how to do things.

    So I've got it started pretty good, but I'm stuck on something. I have an active object for the (random x coordinate / top of screen) bombs that are spawned every few seconds and I set the initial directions to 20-28 (using the bouncing ball type of movement).

    This works fine, except there are some offscreen paths that are created that I want to fix. For example, if the random x coordinate is 50, and the random initial direction chosen is 20 (7 oclock), the bomb is only on the screen for a second or two while it shoots shortly across the top left corner only.

    So I'd like to say something like:
    "if random x coordinate for the current bomb is < (Frame Width / 2) set bomb initial direction to RRandom(24, 28)
    else set initial direction to RRandom(20,24)"

    Ideas?

    Wiggy

  2. #2
    Clicker Fusion 2.5

    Join Date
    Aug 2014
    Location
    Hawaii
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I guess my first post / question was a doozie as no solution seems to exist.

    I've thought pretty hard about this problem last couple of days, and since there was no solution I've been thinking about a work around. And I've come up with a dog awful kludge... but it will work.
    The problem is it causes twice as much of everything...objects, collision detection, destroys, sounds, timing... its really awful, so if anyone can rescue me, please do.

    Here is the tedious work around:
    I'm going to clone the active object missile into left_missile and right_missile. The left_missile will be recoded to have a created location of RRandom(0, width/2) and the right_missile will have a created location of RRandom(width/2, width), then all the object creations duplicated, sound effects duplicated, collision detections duplicated, etc..

    Like I said, please let me know if I'm missing something here or if there is any easier work around. Because my solution feels like I'm creating a tank to shoot a paper target.

    Wiggy

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Hello and welcome

    if random x coordinate for the current bomb is < (Frame Width / 2) set bomb initial direction to RRandom(24, 28)
    else set initial direction to RRandom(20,24)
    this is surely doable, if this may solve your issue:

    i.e.
    name a global value "bomb_X" and set it to "-1"
    then add these actions:

    every 1 second (or whatever)
    >>> set global value "bomb_X" to random(frame width)

    global value "bomb_X" < (Frame Width / 2)
    global value "bomb_X" <> -1
    >>> create bomb at 0,0
    >>> set X position of bomb to "bomb_X"
    >>> set initial direction to RRandom(24,28)
    >>> set "bomb_X" to "-1"

    global value "bomb_X" >= (Frame Width / 2)
    global value "bomb_X" <> -1
    >>> create bomb at 0,0
    >>> set X position of bomb to "bomb_X"
    >>> set initial direction to RRandom(20,24)
    >>> set "bomb_X" to "-1"

  4. #4
    Clicker Fusion 2.5

    Join Date
    Aug 2014
    Location
    Hawaii
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Hey schrodinger, thanks for replying

    I've been trying to figure out this one part without asking as the first line was easy of course, making the global variable bomb_x and initializing it to -1. But I've given up, haha, so please explain. This is where I'm stuck:

    global value "bomb_X" < (Frame Width / 2)
    global value "bomb_X" <> -1
    >>> create bomb at 0,0
    >>> set X position of bomb to "bomb_X"
    >>> set initial direction to RRandom(24,28)
    >>> set "bomb_X" to "-1"
    So this is how I read that:
    First two lines are just information, showing me what that section of code is for...correct?
    Third line, set up a frame event to create a bomb at 0,0 (I just assumed layer 1)....done...correct?
    Fourth line, set up a frame event to make the X position of the bomb to "bomb_X"....done
    ...Then we get to fifth line, set initial direction... This is where I'm stuck.

    I added a second event on the bomb object after the X position is set. I did the following:
    right clicked -> Direction --> Set Direction --> 1+1 button --> RRandom(24,28)
    Then it dawned on me... how does it know only to do this for the missiles that spawn on the first half of the screen (how does it compare it)? I wasn't able to continue to the next section of your code since it will just overwrite what I had done in this section.

    So somewhere I missed how that comparison is done. It looks like that is what line 1 is doing but I don't know where / how to implement that into the Event Editor.

    Please explain, I'm just not getting it, lol

    Thanks!
    Wiggy

  5. #5
    Clicker Fusion 2.5

    Join Date
    Aug 2014
    Location
    Hawaii
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wait... I think I see what you are saying.

    I started messing with the Special Conditions on the Event Editor. I clicked to create a new condition...omg, "condition", this is where "if / else" are put!!! It is logically saying "if this condition is true then do whatever is specified to the right... ...light bulb!

    So I looked back at your code, and I input the "condition" which I assumed is a logical "AND" by default:
    global value "bomb_X" < (Frame Width / 2)
    global value "bomb_X" <> -1

    Then coded the events for:
    >>> create bomb at 0,0
    >>> set X position of bomb to "bomb_X"
    >>> set initial direction to RRandom(24,28)
    >>> set "bomb_X" to "-1"

    Then did likewise for the other condition.

    I was excited until I executed the code with a quick F8. The bombs are now being created and starting down a path that looks promising... but then they are being destroyed or hidden, I really don't know (about every 8th bomb or so). And sometimes (about every 20 seconds or so) 5-7 bombs spawn at once (all with the same RRandom initial direction array of values)...

    I only have 8 conditions, 2 of which are the new ones I just added from your post, so I'm not sure why the new behavior.
    Anyway, was I on the right track, or did I miss something?

    Thanks again!

    Wiggy

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Hello Wiggy,

    I think you're on the right track
    but it's hard to tell what could be wrong without seeing the .mfa

    I made a quick example with the system stated above, hope it helps:
    bomb.mfa

    to have a full undersanding of events logic/succession,
    I suggest using both event and "event list" editor,
    this will show how events and actions follow each other in sequence

  7. #7
    Clicker Fusion 2.5

    Join Date
    Aug 2014
    Location
    Hawaii
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, very interesting...

    The events were fine actually..but when I went to the "Event List Editor" like you said, I noticed the order of my events were very different than what you had.
    Example, the setting of the global value was first instead of last on the condition for "bomb_x > Frame Width / 2". And it was last on the other condition for "bomb_x <= Frame Width / 2". Obviously that is a problem, they both should be set to occur last. The other position of x, and set directions were different as well.

    So I'm happy that its fixed, thank you by the way! But now I'm concerned. I coded this correctly (after your first reply), but still didn't work because Event Editor List was not the same as yours. So how do I read / use the Event Editor? It doesn't seem to be sequential. I assumed incorrectly that the Event Editor and Event List Editor were just two views of the same conditions.

    Any tutorials / stickys on the differences and how to use them? Otherwise, later on, when I get into more advanced games, it will be critical to be able to read / use both.

    Thanks!

    Wiggy

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,369
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Hi Wiggy.
    You were correct in assuming that the Event Editor and the Event List Editor are two views of the same conditions. However, the Event Editor doesn't show the order of the actions. If you double click on an event row (a cell) in the Event Editor, the Action editor will open and you'll see the order of the actions for that event. You can move them around to change the order. The Event List Editor is a combo of those two, allowing you to see all the events and actions in the order they are executed.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by wiggy View Post
    Example, the setting of the global value was first instead of last on the condition for "bomb_x > Frame Width / 2". And it was last on the other condition for "bomb_x <= Frame Width / 2". Obviously that is a problem, they both should be set to occur last.

    (...)

    I coded this correctly (after your first reply), but still didn't work because Event Editor List was not the same as yours. So how do I read / use the Event Editor? It doesn't seem to be sequential. I assumed incorrectly that the Event Editor and Event List Editor were just two views of the same conditions.
    This is (to me) the "top" key-feature of Fusion that is not pointed out enough, and not so obvious to grasp in the beginning,
    because of the event editor grid being so comfortable and feeling so natural to use (now oddly I almost don't use it at all!)

    As Popcorn pointed out, they're both a view of the same events,
    but in the event editor you can't see the order of the actions performed (unless accessing each single cell).

    So, since (most) events are checked top to bottom,
    and since actions follows the same rule,
    you have to take into account what happens before, and what happens after, to have full control of results.

    i.e. in our bomb example:

    >>> create bomb at 0,0
    >>> set X position of bomb to "bomb_X"
    >>> set initial direction to RRandom(24,28)
    >>> set "bomb_X" to "-1"

    If you were to push last action to be performed first:

    >>> set "bomb_X" to "-1"
    >>> create bomb at 0,0
    >>> set X position of bomb to "bomb_X"
    >>> set initial direction to RRandom(24,28)

    the ---set X position of bomb to "bomb_X"--- would have set the position of the bomb to "-1", because it was reinitialized just one action before!
    Thus resulting in bombs disappering (positioned at X: -1)

    Hope this info can be useful

  10. #10
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export Module
    Emerson3's Avatar
    Join Date
    Apr 2014
    Location
    Lafayette, Louisiana
    Posts
    721
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Wow Schro and Popcorn!

    Can you create events and conditions from the Event List?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Click Ball Movement - Initial direction when created?
    By ratty in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 16th June 2013, 04:58 PM
  2. INI initial save and IOS
    By GameMaker2019 in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 18th February 2013, 09:34 AM
  3. Toggling flags based on multiple conditions...
    By OlivettiFever in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th December 2012, 01:19 AM
  4. Global Value initial value with ini
    By ratty in forum iOS Export Module Version 2.0
    Replies: 3
    Last Post: 2nd July 2012, 08:07 PM
  5. Replies: 2
    Last Post: 22nd December 2010, 10:05 AM

Posting Permissions

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