Tutorial: Platform School

Post your own tutorials, guides and demos.

Post » Fri Mar 27, 2009 7:06 pm

Hi.
I couldn't understand the cooper-bounce-overlap-timer part (lesson 8)
Can you explain it?
B
2
G
3
Posts: 18
Reputation: 886

Post » Fri Mar 27, 2009 7:53 pm

[quote="Bonecrusher":1vvt5pda]Hi.
I couldn't understand the cooper-bounce-overlap-timer part (lesson 8 )
Can you explain it?[/quote:1vvt5pda]


Sure, no problem :)

First off, the reason:
We don't want the turtles to overlap each other. If they do start overlapping, they won't be able to pull apart, and you will have two (or more) turtles occupying the same space. This just looks awkward.

Second, the theory:
So... we need a way to get the turtles to bounce away from each other when they touch. Since we're manually moving the turtles by setting their speed and direction, it makes sense to set their speed and direction to something else when they collide. The easiest way to do this would be to make them reverse direction temporarily. This is where the timer comes in. We want them to only "bounce" away for a short period of time, and then return to normal movement. (If we simply tell the turtles to only move away when they're overlapping, then they will continuously try to push into the turtle in front of them. The timer gives them time to get clear.)

Third, the practical application:
In event 13 of the coopBox sheet, we have the overlap condition that starts the bouncing sequence. "coopBox overlaps coopBox." easy enough.

There is an additional condition that, out of those two turtles, the one that is farthest from the player is picked. This is the one the action gets performed on. The 'bounce' variable is set to 10.

Event 14 subtracts 1 from the 'bounce' variable every 10 milliseconds. 10 'bounce' multiplied by 10 milliseconds = 100 milliseconds, or one tenth of a second. This is the timer that defines the duration of the bounce, and it gives the turtle enough time to get clear of the one it's overlapping. When the 'bounce' reaches zero, we will return to normal movement.

BUT - notice that event 13 is always setting the 'bounce' back to 10 as long as the turtle is overlapping... this means that the timer doesn't effectively start counting until the turtle is no longer overlapping.

To get the turtle to stop overlapping we need to change it's direction. This is done in event 12. Event 11 sets the speed for the turtle when it's moving normally:

[code:1vvt5pda]
+ coopBox.Value 'bounce' Equal to 0
-> coopBox: Set horizontal speed to coopBox.Value('xSpeed')
[/code:1vvt5pda]

But in event 12, we check to see if 'bounce' is greater than zero, and if so we reverse the speed:

[code:1vvt5pda]
+ coopBox.Value 'bounce' Greater than 0
-> coopBox: Set horizontal speed to 0-(coopBox.Value('xSpeed'))
[/code:1vvt5pda]

The "zero minus value" equation is a way to toggle a positive number to a negative number, and vice versa. 0 minus 5 = -5, and 0 minus -5 = 5.

To summarize:
1. A turtle overlaps another turtle. The 'bounce' timer is set.
2. The turtle timer begins to count down only when it is no longer overlapping another turtle.
3. As long as the 'bounce' timer is above 0, the turtle reverses his normal direction.

And that's about it. Hope this helps :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Mar 28, 2009 9:51 am

Thanks for reply. It was very helpful.



Unrelated with it, I also want to ask about Fancy Pants 2:
http://www.kongregate.com/games/DrNeroC ... re-world-2

Fancy Pants 2 is one of the worst platform game I've ever played (Let's say I'm playing platform games till the Commodore 64 era)
Has a very bouncy gameplay and very hard to play.

But, I think this game is a good example for making platform games. It has lots of features inside. So, my questions are based upon those features.

- Walking on curves, game automatically turns your character's angle. In your tutorial level designs, there is only one type of slope and it turns the character's angle 45/135/225/315. So, what can we do make our slopes curvy like the FP2 game? Do we need to create smaller slopes that has wide range of angles between 10-60? When we want a curve slope, we will put 10-15-20-25-30 slopes to level? Or there any other easier method for curvy platforms?

- Character have some special movements. For example, if you press down while moving, character makes a slip kick. If your speed becomes 0 while climbing a slope, character starts to slip backwards. If you press down while slipping backwards, you start to roll in that direction. These seems easy to put our game. We just need extra sprites for character. Then we just create events like "while xSpeed>0"+"player pressed down"="Start slip kick event". Similar to this, am I right?

- In SP2 game, there is also "level changing" and "bonus level" features. Will you put something like this to your tutorial? I think Mario style "save points" and Knytt Stories style "save zones" are easy to do for our game. I think it can be done "if player destroyed, after 2 seconds, spawn him in this place, subtract life minus 1". But It will be better if you make a tutorial for that kind of features.

- I think there is also speed check in curve platforms. If we don't accelerate to maximum speed in high angles, we can't climb to that curve and then slip back. I am not sure if putting similar features to our game is necessary. But it would be good if you put another lesson for this kind features. May be it can be used to make a bike racing game.
B
2
G
3
Posts: 18
Reputation: 886

Post » Sat Mar 28, 2009 6:48 pm

The reason that Fancy Pants game is so bouncy and hard to control is it's not using a traditional platformer engine... it's using physics.

It's the physics engine that's also allowing to get the normal for slopes, allowing for smooth rotation of the player when on a slope.

In my tutorials the slopes are rather limited, yes. But this is not meant to be the end of the road. It's simply a tutorial, not a finished, polished game. The method I (and Drasa) show for handling slopes is extensible... you could take this method and create other angles in the same manner. I'm just offering up the technique, it's up to you to take what you've learned and fill in the blanks.

As for loops and smooth curves... no, I won't be doing that. Shallow curves themselves are not terribly hard to do, but the platform behavior is simply not designed to handle real curves or loops. That would require a custom engine built from scratch with your own events.

Yes there will be level changing in a future lesson, but I'm sorry, no there won't be any of that other stuff. The lessons have all been planned out, and for my own sanity I've decided to keep things relatively simple. These are beginner tutorials, after all ;)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Apr 05, 2009 3:49 pm

that fancy pants game isnt bad control at all, and hardly the worst platform game ive ever played. probably one of the most technically advanced platformers ive ever seen, and for a flash game its actually amazing that it was even possible.

the animation is hella smooth, the character has lots of abilities, and he reacts extremely realistically to his enviroment.
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Sun Apr 05, 2009 4:13 pm

first off, thanks deadeye for your awesome tuts
just as a side note
the most technically advanced, fun, and just plain awesome platformer I've ever played by far is littlebigplanet for ps3. god that game rocks
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Apr 06, 2009 12:50 am

[quote="lucid":2w71vvty]first off, thanks deadeye for your awesome tuts
just as a side note
the most technically advanced, fun, and just plain awesome platformer I've ever played by far is littlebigplanet for ps3. god that game rocks[/quote:2w71vvty]

ok aside from big-shot high budget games is what i meant. lol
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Apr 06, 2009 3:36 am

have you played lbp though? man it's good
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue Apr 07, 2009 9:21 pm

[quote="lucid":18cxvh62]have you played lbp though? man it's good[/quote:18cxvh62]

i have an xbox 360, and that game is the only reason i would consider buying a ps3. so ya i know its good, but it aint worth 400$. id love to play it though, havnt tried it yet
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Sun Apr 19, 2009 7:21 pm

Hiya Deadeye,
I'd just like to say your tutorials (and this program!) are amazing, can't wait for you next tutorial on advanced combat, I'm sure as hell not going to be able to figure out how to attack on my todd.
B
2
G
3
Posts: 40
Reputation: 930

PreviousNext

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest