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

Post Reply  Post Oekaki 
 

Posted By Message

7Soul



Registered
  12/08/2008
Points
  167
18th February, 2010 at 23:21:53 -

Take a look at this code:

Image

Should check for each red object colliding with the floor, and making it stop. And it does, but only for the least created object.
For instance, if i rapidly click twice, the first object stand still, while the 2nd one falls and stop then collides with the obstacle

Also, them seem to fall faster as the number of objects increase

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
19th February, 2010 at 00:26:37 -

Is that the fastloop object? I didn't think that needed to be used any more.

 
lol

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
19th February, 2010 at 00:59:12 -

It's actually a mixture of both the fastloop extension and the built-in fastloop functions, which is why it doesn't work.

Instead of:
Alterable Value B of RedBlock = LoopIndex("enemy")

You should use:
Alterable Value B of RedBlock = Loop Step( "Fast Loop object", 0)


btw: The fastloop extension is indeed now obsolete (it's only there for backwards compatibility).

Edited by Sketchy

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
19th February, 2010 at 02:30:02 -

You should also be spreading values in an "always" event by itself, before the "always" event that begins the fast loop. ie. not in "Loop Trigger #0"

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

7Soul



Registered
  12/08/2008
Points
  167
19th February, 2010 at 03:47:17 -

Thank you guys, you solved my problem. The thing is that i am used to use the built-in fastloop but i'm trying out the extension coz i've seen it on a tutorial
But you think the built-in loop is better? Why?

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
19th February, 2010 at 04:21:59 -

The built in fast-loop is better simply because it is built in. I don't think speed differences would be noticeable but it's a good idea to not use an extension for a function that is built in. MMF's loops are also named which is a lot more useful for debugging and general usability than numbered loops.

Like Sketchy said, the fastloop extension is now obsolete because it is now built into MMF's core.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

7Soul



Registered
  12/08/2008
Points
  167
19th February, 2010 at 04:35:22 -

I got another problem here

I have multiple detectors, like lines of sight
For testing purpose, i wanted them to change from orange to purple (just changing animation direction) when the player were overlapping them
But if i keep on overlaping any of them, they all turn purple as i collide with them, and all get orange at once if i stop overlapping any
Images to explain better: ^^

Image


Image

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
19th February, 2010 at 04:44:16 -

Remove both of those checks and do this instead-

On loop "spread1"-
-Set direction of "Detector" to 0
On loop "spread1" and "Player" is overlapping "Detector" and Alterable Value B of "Detector" is equal to LoopIndex("spread1")
-Set direction of "Detector" to 8

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
19th February, 2010 at 07:53:36 -

Comparing Spread ID of an object should always go directly after the "on loop" condition.

 
lol

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
19th February, 2010 at 13:09:23 -

You don't need a fastloop for that.
The problem is that you need to check for the detectors overlapping the player, not the player overlapping the detectors.

It's as simple as this:

+ Always
-> Detector: Set direction to RIGHT

+ Detector is overlapping Player
-> Detector: Set direction to UP

Have a read of this:
http://www.create-games.com/article.asp?id=1975

Also, I think you'll save yourself some trouble later on if you use maths rather than detectors (ie. Calculate the distance from the player using Pythagoras' theorum). Matching objects and detectors can be a pain, and is best avoided where possible (embedded detectors are great too - there's an article on it somewhere).

Edited by Sketchy

 
n/a

7Soul



Registered
  12/08/2008
Points
  167
20th February, 2010 at 02:54:12 -

The math sollution was a great advice, thx

In the end, all i needed to do is to set a value of the enemy to the distance to the player, and then check for the distance lower than something

You guys are the best ^^

 
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
22nd February, 2010 at 17:50:41 -


Originally Posted by alastair john jack
Comparing Spread ID of an object should always go directly after the "on loop" condition.



I always put it last, damnit! I've been getting a lot of practice with fastloops recently and am finally starting to figure them out.

Thanks Alastair!

 
--

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

7Soul



Registered
  12/08/2008
Points
  167
19th March, 2010 at 00:49:39 -

New problem

When i try to destroy an enemy, all of them are destroyed at once
This is the code:
Image

The Alterable Value J of the sprite and the spreadValue variable of the enemy are the variables that I use to store the spread values, and they work just fine

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
19th March, 2010 at 01:02:36 -

It's the order of conditions again - just swap them round and it'll work.

The way you have it, it works like this:

If Alterable Value J of the most recently created Hedgehog(?) is equal to Spread Value of the most recently created RedBox...
...and HP of the most recently created RedBox is less than or equal to 0...
...then destroy all Hedgehogs and destroy all RedBoxes.

If you put "HP of RedBox <= 0" at the top of the list, it works like this:

Select each RedBox whose HP is less than or equal to 0...
...and select each Hedgehog whose Alterable Value J is equal to the SpreadValue of one of the selected RedBoxes...
...then destroy each selected Hedgdehog and destroy each selected RedBox.

Re-read the article I linked to before...

Edited by Sketchy

 
n/a

7Soul



Registered
  12/08/2008
Points
  167
19th March, 2010 at 01:20:17 -

I tried this already and dont work
Also, the event only happens if I destroy the newly created enemy ):

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
19th March, 2010 at 02:38:52 -

You're going to have to post the full source then, because the problem must be with one of your other events.

 
n/a

7Soul



Registered
  12/08/2008
Points
  167
19th March, 2010 at 03:33:58 -

I uploaded it here: http://www.4shared.com/file/244303347/e67991c1/ARadice.html

The code is somewhat messy
You can find the destroy event at Battle Events > Hit Detector Weak
Spread values at line 10 (with all groups closed)
And if you need, enemy sprite positioning is at Enemy Animation > Enemy - Kobold (even if that looks like a hedgehog, but its placeholder)

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
20th March, 2010 at 04:18:39 -

It's crazy complicated, and I don't speak Spanish, so I had some trouble understanding what was going on.
I must admit, I don't know what's wrong with the way you did it, but I do have a work-around which fixes the problem:

+ HP of enemy1 <= 0
+ Pick one of spr_enemy1
-> Destroy enemy1
-> Destroy spr_enemy1

It doesn't actually matter which sprite is destroyed - whichever ones are left over will be properly matched up again the very next frame anyway.

BTW: You don't need to spread a value on every loop of a fastloop. Just do it once before starting the loop. Better still, only do it when you create or destroy an object.

Edited by Sketchy

 
n/a
   

Post Reply



 



Advertisement

Worth A Click