Problem with rules

BasGoodboyBasGoodboy Member, PRO Posts: 310
edited May 2014 in Working with GS (Mac)

Hey all,

So I am at the final stage of my raft-jumping game, which looks like this:

image

The problem:

I have three rafts beside eachother, raft1, raft2 and raft3, each raft respawns a new raft1, raft2 and raft3 at a certain point, and the old ones get destroyed out of the window. It all works pretty fine. Each raft has a random spawn, which randomly spawns a normal raft, a mob 1, a mob2 and so on. The player has to jump on a raft with no mob on it, otherwise it takes a life.

The problem is, that sometimes three rafts with a mob on it spawn beside eachother, and the player HAS to lose a life and get on a mob-raft, as be seen on this printscreen:

image

To solve this, I made the rule:

if raft1spawn=5,6,7 (5,6,7 being the mobrafts),

if raft2spawn=5,6,7 (5,6,7 being the mobrafts),

if raft3spawn=5,6,7 (5,6,7 being the mobrafts),

change attribute three-in-a-row to 1

if attribute three-in-a-row=1, change raft1spawn=1 (1 is normal raft)

BUT.. this won't work, the GameSalad engine seems to be too slow to handle this.

I also tried the rule:

if raft1spawn=5,6,7 (5,6,7 being the mobrafts),

if raft2spawn=5,6,7 (5,6,7 being the mobrafts),

if raft3spawn=5,6,7 (5,6,7 being the mobrafts),

change attribute three-in-a-row to 1

if attribute three-in-a-row=1, destroy first row raft, spawn raft1 (1 is normal raft) on actor,
also this won't work, again the GameSalad engine seems to be too slow and it does work, but it takes seconds and the normal raft will spawn too late and everything will collapse.

Any ideas on this please?

Goodboi Gamestudios | Monster Jumper now on the App Store

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited May 2014

    @GasGoodBoy, GS is not too slow for this. I suspect something with your rules may not be quite right.

    Can you post a screenshot of the rules you posted above? Your theory should work.

    Have you checked that your attribute "three-in-a-row" actually changes?

    Personally I would have opted for more control by making a separate actor which is in charge of spawning all three rafts.

  • BasGoodboyBasGoodboy Member, PRO Posts: 310

    @Hopscotch thanks for answering and trying to help.

    Here is the desired printscreen of the rules in the background actor:
    image

    You should know each island actor, with a mob on it, either a coin or just an emtpy island, all have the rule, that when collapsing the spawning actor, which is invisible at some point of the screen, changing the island1, island2 and island3 attribute to (random:1,17).

    The island1, island2 and island3 attributes will activate a spawn of a certain island, one out of 17, either with a mob, coin or whatever.

    The rules of the island attributes are (in short) as followed:
    image

    This won't work tho, cause like this, when attribute three-in-a-row becomes 1 because of 3 mob-islands side to side, my rules says attribute island1 should then become 1, so there should be an empty mobbed island spawned at the upper left side of the island rows (which should replace the upper left mob one, which would usually be spawned), but in stead the normal 3 mobs spawn and THEN the rule works and because of the three-in-a-row attribute a new empty mobbed island gets spawned AFTER the three mob spawns. Because of that in no time the game crashes because they then all reach the spawning points and more and more islands will spawn at will, which will cause a chaos.

    I hope you understand what I mean and what my problem is.

    @Hopscotch the rest of the spawning works just fine. The whole game works, only it's stupid to have the possibility, which sometimes occurs cause of the random rules, that three mobs spawns side to side and there is no other possibility then take a life and collapse with them with your hero. What is the more-worth of a seperate actor spawning all three islands?

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • BasGoodboyBasGoodboy Member, PRO Posts: 310

    Oh by the way maybe I should notice, if you didn't got that yet, that the hero and island all got the same speed, which speeds up by level and by speed go down when coming out of the 'cave'.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    One way to force a random pattern without duplicates is to create a table of possible values with each column representing a raft. Let's say m stands for mob (I don't know what that is but I'll call it a monster for now) and e stands for empty. You might have this table, then:

    m e e

    m m e

    m e m

    e e e

    e e m

    e m e

    e m m

    Then, each time you need to spawn new rafts you would choose a random row of the table and use the column values to determine what happens to each raft. Since there is never a row with three m's, the problem you described cannot happen.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • BasGoodboyBasGoodboy Member, PRO Posts: 310

    @tatiang great answer, because of you I found a new way, not in tables tho, since I have to completely look into that because I never did tables, but just spawning all three at the same time. I think @Hopscotch meant the same thing.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Don't know if this will be any help to you, but I put out a demo that chooses a random value without picking the value before it. It uses tables. It's found about half way down this page: http://forums.gamesalad.com/discussion/52494/spare-code-dump-it-here

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited May 2014

    That's also great @Braydon_SFX!

    Goodboi Gamestudios | Monster Jumper now on the App Store

Sign In or Register to comment.