Couple of questions for Mario game.

For questions about using Classic.

Post » Sat Sep 20, 2008 10:06 am

Im 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"


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.
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Sat Sep 20, 2008 10:59 am

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
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Sat Sep 20, 2008 11:28 am

Thanks for your reply.

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



Brick problem:
By cheap I mean the sollution in itself, not the look of it.
I want it to be kinda like this:
[code:wiz0g72b]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.
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Sat Sep 20, 2008 11:40 am

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

[code:3esth2tb]
+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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Sep 20, 2008 11:55 am

Thanks for reply. =)

[quote="deadeye":upez4qet]Instead of "direction" being set to either 1 or 2, have it set to -1 or 1. That way you can do this:

[code:upez4qet]
+On collision between goomba and pipebottom
-goomba:Set 'direction' to 0-goomba.Value('direction')
[/code:upez4qet]

(That's "zero minus direction.")
[/quote:upez4qet]

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.
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Sat Sep 20, 2008 12:05 pm

[quote="Jonaw":26pjipcm]
Thats pretty clever. Still dosent work when having more than one Gomba though. Is it even possible to have diffrent private variables for instances?[/quote:26pjipcm]

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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Sep 20, 2008 12:12 pm

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.
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Sat Sep 20, 2008 12:21 pm

[quote="Jonaw":dbuuem1h]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.[/quote:dbuuem1h]

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
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Sat Sep 20, 2008 12:41 pm

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.

[quote="SoldjahBoy":24vq8sno]Set alterable value[/quote:24vq8sno]

What is this MMF crap? gbt dailyclick :P
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Sep 20, 2008 1:15 pm

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.
B
2
G
4
Posts: 23
Reputation: 1,096

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests