The Daily Click ::. Forums ::. Klik Coding Help ::. Need some help with detectors (I think)
 

Post Reply  Post Oekaki 
 

Posted By Message

Corsair



Registered
  26/06/2004
Points
  16
5th July, 2004 at 10:37:01 -

Hey,

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:

http://www.create-games.com/forum_post.asp?id=85009

Thanx in advanced for any help


 
Don't knock on death's door- ring the doorbell and run away. He hates that.

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
5th July, 2004 at 15:50:34 -

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!

Image 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

Yuhkaz

Sin Binned (Broke The Rules)

Registered
  30/09/2002
Points
  -100
6th July, 2004 at 12:12:32 -

Noyb I bloody hate all that

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

crap, lol. Too advanced for me.

 
n/a

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
6th July, 2004 at 12:30:55 -

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

Corsair



Registered
  26/06/2004
Points
  16
6th July, 2004 at 12:44:56 -

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.

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
6th July, 2004 at 18:40:18 -

http://home.att.net/~realnoyb/360.cca - 32kb

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

Corsair



Registered
  26/06/2004
Points
  16
6th July, 2004 at 21:33:15 -

One word- Perfect. Thank you very much.

 
Don't knock on death's door- ring the doorbell and run away. He hates that.

Nothing, Ok?



Registered
  14/05/2004
Points
  199
8th July, 2004 at 14:33:16 -

The day of the tentacle is a good game.

 
Is Nothing, Ok?

http://www.ohwriters.com/

http://www.ohwriters.com/

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!
8th July, 2004 at 21:08:08 -

I enjoy games that involve tentacles in some way.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click