The Daily Click ::. Forums ::. Klik Coding Help ::. Top/Down Engine
 

Post Reply  Post Oekaki 
 

Posted By Message

Rory Griffin



Registered
  14/08/2003
Points
  239
14th March, 2007 at 22:40:37 -

I'm looking to create a custom top/down engine (or 8 direction movement) engine using events only. I've got most of it working, but I can't seem to get the Move Safely 2 object working the right way. The reason I need this working is because when I run into a wall, I want my character to STOP and not just bounce off the wall. (I'm using a detector for this, with sprites overlaying it.)

Is there any way I can get some insight on this? I'm normally good at a lot of other stuff, but when it comes to movements I'm really retarded. I'm new to MMF2 (just got it in the mail today) and I've never worked with Move Safely before until now.

Thanks for the help if you can give it!
~Roar

 
n/a

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
15th March, 2007 at 00:06:40 -

You have 4 detectors for each wall. Do something like this:

If 'up_detector' collides with background
+ stop your player object
+ start loop 'collision' 30 times

If 'down_detector' collides with background
+ stop your player object
+ start loop 'collision' 30 times

If 'left_detector' collides with background
+ stop your player object
+ start loop 'collision' 30 times

If 'right_detector' collides with background
+ stop your player object
+ start loop 'collision' 30 times

On loop 'Collision'
up_detector is overlapping a backdrop
+ move all the detectors and the player down

On loop 'Collision'
down_detector is overlapping a backdrop
+ move all the detectors and the player up

On loop 'Collision'
left_detector is overlapping a backdrop
+ move all the detectors and the player right

On loop 'Collision'
right_detector is overlapping a backdrop
+ move all the detectors and the player left

simple as that.

Zi-Xiao

 
n/a

Rory Griffin



Registered
  14/08/2003
Points
  239
15th March, 2007 at 00:32:14 -

It kind of makes sense, but I'm using only one detector that's a bit smaller than my sprites. The problem is the fact that I can't use the regular 8 Dir movement because my character bounces. Ergo, my character is on "Static" so I can't rightly use "stop movement". I tried a few other things that just get my character stuck. It's really a downer here. In the past I never worried too much about this stuff, but now it's very important.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
15th March, 2007 at 02:55:28 -

keyboard: user pressed up
---start loop "move up" for whatever loops

on loop "move up"
---player: set y to y("player")-1

on loop "move up"
+player is overlapping a backdrop
---player: set y to y("player")+1

And so on. Or you can use a single loop and use a value to indicate which direction was pressed.

Image Edited by the Author.

 
n/a

Rory Griffin



Registered
  14/08/2003
Points
  239
15th March, 2007 at 03:37:59 -

For some reason it's not working. It's set up right, Radix, just like you put on there, but it's not moving at all...I'm confused because I know I've done something like this before...

 
n/a

Rory Griffin



Registered
  14/08/2003
Points
  239
15th March, 2007 at 04:39:03 -

Okay, thanks for the help guys. Jerry, the way I had been working with my game did not require the method you used, but I do know that method works and is a great way of doing it.

Radix, I took a bit of what you said and did it a bit different. Below is an example of what I did:

{
o Always
---- Deactivate group "Move Up"
---- Deactivate group "Move Down"
---- Deactivate group "Move Left"
---- Deactivate group "Move Right"

o Repeat while "Up Arrow" is pressed
---- Activate Group "Move Up"


GROUP MOVE UP
o Always
+ X ("Player") is overlapping a backdrop
---- Set Y position to Y("Player")-1

o Always
+ ("Player") is overlapping a backdrop
---- Set Y position to Y("Player")+1
}

Of course, make changes in accordance to the direction you're moving. This is, for the most part, flawless. Make sure to check the box next to "Collision with box" for your sprites set as obstacles, and also set your detector to do the same. This requires your detector to be set as "Static" under Movements as well.

Again, thanks for the help,
~Roar

Image Edited by the Author.

Image Edited by the Author.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
15th March, 2007 at 07:25:37 -

The code I posted should work, so I can only assume you did something wrong there.

 
n/a

Rory Griffin



Registered
  14/08/2003
Points
  239
15th March, 2007 at 16:03:26 -

I do not doubt that Radix, but I'm using MMF2 and maybe they changed the way a few things work. As I said, I feel as though I had done that before, but it just didn't work.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
15th March, 2007 at 16:16:15 -

"I'm using MMF2 and maybe they changed the way a few things work."

No, they probably wouldn't, for backwards compatibility. And because positioning functions and fastloops don't need to be changed, because they already work as they're supposed to.

 
n/a

Rory Griffin



Registered
  14/08/2003
Points
  239
15th March, 2007 at 16:38:38 -

So anyways, even if yours works, Radix, it inspired the way I did mine, and for that I am thankful. Now here we do have a flawless engine. And for that I am thankful. For now my game can be made as it should be, and for that I am thankful.

Thanks a million yet again, a thousand times "thank you",
~Roar

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
15th March, 2007 at 17:09:56 -

I wouldn't call what you described a "flawless engine" but if you're happy with it, great.

 
n/a

Rory Griffin



Registered
  14/08/2003
Points
  239
15th March, 2007 at 19:30:27 -

I'm sorry Klikmaster, I have yet to find anything wrong with the movement engine. If you do find something flawed please let me know.

~Roar

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
15th March, 2007 at 19:32:28 -

Image

Works fine in MMF2.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click