The Daily Click ::. Forums ::. Klik Coding Help ::. Please point me in the right direction - platform movement
 

Post Reply  Post Oekaki 
 

Posted By Message

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
9th January, 2009 at 22:35:15 -

Hi guys! This is my first day on the site and my first post. I've done some poking around and have a question to ask (which) I'm sure has been asked 10,000 times before. Please forgive me.

Around 2002 or so I bought and played around with both TGF and MMF. I created a small platform game for myself and enjoyed hacking away with it. This past Christmas, I treated myself to a purchase of TGF 2 and have enjoyed revisting my old game.

Here's my problem: I've noticed issues with the platform movement (no surprise to you guys). I found this site and did some reading (e.g. reviewed games that get low marks for using the builtin platform movement). I tried to download some of the samples on "custom platform movement" but many of the links were dead.

My question: Can someone point me in the right direction to either a written tutorial or a source sample that I might take a look at. Some of the GOTWs (I played and really liked Elf) must use a custom movement but I don't know if anyone is willing to share their source with me. If you'd like I can post a link to the game I'm trying to make. It's VERY basic by your standards but I'd like to have things like moving platforms, etc.

Any help would be greatly appreciated.
Jess Bowers

 

-MacAdaM-

Megaman Fosho

Registered
  12/02/2008
Points
  560
9th January, 2009 at 22:46:11 -

Here is a Custom Platform Movement that I made a while ago, It's far from perfect, but it is still pretty solid, and can get the job done!
http://create-games.com/download.asp?id=7260


(I don't know if this works with TGF2 )
You can always try something called the PMO, It pretty much can create a easy, solid custom movement.
Hopefully I helped a little bit!
If you need anything else feel free to message me with a question, or I am sure someone else can help you!
This is a really helpful community.


 
Your just jealous that you're not as awesome as me.
(And my megaman avatar )

Deleted User
9th January, 2009 at 23:19:10 -

Most Custom movements I've seen usually start with something simple like

--Left repeat while pressed
---Set player X to player X-1
---Set player animation to Walking
--Right repeat while pressed
---Set player X to player X+1
---Set player animation to Walking
X-Left repeat while pressed
X-Right repeat while pressed
---Set player animation to Stopped

Or, create an square the size of your player and set it to bouncing ball movement
Create a few events that go like this

--Start of Frame
---Set box visiblity to invisible
--Always
---Set X of player to X of box
---Set Y of player to Y of box
--Left Repeat while pressed
---Set direction of box to left
---Set speed of box to 10
---Set player animation to Walking
--Right Repeat while pressed
---Set direction of box to right
---Set speed of box to 10
---Set player animation to Walking
X-Left Repeat while pressed
X-Right Repeat while pressed
---Set speed of box to 0
---Set player animation to Stopped

There are also other things to take into consideration, such as collision detection, which is where the bouncing ball style is alot easier to use, in my opinion.

Create an active object

-When box collides with "wall object"
---Bounce Box

Then go back to your movement code and add another condition to each
X-Player is overlaping "wall object"

And that takes care of the left and right walls The last thing is the ground. Create your ground as a backdrop, and set it to obsticle. Then do this:

X-When box is overlaping obstacle
---Set box Y to box Y+2

There is one more tip for this part. Draw your entire background, each platfrom and everything goes into one image. Then clone it as an active object. Edit the active object and shave of the top two pixels of every platform. If you did a larger or smaller number in the last one, then shave of that many pixels instead. Then as you did with the box, at the start of the frame, make that object invisible.

I'll have more for you in a bit, but get back to me and see if you got it to work or have any questions.

EDIT: And the best advice I can give is to try figuring it out for yourself as much as you can, play around a bit. If you don't get it, do a search on this code-it forum, the programers union and the articles section. If you can't find what you're looking for then, you're more than welcome to come and ask us.

Edited by an Administrator

 

Deleted User
9th January, 2009 at 23:33:04 -

Now, as far as jumping is concerned, all you need is this

--When Shift is pressed
--Box is overlaping background
---Set alterable Value A to 25

--If alterable value A is greater that 0
---Set box y to box y-2
---subtract 1 from alterable value A

--If alterable value A is greater that 0
--Collision between box and "Wall Object"
---Set alterable value A to 0

And the last thing you need to do is on the box is not overlaping backdrop add
--Alterable value of A is less than or equal to 0

I'm going to go back and annotate the code and explain what each one does.

 

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
10th January, 2009 at 00:03:59 -

First, thank you both (MacAdaM and jneumann1) for responding so quickly. I fed my daughters dinner and when I come back... answers to my questions! Seriously, big thanks.

1. MacAdam - I downloaded your Custom Platform Movement demo and think it's great! Unfortunately, I've had some trouble loading the GAM file. Using these products (all purchased and non-demo), here are the errors I got:
A. TGF 2 (build R248 ) - "Cannot find extension KCfloop.mfx."
B. TGF 1 (build 38 )(32 bit) - "Cannot find gffloop.GOX!"
C. MMF 1.5 (build 118 ) - "Cannot find extension KCfloop.cox."
I would LOVE to take a peek at the code in the demo. Any idea what I might be doing wrong? Do I need an extension that I don't have? If so, is the extension an MMF 2 version only? Again, your demo looks great. Does it have any code for moving platforms (which will carry the player with them horizontally)?

2. jneumann1 - Thanks a ton for the explanation. Its good to have an explanation of the code. I haven't dived into your full explanation yet but will after I get my girls put to bed tonight. As a novice, I'm sure I'll have a question or two.

Thanks again!

Edited by Jess Bowers

 

Deleted User
10th January, 2009 at 00:08:45 -

--Left repeat while pressed
---Set player X to player X-1
---Set player animation to Walking
--Right repeat while pressed
---Set player X to player X+1
---Set player animation to Walking
X-Left repeat while pressed
X-Right repeat while pressed
---Set player animation to Stopped

What these commands do is first takes the conditions when a player hits whichever keys, it moves the player by calculating his current postion, then adding or subtracting one. The last one makes it so if the player does not hit anything, then it stops the animation that's playing.

--Start of Frame
---Set box visiblity to invisible
Tells the game at the start to hide the box

--Always
---Set X of player to X of box
---Set Y of player to Y of box
Always sets the player sprite to the box. Remember, put the player on the box, not the box on the player, or you won't move. The player sprite is just the graphical representation, the box is the one that actually moves and determines collsions.

--Left Repeat while pressed
---Set direction of box to left
---Set speed of box to 10
---Set player animation to Walking
--Right Repeat while pressed
---Set direction of box to right
---Set speed of box to 10
---Set player animation to Walking
These are virtually the same as the XY calculations from the top, but using the builtins to your advantage, you can do much quicker calculations, especially if the player is going somewhere other than left and right.

X-Left Repeat while pressed
X-Right Repeat while pressed
---Set speed of box to 0
---Set player animation to Stopped
This one is more important than the top one for the bouncing ball engine, because not only does it stops the animation, but it stops the player from moving as well.

-When box collides with "wall object"
---Bounce Box
This is another good thing to using the bouncing ball engine, it can bounce, which to the untrained eye, just makes it seem like the player just can't move through it.

Then go back to your movement code and add another condition to each
X-Player is overlaping "wall object"
And this ensures that you definatly cannot move through the force field you've created

X-When box is overlaping obstacle
---Set box Y to box Y+2 <--
This makes it so that when the player isn't touching the ground, which if you've done it right should be peaking at least the ammount of pixels that I'm pointing to, the player will fall down untill it hits the background.

--When Shift is pressed
--Box is overlaping background
---Set alterable Value A to 25

This command only happens if the player presses the jump key and is touching the ground. Then it sets an ammount to an alterable value that is ultimatly the ammount of time that the player hangs in the air.

--If alterable value A is greater that 0
---Set box y to box y-2
---subtract 1 from alterable value A
And then this command which is triggered as soon as the alterable value goes over 0 causes the player to move upwards, and at the same time takes away from the alterable value, so that the player doesn't keep jumping.

--If alterable value A is greater that 0
--Collision between box and "Wall Object"
---Set alterable value A to 0
This command makes it so if the player hits the bottom of a platform, then the player stops jumping and moves back down

And the last thing you need to do is on the box is not overlaping backdrop add
--Alterable value of A is less than or equal to 0
and this makes it so that the falling script doesn't happen untill the alterable value runs out.


Hope this helps get you started. And feel free to play around with the values a bit. Any number on here you can change to increase the speed of your player, the jump time, or whatever you want to do.

As far as the moving platform is concerned, I'll just type it out without the code and see if you can't figure it out kind of on your own. You need 2 active objects that always set itself to eachother, like you did with the box, and it should be similar to the way the backdrop and wall object is, with one acting as the backdrop, the other acting as the wall object which is the same size minus the fall variable (which I've listed as 2). In the wall condition, If player collides with wall then bounce, add copy both conditions into the same event, right click on it and hit "OR(Logical)", and move that in between the two, and change the "Wall Object" on the section set to the platform's "wall object". Do the same with the falling event, copy both conditions into the same event and put an or statement in between them. Then we have to make the platform move. Make sure you put in that even to set the X and Y of the platform's "wall object" to the platform's "backdrop object". Set the backdrop object to bouncing ball and choose the speed. Place that object to whatever Y you want it to be and figure out the X of which points you want it to move to. Create 2 new events one of the conditions will be if the plaform is less than or equal to the lower X number and the other is greater than equal to the larger X number. Let's say between X of 2 and X of 25. So if the X of the platform is less than or equal to 2, change the direction of the platform to the right, and if the X of the platform is greater or equal to 25, then change the direction of the platform to the left.

Alright, I kind of explained it in detail, but you get the Idea. Now, you can tweak it however you want. If you want the player to be able to Jump through the platform, just get rid of that platforms wall object, and if want to do that for part of the backdrop, edit both the backdrop and the "wall object", cut the part of the wall object and paste it as another backdrop and put it in place, and then just delete the same part in the backdrop, so it just functions as empty space, and when the player hits the backdrop, he'll stop. But to make that work, you'll have to change the condition "box collides with backdrop" and "box collides with platform" to a collision mask, which will be if you select the gameboard icon in the conditions, and go down to collision mask->is obstacle, and then change it to Y of box minus the ammount of pixels from the bottom to the hot spot.

If you are confused on anything, just reply.

 

Deleted User
10th January, 2009 at 00:16:33 -


Originally Posted by Jess Bowers
First, thank you both (MacAdaM and jneumann1) for responding so quickly. I fed my daughters dinner and when I come back... answers to my questions! Seriously, big thanks.

1. MacAdam - I downloaded your Custom Platform Movement demo and think it's great! Unfortunately, I've had some trouble loading the GAM file. Using these products (all purchased and non-demo), here are the errors I got:
A. TGF 2 (build R248 ) - "Cannot find extension KCfloop.mfx."
B. TGF 1 (build 38 )(32 bit) - "Cannot find gffloop.GOX!"
C. MMF 1.5 (build 118 ) - "Cannot find extension KCfloop.cox."
I would LOVE to take a peek at the code in the demo. Any idea what I might be doing wrong? Do I need an extension that I don't have? If so, is the extension an MMF 2 version only? Again, your demo looks great. Does it have any code for moving platforms (which will carry the player with them horizontally)?

2. jneumann1 - Thanks a ton for the explanation. Its good to have an explanation of the code. I haven't dived into your full explanation yet but will after I get my girls put to bed tonight. As a novice, I'm sure I'll have a question or two.

Thanks again!



You're welcome, no doubt mine is fairly basic, his may or may not be better. But it's not loading because you need certain extentions for it to work. Type in those file names into a search engine and they'll lead you to the right place.

I forgot that you might need one more thing for my part of the code, to make the player move on the platforms. Start a new event and set the conditions to "box is overlaping platform". Then have it set the box direction (not the player) to the direction of the platform. Also have it set the speed of the box to the platform.

I also forgot, during your movement code, after you set the direction of the box, set the player direction as well. It's important to not just get lazy and say "always set player direction to the box direction" because then if you set the direction of the box on the platform, then the player would look the same way, and you might not want that.

I'm going to eat some chow, and when I get back, I'll put together an example. If you start working on it tonight, I'll check back and answer any question you have.

 

-MacAdaM-

Megaman Fosho

Registered
  12/02/2008
Points
  560
10th January, 2009 at 00:25:37 -

Actually I do know what the problem is.
Making the engine, I used something called Fastloops.
A really handy extension!
Do not worry though, here is a link to where you can download it!
http://www.mediafire.com/download.php?zyjmkzmynyr

I made it using TGF 1 so you should be able to open it.
Just extract that file into were the other extensions are in the TGF 1 folder.

Once your done, you can view the source.




 
Your just jealous that you're not as awesome as me.
(And my megaman avatar )

Deleted User
10th January, 2009 at 00:28:25 -

I just realized that I can't give you the example, simply because I have MMF2, and not TGF2. I'll see about downloading the demo and doing it from there.

 

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
10th January, 2009 at 02:30:45 -


Originally Posted by MacAdaM

I made it using TGF 1 so you should be able to open it.
Just extract that file into were the other extensions are in the TGF 1 folder.



MacAdaM... thanks! I downloaded the extension and was able to open the GAM file in TGF 1. I did some poking at it looks like TGF 2 doesn't support extensions (at least as far as I can tell). Everything in the extensions folder has an MVX for MFX extension ... and just changing the fastloop file extension and placing it in the TGF2\Extensions folder didn't seem to work. Do I need to use MMF 2 (instead of TGF 2) to use the FastLoop extension in *this* generation of click products?


Originally Posted by jneumann1

I just realized that I can't give you the example, simply because I have MMF2, and not TGF2. I'll see about downloading the demo and doing it from there.



Although I have TGF 2, I think I can download the demo for MMF 2. But, if you think you can create a demo of the code your explaining then I would be hugely grateful.

Guys, I can't say enough how much this helps. I am going to spend some time now trying to build some code in TGF2 (using jneumann1's explanations) and start analyzing the MacAdaM's demo. Sounds like they might be different methods - but both look like they will work great. If I can get the smooth movement, not get stuck in walls, use platforms, etc... I'm going to be extremely happy.



Edited by Jess Bowers

 

Deleted User
10th January, 2009 at 02:39:35 -

I got the demo of TGF2 and I'm putting my code it. There were a few things that I left out, but I'll post the file once it's done.

You're very welcome, and thank you. This is giving me a good practice going back over and improving some old coding practices.

 

-MacAdaM-

Megaman Fosho

Registered
  12/02/2008
Points
  560
10th January, 2009 at 02:50:06 -

Well TGF2 and MMF2 have Fastloops built in.
It was just TGF1 that did not.
So if you need a good custom movement for TGF2, I will try and download the demo and cook something up real fast.

But you could always look at my events and try to reproduce them im TGF2 using the build in fastloops instead of TGF1.

Good luck though.

 
Your just jealous that you're not as awesome as me.
(And my megaman avatar )

Deleted User
10th January, 2009 at 04:20:28 -

http://www.megaupload.com/?d=599UWS7T

Give that a try. It's not as good as what I wrote, and there's even a few different things. I tried to do a platform that moves up and down as well, but it didn't work to well. MacAdaM might be able to come up with something a little better.

 

aphant



Registered
  18/05/2008
Points
  1242
10th January, 2009 at 06:22:05 -

Here's a well-written tutorial, with examples, by David Newton: http://clicktutorial.byethost9.com/zips/plattutorial.zip

It's designed for MMF2, but it uses fast loops so all the basic concepts should work in TGF2.

 

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
10th January, 2009 at 06:58:31 -

Once again, my favourite tutorial has come into discussion

Just thought I'd say that David N's movement is very sufficient for platform games.

 
n/a ...
   

Post Reply



 



Advertisement

Worth A Click