Couple of questions for Mario game.

This forum is currently in read-only mode.
From the Asset Store
A collection of various characters spritesheets for creating a 2D top down, RPG, tower defense, or other similar game.
  • I�m trying to remake the first level of Super Mario Bros but Ive run in to a few, probably really stupid problems.

    1: Goomba "AI"

    The AI is set up like the picture, and it works great, as long as you only have one enemy. But when the enemy collides with the pipe it changes the value for the object, and not the instance.

    Is it a way around that, or how can I else do the "AI"

    <img src="http://lh5.ggpht.com/JWesstrom/SNTHhZbfbFI/AAAAAAAAAsE/ix-lqvVgWQo/Goomba.jpg">

    2: Headbutting blocks

    I cant really find a good way to make the block move up and down. My first thought was to use a loop, but that didnt really work. My second thought was to animate the sprite, but that sollution is rather cheap. Animating dosent really work with physics either.

    I appriciate all the help I can get.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Image link is broken? I'm not sure I understand exactly what your problem is with the goomba AI... they should be fairly simple to make as they just walk along until they bump into something then turn around and go the other way. I would suggest using ball movement and making invisible detectors where you want the goomba to change direction.

    +Goomba collides with Detector

    • Goomba angle = goomba angle -180�

    As far as the bricks go, I guess there are a few ways you could try. Personally I would do it with animations, because if you do it right it won't look "cheap" at all. Just make sure there are enough frames and it hould look sweet. You could also try making an invisible detector that the brick "rests" on, but doen't affect the player... though you may run into trouble if the brick object is using physics, as it may not bounce straight up and back down to it home position, thus you could end up with some very interesting bricks. O.o

    Perhaps post a .cap file or something if you are still ahving trouble with your goomba... and if I can think of a better way to make the bricks I will put something up here for ya.

    ~Sol

  • Thanks for your reply.

    Goomba Problem

    The thing is that Im using physics for everything (for several reasons).

    <img src="http://i5.photobucket.com/albums/y186/Jawoo/Goomba.jpg">

    Brick problem:

    By cheap I mean the sollution in itself, not the look of it.

    I want it to be kinda like this:

    If Mario overlaps BoxHitDetection
              Box.Y = Box.Y - 20
              Box.Y = Box.Y + 20
    [/code:wiz0g72b]
    
    Now, the obvious problem with doing it like that is that the movement of the box is so fast that you cant see it.
  • Instead of "direction" being set to either 1 or 2, have it set to -1 or 1. That way you can do this:

    +On collision between goomba and pipebottom
       -goomba:Set 'direction' to 0-goomba.Value('direction')
    [/code:3esth2tb]
    
    (That's "zero minus direction.")
    
    Instead of the sub-event with the Else condition you have there.  I can't tell without the .cap, but I suspect that Else might be mucking things up.
    
    As for bricks, I just did a quick mockup where I had two animations for the brick, "Default" and "bump."  For the bump animation I just copied the frame a few times, then lowered the hotspot 2 pixels down on the first frame, 4 pixels down on the second frame, 6 on the 3rd, 4 on the 4th, and 2 on the 5th.  I set the animation to not loop, and 24fps.  It looked fairly close to the original SMB.  You could always tweak it to match perfectly.
    
    [code:3esth2tb]
    +Mario hits brick
       -brick: Set animation to "bump"
       -brick: Set animation frame to 1
       -brick: Play animation
    
    +brick animation "bump" finished
       -brick: Set animation to "Default"
    [/code:3esth2tb]
    
    You could always work in the bump animation as a condition for bopping Goombas from below this way also.
    
    Edit:
    I agree with Sol, if you're still having problems, upload your .cap.  And if you're really using Physics for everything, I wish you luck... you'll need it.  A few people here (myself included) have tried using physics for platformers, and the results are always less than satisfactory.  It's a real pain to work around.
  • Thanks for reply. =)

    Instead of "direction" being set to either 1 or 2, have it set to -1 or 1. That way you can do this:

    > +On collision between goomba and pipebottom
       -goomba:Set 'direction' to 0-goomba.Value('direction')
    [/code:upez4qet]
    
    (That's "zero minus direction.")
    
    

    Thats pretty clever. Still dosent work when having more than one Gomba though. Is it even possible to have diffrent private variables for instances?

    About the brick:

    I know how to do it with animation, that was really never the problem. The problem is doing it without animation.

  • Thats pretty clever. Still dosent work when having more than one Gomba though. Is it even possible to have diffrent private variables for instances?

    Yes it is. There must be something else going on with your events. Upload your .cap.

    Edit:

    As for the bricks, you could run a routine that changes it's y pos over time up a few pixels, then down a few pixels, but you won't be able to make any simpler event system than if you just do it with animations.

  • cap. http://www.fileshack.us/get_file.php?id ... =Mario.cap

    How would such a routine look? As I said earlier i tried doing it with loops, but it didnt really work out.

  • cap. http://www.fileshack.us/get_file.php?id ... =Mario.cap

    How would such a routine look? As I said earlier i tried doing it with loops, but it didnt really work out.

    I would try something like

    +On start of layout

    -Set alterable value (x) of Brick to brick.x

    +Player overlaps brick

    +Player is jumping

    -Set alterable value (a) of brick to 1

    +Alterable value brick (a) equals 1

    +every 3 ticks

    -Brick.x = brick.x + 1

    +Brick.x is greater than alterable value (x) of brick + 5

    -Set alterable value (a) of brick to 0

    +Alterable value brick (a) equals 0

    +every 3 ticks

    -Brick.x = brick.x - 1

    +Brick.x is less than or equal to alterable value (x) of brick

    +alterable value (a) of brick is 0

    -Set alterable value (a) of brick to 2

    -Set brick.x to alterable value (x) of brick

    Something along those lines would probably work

    ~Sol

    *EDIT*

    x...y...i always get them mixed up lol... those might all be Y's haha

  • Okay, I just took a look at your .cap... and it is working.

    It just looks like it's not.

    What's happening is your physics goombas are getting stuck on the pipes. They're trying to turn around, but they can't.

    Try changing the goomba's physics settings like so:

    Linear Dampening: 0

    Contact Friction: 0

    Contact Elasticity: 100

    World Friction: Exact

    World Solver: Exact

    You will see that the goombas do have a mind of their own. They still get stuck, but not as much.

    I think the reason they weren't breaking loose of the pipes until the other goomba hit the pipe is there was a transfer of force through the objects that was big enough to knock it free. Which is strange, because the pipes and ground are set to Immovable. I don't really understand it.

    Anyway, it's all just a byproduct of trying to use physics for a platformer. Theoretically it can be done, but it's a weird use of the physics engine. And if it's a weird use of the physics engine, you're going to get weird results. My recommendation is that you stick to non-physics behaviors for tasks that don't need physics.

    And yes, I understand that you want to use physics because it's easier... but in practice it just isn't easier.

    Set alterable value

    What is this MMF crap? gbt dailyclick

  • Hmm, your problebly right though it is strange that the Goomba works perfectly when there is only one of them.

    The reason to use physics is mainly becouse i want the Goombas to interact with the other objects.

  • Yes, you were right deadeye, i changed it from physics to this:

    Goomba.X = Goomba.X + 100 * TimeDelta[/code:695hp1hv] and it worked as it should.
    
    Very strange that it didnt work with physics though.
    
    A big thanks for your help.
    
    SoldjahBoy: Ill try your example.
  • Hmm, your problebly right though it is strange that the Goomba works perfectly when there is only one of them.

    The reason to use physics is mainly becouse i want the Goombas to interact with the other objects.

    If you want built in functionality like gravity/collision without having to code it by hand, just use the Platform behavior on them. At the beginning of the layout do "Goomba: Start ignoring user input." Then you can manually set the x speed and such with events.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)