cannons a lil empty..... need some help please

ovechkin8ovechkin8 Member Posts: 42
edited November -1 in Working with GS (Mac)
I have a slight problem / bug in my game that is pretty random. I have had a few people check my code too but we cannot seem to find what is the problem so any help or advice would be most helpful. Anyways Im having trouble with a reload function of a cannon. If you shoot any of the three cannons you have a reload time that matches that set cannon. So for example if you fire the right cannon, then there is a right cannon reload time. Each reload time is set to 3 seconds and then a green outline shape appears indicating "go / fire". The problem is that every so often my a random of the three cannons will not reload. And this is how they are set up in game salad.

Center Cannon

when (game.middle reload) is( false) + actor receives events when touch is inside
--------------------------------------------------------------------------------------------------------
actor receives event when touch is pressed
--------------------------------------------------------------------------------------------------------
spawn actor (cannon ball)
play sound
spawn actor (smoke)
change attribute ( game.middlereload) to: (true)
--------------------------------------------------------------------------------------------------------

Rule
when attribute (game.middlerelaod) is (true)
------------------------------------------------------------------------------------------------------
Timer
After (3) seconds
Change attribute (game.middlereload) to: (false)
Spawn actor (go) * thats the green outline of the cannon

Thats how all 3 are set up. I have to guess that there is about a 20% failure rate when one tends not to reload. It not every game but I would say that 1 in 5 where one or two cannons do not reload. Sorry for the long post but any help would be great.

Thanks

Comments

  • mrfunkleberrymrfunkleberry Member Posts: 424
    Errors like this are most annoying. Here's a few things to look for...

    Everything

    The problem may not be with your cannons but elsewhere. Too many sprites?(check fps), collisions, timers.

    A good place to start would be in your 'cannon ball' and 'smoke' actors. Check there are no funnies in these actors.

    Also and take this with a huge pinch of salt, but i always avoid the boolean variables. I always use integers 1/0.

    Also in your first rule is 'all' or 'any' selected?
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    is there a good reason to avoid boolean variables? that's something i'll change in my game now if it will help in the future...
  • mrfunkleberrymrfunkleberry Member Posts: 424
    I've not done any systematic testing, so i can only call it a personal prejudice. However i don't like the fact you can define it by checking a box in some instances and with text in others. It only takes one spelling mistake and you're buggered.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    you make a good point. makes you wonder what the GS devs were smok...err, thinking. ;-)
  • ovechkin8ovechkin8 Member Posts: 42
    How many sprites is too many? I have alot going on in that game. The rules are "all" as well. Ill look at stuff too but smoke is just a nice effect animation that comes out after the ball. Then the ball itself has just a few this actor collides then ... rules with it. Im not sure if that could be the problem but I think it might be the sprite one.

    I will try the integer variable. I have heard of some other people doing that. Besides the spelling errors that might come with them, any other advantage?
  • mrfunkleberrymrfunkleberry Member Posts: 424
    Sometimes as the game develops i realize i need more that just an on/off state. And of course integers give you as many states as you like. It is particularly useful when you're structuring the rules of your actors. When creating an actor think of its 'states'. Lets say i have four: run, jump, fall, and powerup. Now create a integer variable called MyState. Create 4 rules in your actor..

    if MyState=1 then... (run)
    if MyState=2 then... (jump)
    if MyState=3 then... (fall)
    if MyState=4 then... (powerup)

    Now you've got a nice structure that at least gives you a chance of being efficient, plus a little security that behaviors governing 'jumping' should never interfere with that of 'falling'.

    Anyway back to booleans : like i said, i haven't done any testing, so i couldn't tell how, when, even if they fail, its pure prejudice on my part.

    Check your frame rates, if they go below 24 its too slow anyway, but its a good indication of too many sprites.
  • ovechkin8ovechkin8 Member Posts: 42
    changing the variables from boolean to integer seems kinda messed up but its working better so far ive tried it 3x and so far no fail. The old way i had a fail on the second try. Any reason for this simple change possibly making all the difference? Also should I convert all my other variables even if they are not giving me problems now?
  • mrfunkleberrymrfunkleberry Member Posts: 424
    I can only repeat what i said before. Anyone else find booleans dodgy?
  • ovechkin8ovechkin8 Member Posts: 42
    alright it locked up again so changing varible settings didnt really work after all but thanks anyways
  • beefy_clyrobeefy_clyro Member Posts: 5,394
    i would suggest adding in some 'display text actors' to show you the attributes for the cannons onscreen. That way when you test you can confirm that the attribute is changing to the correct value, therefore, should be triggering the reload. Keeping an eye on those attributes 'in-game' may give you an idea of where its going wrong. Also, i think it has been mentioned before that depends how much you've got going on, that time triggers and stuff arent always accurate and reliable, i think this is to do with your FPS and sometimes it almosts skips the frame (where the trigger should of taken place). Does this take place when previewing on your computer or when its on the iphone? Whats your FPS running at? Try displaying the attributes and see if that gives you any indication.
  • ovechkin8ovechkin8 Member Posts: 42
    It takes place on both the computer and on the ipod. If it is a frame rate issue what is the easiest way to get that resolved? Is it cutting down on the amount of actors used? Displaying attributes is a good idea too. Thanks
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    Right now you have a touch is inside as well as a touch is pressed condition. You don't need both. I would remove the touch is inside so nothing gets triggered accidentally. Also make sure Run To Completion is set on the TImer.

    (I changed game.middlereload to self.readyToFire just for my own clarity)

    I would set up your Rule structure in each cannon like this:

    Rule
    When All conditions are valid
    When Touch is Pressed
    When self.readyToFire = true
    -----spawn actor (cannon ball)
    -----play sound
    -----spawn actor (smoke)
    -----Change Attribute: self.readyToFire to: false
    -----Timer: After 3 seconds Run To Completion
    ----------Change Attribute: self.readyToFire to: true
    ----------Spawn actor (go) * thats the green outline of the cannon

    That should do the trick and avoid misfires and reloading issues. Let us know if you're still having problems.
  • ovechkin8ovechkin8 Member Posts: 42
    While it seems to reload a lil bit smoother it is still happening. I however did not change the self.readyToFire to false. It is still change reload to true. I know you did that for a personal clarification but would it make a differance if I switched around the variables. So for example instead of firing the cannon making the cannon reload time true. (as it is in the game now)Should I make it when cannon fires make cannon reload false (even though variable name doesnt make sense. ) Would there be a difference?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    The variable names don't matter. Just make sure your Rule structure is set up properly.

    You can also throw a loose Display Text Behavior on the cannon (outside of that Rule) that tracks game.middlereload to make sure it is behaving properly.

    Something not happening 20% of the time is a lot. I don't usually encounter any misfires so there is definitely something funky happening.
  • ovechkin8ovechkin8 Member Posts: 42
    Its decreased..... but its definitely frustrating. Could there be too much going on? There are 3 cannons repeatedly firing too. Each one has their own reloading variable too. Is there a better maybe more efficient way to set that up?
  • ovechkin8ovechkin8 Member Posts: 42
    Ive noticed that the reload sequence does NOT happen when set cannon continuously touched or fired during the switch from reload being true to false. Any ideas with this?
  • ovechkin8ovechkin8 Member Posts: 42
    Ive noticed that the reload sequence does NOT happen when set cannon continuously touched or fired during the switch from reload being true to false. Any ideas with this?
Sign In or Register to comment.