Well, MMF2 has been sat on my shelf doing nothing for a good few months now. Today I decided that it was time I left TGF alone and kicked it up a knotch with MMF2.
I also decided to start doing custom movements, too... Got my left/right movement and very basic gravity done but I'm very stumpped at jumping. I can't really seem to think of a way around it. Maybe with a counter/value/etc? Whats the easiest way? Oh, I do have another problem: getting the falling animation to play properly.
Bottom detector not overlapping BG -> Player Y Pos -2 + change animation to "falling"
With that the animation will not play. It changes but sticks at frame 1. Is this because its constantly setting the animation to "falling"? If so, how could I correct this? Thanks for any help
the way i do it is make the objects y value relate to a value (a counter or an alterable value that i call 'jump')
(make characters y value related to it's y value + 'jump')
then have three modes (also an alterable value)
stop = 0
rise = 1
fall = 2
so 0 makes the 'jump' value 0
1 makes the jump value subtract
2 makes the jump value add
then it's a matter of pressing a button to make the value 1 until you've jumped enough (jump = -25 set jump mode to 2)
then hitting the floor will make jump mode 2.
well thats how i used to do it, it's not really very good because you'll sink into the floor.
I have an alt variable called JUMP CEILING that when the player presses the jump button , JUMP CEILING is set to the player's Y position - 40 and a flag is set to on. Then, while that flag is on you have an event that subtracts -2 to the player's Y position. When the player's Y position <= JUMP CEILING, then you turn the flag off and he'll fall.
It's way more complicated to get it to not look like crap though, which is something I'm working on at the moment myself
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
26th July, 2007 at 21:51:11 -
Oh... dear.
You should keep watch for better jumping methods.
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
Yeah I know. I've been trying to work Phizzy's awesome examples into my own but mine is too over-complicated and integrated to be changed too much and have it work. Worst of all is the friggin' hype over this thing is getting ridiculous, in a bad way if I can't cut the mustard!!
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
* Player isnt on the ground: increase his y speed by some constant rate (that would be the force of gravity) (If he is on the ground, set his y speed to 0!)
* Always set position y = current position + y speed (Not this basic, of course, you probably want to use the fastloop method that moves an object 1 pixel at a time and such, or whatever applies to your specific engine!)
* player pushes jump key, set the y speed to some negative number. Maybe -7 for an example, this will launch the player up in the air.
* with the gravity always acting, everything will take care of itself! The player rises into the air, and falls back down with a perfect parabola if you did it right. ;D
I hope that was clear. I'm very tired and I didnt go into any detail :I
I do it Xerus' way, but with a slight modification:
Set Position of Player to Y(Player)+ Alterable Value A (Player)/3
If you make the engine without the "/3" part the player will fall down very quickly. Of course, you can change the 3 to a 4, or even a 5... it depends on what sort of game your engine will represent.
I seem to be having a problem with the fast loop though. I tell it to move the player up 1 pixel and to loop 60 times. So its just positioning the player up there right away, not pixel by pixel... How do I get this part a workin'? (I'm horribly new to this, ugh)
Edit: Oops, my bad. Still went through the ceiling though Its like its just ignoring the fast loop and just positioning the active object there right away. I'm really confuzzled. :S
Uh slink, the point of fastloops is that it does everything in one (TGF/MMF) loop
Your character did indeed move up one pixel at a time, it's just that all those 60 loops ran so fast you couldn't see it. You need a "stop loop" event in there.
Well, what if you also made it so that in order to jump, Player Flag 1 has to also be set to ON. Then you can add another line like "if Player top detector overlaps the background (i.e. hits his head on the ceiling or whatever) set Player Flag 1 to OFF." You'd have to work gravity in there still, maybe use another flag? I'm new at this too but it may work.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Set up the way xerus said to use an alt value for Y movement .
Always ->
start loop "jump" Abs(AltValA("Player")) times
on loop "jump"
+ bottom detector is not overlapping a backdrop
+ AltValA("Player") > 0 ->
Set Y position to Y("Player)+1
on loop "jump"
+ top detector is not overlapping a backdrop
+ AltValA("Player") < 0 ->
Set Y position to Y("Player)-1
This does gravity too though. A fastloop run 30 times is as good as moving 30 pixels in a frame, so the always event keeps it at MMF drawable speed if you will .
As always someone is free to correct me but i think this should work, it did in an engine i made anyway...
Slink, the typical proceedure is to check for collisions every loop, then when there is one, back up the character 1 pixel (So it's not overlapping the wall) and do the stop loop.
Ben, that looks fine, but I think its confusing to call that loop "jump" I would name it something like "moveY" or something like that, since its taking care of all actions that could possibly move the player on the y axis.
The reasoning for the fast loops is pixel perfect collision. If you were to move your player at a ridiculous speed, say 60 pixels per frame, without fast loops, you're probably going to pass through backdrops and other actives since you'll skip right over them. But with a fast loop moving the player 1 pixel 60 times per frame, each pixel of movement checks for a collision, and you wont see the next frame until after that fast loop is done-- so you get the same thing, but with accurate collisions. Plus, you dont have to worry about pushing the player out of walls too much since the deepest they can go is 1 pixel.
I remember going through custom platform tutorials when I first was getting into MMF, and I was always so confused as to why people always named their player's y speed value "Gravity." That totally messed with me :I