Help with platformer collisions

For questions about using Classic.

Post » Mon Jan 31, 2011 5:11 am

I'm making a Super Mario World game, and one element I'm having trouble replicating is the floating ? blocks.

For those who don't know what those are, they're, well, floating blocks with ? marks on them. :P They're solid, so Mario can stand on them and can't go through them, and when he jumps into them from the bottom they bounce up a little bit and then go back to their original position.

I've tried a couple different ways of doing this, from assigning the block Platformer behavior and having it jump, to making it a ball and trying to get it to bounce, but none of it seems to be working properly. Any ideas?

Here's the .cap if you want to play around with it:
http://dl.dropbox.com/u/19702035/mariosonic3.cap
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Mon Jan 31, 2011 5:49 am

Instead of moving the block, how about you just animate the bounce? You can keep the collision mask in it's place then.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Jan 31, 2011 6:15 am

Here you go :wink:

[url:1j5iofb7]http://dl.dropbox.com/u/19912093/mariosonic3%20Bounce.cap[/url:1j5iofb7]
B
2
S
1
G
1
Posts: 14
Reputation: 628

Post » Mon Jan 31, 2011 5:10 pm

[quote="deadeye":38zt9jn2]Instead of moving the block, how about you just animate the bounce? You can keep the collision mask in it's place then.[/quote:38zt9jn2]

Wow... No idea why I never thought of that before. I was about to run ahead and start animating that, but I see the complicated route's already been done for me -- thanks a lot, TecmanX, that works perfectly. :D

One question though, Tecman... can you explain exactly what you're doing with the Set Y to .y - (100*TimeDelta) part? Some crazy stuff is happening when I try to do something else with ItemBox, and I think it might be because I don't know what that bit of code means. :P
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Mon Jan 31, 2011 10:16 pm

Quick question, hopefully a simple one -- is there any way to make a character flashing/blinking WITHOUT making an animation with every other frame being blank? That isn't too hard to do, but... as you can imagine, it's a lot of work. I'd rather not do all of that if there's an easier way.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Mon Jan 31, 2011 10:36 pm

[quote="SullyTheStrange":9lt88w3j]Quick question, hopefully a simple one -- is there any way to make a character flashing/blinking WITHOUT making an animation with every other frame being blank? That isn't too hard to do, but... as you can imagine, it's a lot of work. I'd rather not do all of that if there's an easier way.[/quote:9lt88w3j]
The way I would approach this is as follows:

Have a group (let's call it "flashing") that's always enabled, and have it monitor a variable that will determine whether the character should flash or not (let's call it "flashOrNot").
Also, use a variable that will keep track of the flash rate (let's call it "flashDuration").

In the "flashing" group, have it subtract delta time from "flashDuration", and if it dips below zero, add your initial amount (let's say 0.5 for half a second) and then toggle the character's visibility.
And that's it.

The "flashing" group will take care of everything for you, and all you have to do is set "flashOrNot" to 0 for no flashing, or 1 for flashing.

Krush.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Mon Jan 31, 2011 11:30 pm

The Timedelta System Expression ensures that the block will move at the same speed regardless the framerate, look here for more info [url:9w2k7ufm]http://sourceforge.net/apps/mediawiki/construct/index.php?title=TimeDelta[/url:9w2k7ufm]
B
2
S
1
G
1
Posts: 14
Reputation: 628

Post » Mon Jan 31, 2011 11:46 pm

Just to add what TecmanX has said, you can see from my example above that I use time delta for the same reason; To make sure that no matter what the framerate, the flashing will happen at the speed you want it, allowing people to see it flash exactly as you want them to.

Krush.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests