Posted By
|
Message
|
Devernath
Registered 04/12/2004
Points 54
|
2nd March, 2008 at 09:50:39 -
Hello, everyone, I have been looking at some custom platform movement engines, and I sorta get the idea of how it works.
But now, I wanna know, how would I make it if it was 8-dir movement? At first, you may think it should be exactly the same, but I also want to incorporate the ability for the player to move down-right, down-left, up-right, and up-left.
I know this may sound extremely newby, but I am what I am.
n/a
|
Pixelthief Dedicated klik scientist
Registered 02/01/2002
Points 3419
|
2nd March, 2008 at 09:54:16 -
you mean just like you hold left, and you travel left until you let go; you instantly stop, and it would be for a top down game?
Its rather complex to make it so the diagonals don't travel too fast, and so that the character moves at *just the right* speed, instead of 1 pixel/frame, so I'd recommend just using the built in 8-direction movement. Its very stable in comparison to the rest of the built in movements.
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
|
Pixelthief Dedicated klik scientist
Registered 02/01/2002
Points 3419
|
2nd March, 2008 at 10:03:07 -
Btw; if you really do want to make that from scratch, what you need to do is:
Create a seperate counter for the players X & Y positions. Instead of just using the built in 0-640 and 0-480 pixel stuff, you need to define some other variables here. Create them as:
-Start of Level
=Set X-Counter to Player's XPosition * 1000
=Set Y-Counter to Player's YPosition * 1000
Then, at the bottom of your event list, write in:
-Always
=Set Player's XPosition to X-Counter/1000
=Set Player's YPosition to Y-Counter/1000
This way, you are dealing with their position to a precision of 1000x what is built in. this is vital to making the movement smooth. Now, instead of adjusting the objects X position directly, with the built in "Set X position" commands, you can just alter the counters that keep track of their position.
So, you can now add a fraction of a pixel to his position when holding a direction. To avoid using sin/cos to complicate it for you, I just did the math for each 45 degree angle. So next, you put in these events:
-While LEFT-ARROW is pressed
+NEGATE While UP is pressed
+NEGATE While DOWN is pressed
=Subtract 1000 from X-Counter
-While LEFT-ARROW is pressed
+AND While UP is pressed
+NEGATE While DOWN is pressed
=Subtract 707 from X-Counter
=Subtract 707 from Y-Counter
-While LEFT-ARROW is pressed
+NEGATE While UP is pressed
+AND While DOWN is pressed
=Subtract 707 from X-Counter
=Add 707 to Y-Counter
Then, just create those same 3 events for every other arrow key, up, left & right. Make sure that when it is traveling straight LEFT/RIGHT/UP/DOWN, you change the relevant counter by 1000, but when it is traveling diagonally, you change each one by 707. This is because Sin(45) ~= .707
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
|
Devernath
Registered 04/12/2004
Points 54
|
2nd March, 2008 at 10:04:24 -
Originally Posted by Pixelthief you mean just like you hold left, and you travel left until you let go; you instantly stop, and it would be for a top down game?
Its rather complex to make it so the diagonals don't travel too fast, and so that the character moves at *just the right* speed, instead of 1 pixel/frame, so I'd recommend just using the built in 8-direction movement. Its very stable in comparison to the rest of the built in movements.
Normally, I would, but like, heres the thing.....When "Player" collides with background, i make it so that he stops. He doesnt go through the obstacle, but it looks like hes having a seizure.
The main reason is that i want him to able to "push" the background (or active object that looks like background" and it looks very bad with the character convulsing.
Also, my character uses a "Sword" animation, and it would get stuck in the walls.
n/a
|
Pixelthief Dedicated klik scientist
Registered 02/01/2002
Points 3419
|
2nd March, 2008 at 10:16:02 -
I cooked up an example in like 3 minutes:
http://claniraq.googlepages.com/8dir.gam
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
|
Silveraura God's God
Registered 08/08/2002
Points 6747
|
2nd March, 2008 at 10:54:54 -
I wrote an article that got some pretty nice responses on doing just that. If you don't a small bit of reading, I'm sure the article will not only help you make an 8 direction custom movement, but understand exactly how it works, so you can customize it.
http://www.create-games.com/article.asp?id=1641
http://www.facebook.com/truediamondgame
|
AndyUK Mascot Maniac
Registered 01/08/2002
Points 14586
|
2nd March, 2008 at 11:07:27 -
Originally Posted by Devernath
Also, my character uses a "Sword" animation, and it would get stuck in the walls.
I think it would be best to make the sword a different active object that follows your player. Although that can be tricky to get working properly.
.
|
Maisnon
Registered 20/01/2008
Points 14
|
3rd March, 2008 at 09:20:30 -
Originally Posted by I am AndyUK (honest)
Originally Posted by Devernath
Also, my character uses a "Sword" animation, and it would get stuck in the walls.
I think it would be best to make the sword a different active object that follows your player. Although that can be tricky to get working properly.
Well, you could always just make an invisible object take care of the collisions and an overlapping one handle the animations and sword stuff
The first man to compare the cheeks of a young woman to a rose was obviously a poet; the first to repeat it was possibly an idiot.
|
AndyUK Mascot Maniac
Registered 01/08/2002
Points 14586
|
3rd March, 2008 at 11:23:54 -
Well yes, if you want,
But it will still cause problems when trying to make killing enemy events if the sword and player are one object. Unless you want to make a collision mask for the sword too?
I certainly wouldn't recommend it though.
.
|
Dustin Gunn Gnarly Tubular Way Cool Awesome Groovy Mondo
Registered 15/12/2004
Points 2659
|
3rd March, 2008 at 22:56:54 -
Originally Posted by I am AndyUK (honest) Well yes, if you want,
But it will still cause problems when trying to make killing enemy events if the sword and player are one object. Unless you want to make a collision mask for the sword too?
I certainly wouldn't recommend it though.
Yes you make the player and sword one object and have collision masks that is how it is done
n/a
|
Pixelthief Dedicated klik scientist
Registered 02/01/2002
Points 3419
|
3rd March, 2008 at 23:50:50 -
Or you make the entire game on an obnoxious grid and check collisions purely by retrieving data from that position in the array.
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
|
|
|