How can I create Mario fireballs?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello again.

    I've been trying to create fireballs for around 4 hours today and nothing seems to work.

    What I'm trying to do is when the player presses the 'X' key, a fireball will be launched from the player in the direction that the player is facing.

    The fireball will then fall and bounce up off backdrops and repeat.

    I'm trying to achieve this without using the bouncy ball movement type, as I would prefer to keep it to events for consistency sake.

    I also want there to be acceleration on the gravity for the fireballs for smooth gravity.


    Can somebody please show me the way? :) I know it sounds simple but today I just can't figure anything out. :(

  • If you search in the forum for "Mario like fireball" you can find some discussions about the problem.
    I dont read them very well but I think they used bouncing ball movement that you dont want to use.
    Take a look just to have some ideas.

    Please login to see this link.

  • How familiar are you with basic game physics. Do you have any experience creating custom platform engines?

    I can make an example, but it might be a little more complex than what you're looking for. I don't mind - I can pop some comments in too.

  • How familiar are you with basic game physics. Do you have any experience creating custom platform engines?

    I can make an example, but it might be a little more complex than what you're looking for. I don't mind - I can pop some comments in too.

    I think I'm okay at it. I've created multiple custom platform engines just for the sake of learning using DavidN's FastLoop movement tutorial. While I don't understand it 100% and currently can't remember all the steps to write it on my own without the tutorial, I usually am able to play around with variables and such until I get something I want. Usually :P. And if that's okay, that would be great :)

  • Finally. Sorry for the delay!

    If you have any questions please feel free to ask and I will try to explain the best I can.

    Controls

    Left/Right Change "Character" direction
    Z - Shoot from Character position
    X - Create a bunch of random fireballs
    C - Create a bunch of random fireballs
    Left Click = Create fireball at mouse
    Hold Right Click = Create lots of fireballs at mouse

  • Finally. Sorry for the delay!

    If you have any questions please feel free to ask and I will try to explain the best I can.

    Controls

    Left/Right Change "Character" direction
    Z - Shoot from Character position
    X - Create a bunch of random fireballs
    C - Create a bunch of random fireballs
    Left Click = Create fireball at mouse
    Hold Right Click = Create lots of fireballs at mouse

    Wow that's a pretty great and well made example, thank you!!

    I'm sure it will help lots of people in the future who also are looking for fireball related movement.

    I just took a look through the whole thing and I believe I understand a good bit of it.

    I'll try implementing it to my player as soon as I have time, so I'll be sure to let you know if I run into any problems that maybe you'd know how to deal with.

    Also on line 30, you said "The lines in this group take the place of fast loops. This is much simpler than trying to combine for each loops and fast loops."

    Why is that? I understand FastLoops (although I'm new to them) and I'm in the process of learning ForEach loops, but why can't they be combined easily?

  • Specifically in this example it is because your fireball left/right/up/down sensors are positioned using ForEach loops. Checking for collisions or making movement adjustments during a Fast Loop will NOT guarantee that the FastLoop lines up with the ForEach loop - which would result in your collision sensors not lining up with the fireball that is being moved nearly 100% of the time. You would have to implement a method of checking which fireball is active in the ForEach loop (perhaps making the fastloop run inside it?) and then adjusting the object - which is unnecessary considering you probably won't be working with really high speeds - so it really isn't all that inconvenient or time consuming to copy and paste 4 lines of code 6 times each. You can probably handle that same thing inside of a FastLoop (ie: move the sensors to each fireball and adjust them/check for collisions in the fast loop) - but why would you overcomplicate things like that? At that point you have to do your own object selection. For Each loops handle the object selection for you.

    With that said, having 6 lines of the same code is /nearly/ identical to having a fastloop that runs 6 times. The difference is that a fastloop essentially "pauses" the game in order to complete its loops while having 6 lines of code is just running the same code 6 times within the same event loop. You pretty much get the same end result.

    FYI - You should only ever increase or decrease object positions by 1 pixel at a time when possible. This way you can get pixel-perfect collisions with no overlap by utilizing sensors that are 1 pixel "outside" of the hitbox.

    If you're moving an object 3 pixels per frame in a single line of code your object has the potential to overlap other objects by up to 2 pixels - which would cause your object positioning code to run - which is unnecessary.

    If you increment the object 1 pixel per line, multiple times per frame, the game will check each increment to make sure your collision sensors aren't overlapping anything before increasing the objects position. - This is what the "Easing" group is doing. It moves an object 1 forward a pixel and checks for collisions. If there is no collision it moves it forward 1 more pixel etc. This happens 6 times per frame, since there are 6 lines of code for each direction.

  • Ah, thank you for elaborating.

    I was curious because personally I like to keep short code that's easy to understand and modify. Yes the 6 event lines is as you say is a better method than the FastLoop in this case, but I still prefer keep short code as what I'm working on may be given to a few buddies to take a look at later on. Anyway, I think I'll try out the 6 event idea and if I figure out how I can use FastLoops instead, then I will. Then I'll decide then which one to actually use in the real game :)

    Still working on learning FastLoops in ForEach loops though X)

  • The example posted earlier in the thread seems a bit over-complicated to me. Personally, I find it's quite often easier to actually use the built-in object scoping system to your advantage, instead of trying to fight it using foreach loops etc...
    eg.
    Please login to see this attachment.

  • Your'e sketchy on TDC right? Good to see you're still around :o.

    Your fireballs behave differently when there is more than one.

    See the attached mfa. The only changes I made were moving the player object (to test the issue I found) and increasing the X velocity of the fireballs. Oh yeah "Z" shoots a fireball now, too lol. It seems to be "skipping" collision checks or something when there is more than one fireball.

    These types of subtle issues are a large part of the reason as to why I code things the way I did in the example and always test for scalability.

  • Yep, that's me.
    You mean when there are more than one "player" object shooting fireballs at the same time? That's down to some weirdness with the object creation system not properly scoping newly created objects, and unfortunately does mean that one line needs to be wrapped in a foreach loop (that's the simplest fix at least).
    eg.
    Please login to see this attachment.

    There aren't any issues with collisions being skipped though - even a 1 pixel "fireball" will always collide properly with a wall that is 1 pixel thick, regardless of speed.

  • No only one player object. I believe its registering a collision for both fireballs simultaneously. I didn't check to see if your edit corrected it.

    In the edit I posted there aren't really any changes. If you fire one fireball it ALWAYS takes the same path of travel. If you fire 2 or more they take a different path very consistently (it bounces off of the corner area of the left platform). If you go back down to one it works as normal.

  • Okay so I remembered that I could try to make fireballs using sub-pixel movements that I learned from AlmightyZenTaco's FastLoop tutorial: Please login to see this link.

    I decided that since I'm looking to keep my code as easy for me to read as I possibly can that I would at least see how far I could using his tutorial to make my fireballs and make them with minimal events.

    I managed to make this: Please login to see this link.

    I think it looks great :D

    But standing in certain areas and right against walls does this: Please login to see this link. (they should explode, not be pulled out up and out of the ground.)

    I believe this is because the gravity FastLoop runs before the horizontal FastLoop, so when a fireball spawns they are pushed up out of the ground before they're told to move horizontally.


    When I switch it so the horizontal FastLoop runs BEFORE the gravity FastLoop, this fixes the issue: Please login to see this link.

    But now, this creates another issue and this happens: Please login to see this link. (as we all know, fireballs should bounce when they land, not explode!)

    I believe this is because the horizontal FastLoop runs BEFORE the gravity FastLoop, so they fireballs fall into the ground, and do their horizontal collision check (the horizontal FastLoop) before they decide to start the gravity FastLoop to pull them out.


    How would I go about fixing this? Again I'm not against the methods you've all showed me. I just wanted to see what my own abilities could do after watching that tutorial, and they work almost perfectly with very few events so I thought maybe I should pursue this method. If I can't get things working, I'll study one of the .mfa's you've all shared with me and I will choose which works best for me :)

  • Looking good!

    I guarantee your issue is that you're causing overlap somewhere. Be sure that you're updating your sensor positions at the same time as your fireball positions. Are you sure you're only incrementing fireball position 1 pixel per loop? If so, then there is an extremely high chance that your sensor positions are not updating at the same time as the fireball.

    For example:
    On Loop "Move"
    - Add 1 to X of Fireball
    - Set X Position of Sensor to X of Fireball
    - Set Y Position of Sensor to Y of Fireball
    etc.

    A good way to test would be to make all of your sensors visible and shoot a fireball. Before it hits a ground pause the game in the debugger then step through one frame at a time. If there is any lag between the sensors and fireball it will show up and verify that this is your issue.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!