The Daily Click ::. Forums ::. Klik Coding Help ::. For those of you (read everybody but me) who've made a custom movement before
 

Post Reply  Post Oekaki 
 

Posted By Message

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
19th December, 2006 at 22:46:41 -

Now I know this is probably easy as pie, but for the game I'm working on now I want to try and make a custom 8 direction movement for the hero. This is because the last game I made(Necropolis Rising)had the built-in movement and a lot of people didn't like that. (It was bouncy, etc, you guys know).

So what I've done is made an active for the hero's sprite, and another small rectangular active always set to his feet. The rectangle has 2 alt variables, X and Y for the position (wow!) For the events, I did these:

> Repeat while pressing Up Arrow
>+ Rectangle is not overlapping a backdrop --> Sub 1 to Y

(This is for all 4 directions)

Now what happens is when my guy hits a backdrop (that's been set to obstacle), he just stops moving. This would be great and what I wanted except that he can't move AT ALL afterwards because he's stuck. I tried making events afterwards that negated the alt variable if the rectangle was indeed overlapping the backdrop. (So before it's Sub 1 to Y, it'd be Add 1 to Y).

I guess what I'm saying is that this should be easy but damned if I can get it to work properly. I want good gameplay in one of my click games for once, dammit! What do I do?

Thank you!

 
--

"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!

Nioreh



Registered
  18/11/2002
Points
  1078
19th December, 2006 at 22:55:39 -

Well I haven't that much experience in custom movement, but I can tell you why your thing doesn't work. He will walk not till he is standing besides a wall, but until he is overlapping it. Then he will be stuck since the controls will only work unless he is not overlapping an obstacle. I would suggest making detectors objects on each side of his feet instead of making a rectangle under them. Then you can disable movement only in the direction where a detector is overlapping an obstacle.

 
Its hard to be religious when certain people are never incinerated by bolts of lightning.

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
20th December, 2006 at 00:31:25 -

You've got to push it back out of the wall again. To do that, use collision detectors on all sides of the player, that push him back when they overlap a backdrop. I can make you an example later if you want...

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
20th December, 2006 at 02:11:46 -

Through some interesting code manipulation, you can do it WITHOUT detectors, actually rather easily.
Have a value that tells which direction your "Rectangle" is travelling in;

> Repeat while pressing Up Arrow
>+ Rectangle is not overallaping a backdrop
---> Sub 1 to Y
---> Set Value A to 1


with down = 2, right = 3, left = 4, ect.

Then, place an event BELOW your "repeat while key" events in the editor:

> Rectangle is not overallaping a backdrop
>+ Value A = 1
---> Add 1 to Y


Basically, an event that UNDOES the movement, before the frame is fully calculated.
Since MMF reads events from top to bottom, this will move your rectangle up 1 pixel, detect its over a background, and move it down 1 pixel.



Of course, if you have more complex movements, such as your main character can jump or fall quickly, or interact with the environment in odd ways, you would be best off using invisible detectors on each side of your rectangle; 1 for each direct, and then have the exact same set up you have right now.

> Repeat while pressing Up Arrow
>+ Top Detector is not overlapping a backdrop --> Sub 1 to Y


That way you wont be able to move any further up, but you can still move down, left, or right.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Werbad



Registered
  18/09/2002
Points
  235
20th December, 2006 at 02:44:10 -

* Repeat While Up Arrow Is Pressed
- Sub 1 to Y

* Repeat While Up Arrow Is Pressed
+ Overlapping Background
- Add 1 to Y

Easiest way I can think of to undo the movement...

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
3rd January, 2007 at 07:25:57 -

Just an update, I FINALLY made a custom movement that works pretty well. Thank you to everyone for helping me.

I can't believe how friggin' easy it was, yet it took me (insert insane number) months to make something work. If there's anyone else who has any trouble with one, this is what I did:

I made 4 detectors (active objects) that form a small rectangle at the base of the hero's feet. The hero's active has 2 alt variables of X and Y that his position is always set to.

Then something like this-

-Repeat while pressing (up arrow)
+Top detector is overlapping group.neutral (negated)
=Sub 2 to Alt variable Y
=Change "hero" animation direction to UP

-Repeat while pressing (down arrow)
+Bottom detector is overlapping group.neutral (negated)
=Add 2 to Alt variable Y
=Change "hero" animation direction to DOWN

-Repeat while pressing (left arrow)
+Top detector is overlapping group.neutral (negated)
=Sub 2 to Alt variable X
=Change "hero" animation direction to LEFT

-Repeat while pressing (right arrow)
+Bottom detector is overlapping group.neutral (negated)
=Add 2 to Alt variable X
=Change "hero" animation direction to RIGHT


* * *

I tried having it only add / subtract by 1 originally but he moved too slow. Then it's a simple flag to control the walk / stopped animation.

I know it's easy as hell but maybe someone can get use of it.

And the new game is coming along awesome! At least I don't think there'll be any "This gameplay sucks!" comments as far as the movement goes...?





 
--

"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!
   

Post Reply



 



Advertisement

Worth A Click