The Daily Click ::. Forums ::. Klik Coding Help ::. Spread Value problem
 

Post Reply  Post Oekaki 
 

Posted By Message

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 19:04:41 -

Ok. So I just started experimenting with spread values and I am going to use them in a full game (because I have to), but I wanted to start small scale and can't still get it to work.

What I did is make an object, controller by the player, two red boxes and two green ones. I wan't one of the green boxes to be destroyed when I touch one of the red one's. So I did this:

- Start of frame
--- Spread value 1 in alterable value A (of the red box)
--- Spread value 1 in alterable value A (of the green box)

- When (player) is overlapping (red box)
+ Alterable value A (of red box) = Alterable value A (of green box)
--- Destroy (green box)

What it does is destroy neither of the boxes when I touch the one with Spread Value 2 and both when I touch the one with Spread Value 1...

Why, how, when and who!?

- Thanks

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th June, 2010 at 19:10:23 -


Originally Posted by superpower
- When (player) is overlapping (red box)
+ Alterable value A (of red box) = Alterable value A (of green box)
--- Destroy (green box)



Flip the middle one around to Alterable value A (of green box) = Alterable value A (of red box)

 

  		
  		

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 19:16:24 -

Thank's hugely!

But... Why is it so important. How do I know in the future which way to put it?

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th June, 2010 at 19:17:59 -

The specific green box has to be the focus of the condition. The way it was, MMF was checking the red box's value. Well, yea, it equals one of the green boxes' value, but since the red was first, it's the focus. So MMF doesn't know which green box to destroy. It works logically to a thinking person, but not MMF, unfortunately.

When something doesn't work that should work, try flipping things around or looking at order of events.

Edited by OMC

 

  		
  		

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 19:27:25 -

Actuall that kinda makes sense in a weird way. Thanks again. Still got loads of problems left though, with my real application

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th June, 2010 at 19:32:34 -

No problem! Feel free to post your other questions. If I can't help you with them, I'm sure someone more advanced can!

 

  		
  		

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 19:40:57 -

One more thing actually.

Always when I wan't to make something happen I need two instances with a spread value, a unique ID.
What if just want to make a specific enemy follow me to the right. Let's say I do something like this:
- X position of "player" is less than X position of "enemy"
+ every 0,03 seconds
--- Set X position of "enemy" to "enemy" X-cordinate -3

How do I make the spread value ID thingy useful. What I'm saying is that I can't compare "enemy" spread value to anything. Is there any way to still utilize the unique quality of his "ID" or do I have to make a detector of respective value to match?

Edited by superpower

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th June, 2010 at 19:46:50 -

How do you want the enemy to be selected? If they're close enough to you? If that's the case, we can use the distance formula. But I'm not sure what you're asking.

 

  		
  		

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 19:50:32 -

I wondered if it's possible to make the ID of the specific instance of the enemy useful without having to create another object to match.
For example this distance formulae you mentioned.
Could you please post it?

Also, I've always wondered... Is there some place where I can find a sort of "legend" for the calculator expressions, i.e "Dir" means distance and so on?

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th June, 2010 at 20:13:51 -

I'm sure it is useful for other things, but I still don't follow...

The distance formula is the square root of this:
(X2 - X1)^2 + (Y2 - Y1)^2


Which, when translated to MMF and used with two objects that we'll call Player and Enemy, becomes this:

Sqr((X( "Enemy" )-X( "Player" )) pow 2+(Y( "Enemy" )-Y( "Player" )) pow 2)


You could use compare two general values, with this in the first one, and your minimum desired range in the second one. Like this:

Sqr((X( "Enemy" )-X( "Player" )) pow 2+(Y( "Enemy" )-Y( "Player" )) pow 2) is less than 50 >> Set Value Whatever to 1.

Value Whatever = 1 >> Make enemy follow Player


So if the distance between the objects is less than 50, the enemy follows the player.

As for a calculator legend... I could tell you what each button does, but I wouldn't be able to remember all of the expressions you can get like "dir" and "speed". I'd like to see a legend too! Maybe someone else knows of one.

Edited by OMC

 

  		
  		

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 20:30:29 -

While we are on the topic of well... pretty much anything that comes to mind
Is there like a way to make the enemy check if anything is between the player and him without using hitboxes? Using the distance formulae wouldn't really work that well with platforming otherwise. Since he could essentially see you through the ceiling and still follow you around like a dog begging for food at the table...

Oh. And cheers for the formulae I tried it out it could actually get really useful. Normally I don't use the calculator that much since I don't really like anything I "can't see". Call me old fashioned

Edited by superpower

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th June, 2010 at 20:59:24 -

Ah-ha! Here's an area where I've not wandered before. There are several approaches to line of sight.

A quick search brings up some interesting stuff...
Sketchy's fastloop LoS engine: http://www.create-games.com/download.asp?id=7524
Pixel-stretching Article by MrMcFlurry: http://www.create-games.com/article.asp?id=2137 (I'd try this one)

There are loads of others too, but some of them have dead links. I think I remember one by Codemonkey somewhere but I've got to run right now. Check them out and see if any fit!

Edited by OMC

 

  		
  		

superpower



Registered
  07/06/2010
Points
  27
7th June, 2010 at 21:19:21 -

Cool stuff!

Oh now I see. This is my first time online and I've always wondered why the search doesn't work Since it used to work for all users before

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th June, 2010 at 22:09:46 -

My article on duplicate objects etc (incl. links to other relevant articles)
http://www.create-games.com/article.asp?id=1975

Re: Line-of-Sight:
The pixel-stretching method is the best, unless you need to find the point where the line of sight is broken (you also *must* use the HWA build of MMF2).

 
n/a

superpower



Registered
  07/06/2010
Points
  27
8th June, 2010 at 18:16:37 -

Thanks a lot for the help! I'm finally getting somewhat of a hang of fast loops and spread value...

However, I still have a problem...
I'm trying to make some of the enemies to start walking right and some to start walking left at the start of the frame.

I've tried...

- Start of frame
+ 1 chances out of 2 at random
+ On Loop "Loop1"
+ ID of "Enemy Test" = LoopIndex("Loop1")

...and all other possible combinations, which leads me to believe that I'm doing something so fundamentally wrong that only you guys can help me with this

 
n/a
   

Post Reply



 



Advertisement

Worth A Click