I'm progressing fairly well in my learning of mmf - I have 360 movmement system down (with much thanx to the people at TDC), weapon firing with damage / ammo / reloads, weapon switching, and several types of enemy AI. But alas, I need to come back for help with my latest problem as I cant figure it out myself :S
How is it I can prevent my player from walkign trhough certain objects or walkign off screen? I'm assuming its doen either with detectors, or with a simple collision/test position condition. Though I'm not sure how I should alter the players movement in order to prevent them from goign off screen or through objects.
The code/concept behind the movement can be foud here, post number 4:
Setting detectors: (Assuming a 32 x 32 sprite, you can change the +/- values. Set all hotspots in the center)
Always:
Set Top's position to (0,-16) from Player.
Set Bottom's position to (0,16) from Player.
Set Left's position to (-16,0) from Player.
Set Right's position to (16,0) from Player.
Now, you have to make it so that it doesn't move in the direction of a detector that's overlapping an obstacle, or when it's out of the playfield.
Sin( Value A( "Player" ) ) * Value B( "Player" ) < 0 & Left is not overlapping an obstacle (add more negated conditions for active object obstacles) & X("Left") > 0:
(Player) : Add Sin( Value A( "Player" ) ) * Value B( "Player" ) to Value C
Sin( Value A( "Player" ) ) * Value B( "Player" ) > 0 & Right is not overlapping an obstacle (add more negated conditions for active object obstacles) & X("Right") < (horizontal width):
(Player) : Add Sin( Value A( "Player" ) ) * Value B( "Player" ) to Value C
Cos(Value A("Player")) * Value B("Player") > 0 & Top is not overlapping an obstacle(add more negated conditions for active object obstacles) & Y("Top") > 0:
(Player) : Sub Cos( Value A( "Player" ) ) * Value B( "Player" ) to Value D
Cos(Value A("Player")) * Value B("Player") < 0 & Bottom is not overlapping an obstacle(add more negated conditions for active object obstacles) & Y("Bottom") < (Vertical width):
(Player) : Sub Cos( Value A( "Player" ) ) * Value B( "Player" ) to Value D
Always:
(Player) : Set X Position to Value C( "Player" )
(Player) : Set Y Position to Value D( "Player" )
Hope this helps!
Edited by the Author.
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
"Sin( Value A( "Player" ) ) * Value B( "Player" ) > 0 & Right is not overlapping an obstacle (add more negated conditions for active object obstacles) & X("Right") < (horizontal width):
(Player) : Add Sin( Value A( "Player" ) ) * Value B( "Player" ) to Value C"
Sin( Value A( "Player" ) ) * Value B( "Player" ), in his 360 degree engine(http://www.create-games.com/forum_post.asp?id=85009 ), just gives the left/right direction, and Cos(Value A("Player")) * Value B("Player") gives up/down direction. The quoted code simply says that if it's supposed to go right, it only can if the right detector isn't overlapping anything or off the screen.
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
That looks like its more or less exactly what I need, though I am having slight troubles following some of yoru code. :S
Sorry to ask this of you, but would it be possible to see an perhaps a workign example of oen of the condition/event sets that involve COS or SIN? From what you've written I'm confused as to what aspects of the taht should be negated, or which aspects belogn with condition or events.
Don't knock on death's door- ring the doorbell and run away. He hates that.
Making the file, I realized that I accidentally swapped Sin and Cos in my replies above. This file contains the correct code to allow for collision detection with the edge of the screen, quick backdrop obstacles, and active object obstacles (just put them all in group 0). I also move the detectors in a fastloop to prevent lagging. Good luck with your game!
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames