User Tag List

Results 1 to 10 of 10

Thread: I feel like I overuse counters. Are there better ways to do the following things?

  1. #1
    Clicker Fusion 2.5Android Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    May 2013
    Posts
    85
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    I feel like I overuse counters. Are there better ways to do the following things?

    I'm entirely self-taught at CTF, and I use counters to make a lot of stuff work in my games. Are there better ways to do:

    1. Randomness. If I want something to happen 25% of the time, I create a counter that counts by 1 every 1 millisecond, and if the counter=4 reset to 0. When the trigger occurs, if the counter displays the number 1, the action happens.

    2. Boolean values. The counter named "NPC has given you the diamond" begins at 0. When the NPC gives you the diamond, the counter changes to 1, and then I can use the status of the counter in my code to prevent actions from occurring until you've received the diamond.

    3. Cooldown. If I want to limit a gun's firing speed, I create a counter called "AK-47 cooldown" with a minimum value of 0. When the player fires, the counter sets itself to 1 and subtracts 1 every second. The player can only fire when the counter is at 0. This means the player can only fire once a second. I also use this a lot if I need a delay between two things so they don't happen exactly after each other, for example granting the player 1 second of godframes with a "player just took damage" counter.

    In addition to the typical use of counters (storing values), I wind up with a lot of hidden counters by the end of a project. Are any of these features doable some other way that might be easier than keeping track of all these counters?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,345
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    1: Random(4) = 0
    2: Boolean values in Fusion are called Flags. You can use the flag object, or an active object's flags. You can also use an array.
    3: The timer. You can delay events, or set something to happen 'every..interval'.

    Also consider using ini's or even plain text files, and arrays...

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,245
    Mentioned
    87 Post(s)
    Tagged
    0 Thread(s)
    It's certainly possible to use them less. I don't use a single counter in my game

    1. There's a special condition for randomness. It's in the "limit conditions" section of the special conditions (the gears icon). It's called something like "x chances out of... "

    2. I would use alterable values. For example, Make an alterable value on the npc active object called hasGivenDiamond and set it to 1 or 0.

    3. Same as above. Use an alterable value attached to the ak47 (or player) and use the same cooldown method you were using before

    The big benefit of alterable values is you won't have to create all sorts of new counter objects every time. You simply add another alterable value to an existing object

    It's also better when there are multiple instances of something. For example if there are 5 instances of a turret, they will each have their own shootCooldown alterable value that you only need to reference once in your code (rather than creating 5 counters: turret1cooldown, turret2cooldown, etc.)

    For those situations where you want to visibly see a counter for debugging purposes, use the debugger (fiddly) or VACCiNE (in my sig - though link might be currently broken. If so go to sprykegame.com and then to the downloads section)

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,305
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Counters are for displaying a numerical value on screen - that's it. Not for storing values, and not for anything else.
    Global values should only be used for data that needs to be retained across frames, so don't overuse those either.

    Most of the time, I'd strongly recommend using Active objects and their alterable values - both for their obvious intended purpose (to store values that vary between individual instances of the same object), but also for more general data storage.

    For example, loading a tile-based map is a complicated process, involving a lot of different variables that need to be stored somewhere - so I'll create a special active object just to hold them in its alterable values. Likewise, a pathfinding system uses a lot of values for its calculations too, so I'll create another active just to hold those. For each component of the game, I'll use another separate active to store all the related data (and a separate event group to hold all the events).

    This way, all your values are very neatly organized and easy to find, and to re-use a component in a different project, you can just copy the object over, along with the related event group (don't ever use behaviors!).

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,345
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    I use a lot of hidden counters for much that's going on behind the scenes all the time. And it works fine, even on Android. No problems at all. No slowdowns. Counters are designed to be used that way. If it was just for displaying, it wouldn't have add and subtract actions, and at least of all a Hidden option. I found it very strange when Yves (I think it was him) said that counters were not meant to be used in that way. If that's true, Clickteam have made a terrible attempt of making that clear..

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    aenever's Avatar
    Join Date
    Jun 2013
    Posts
    1,420
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    There's nothing wrong with using counters, it helps keep certain conditions visible for testing. If you can be bothered when you're done you could delete them, yet what's the point no one will see them and they don't slow your game at all.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Wodjanoi's Avatar
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    652
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I used a counter(Animation type counter) for a game menu which will be part of a low price Android game example for the Clickstore I'm working on. Do you think I have to create the menu system with saving and loading routine again without the Counter, because Counters are not good for Android?

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    I don't think there are issues with counters and Android
    (are there? I never encountered one, but I generally only use them for debugging)

    As a personal preference, I work the same way as Muddymole (with objects alt.vals)
    I make a "game engine" object where I set multiple values (usually "instance_picker", "temporary_value", various game-specific values)
    and eventually task-specific objects
    all comes out pretty clean and efficient.

    Can't see anything wrong in using counters,
    depending on the task you are up to and your working habits
    (you prefer having ten objects for ten values, or one object holding ten values)

    unless you do very processing-havy things:
    counters (even when hidden) are about twice slower than alt/global values

    but you won't generally notice it as you start losing some hundreds of seconds when in the order of the million operations

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,245
    Mentioned
    87 Post(s)
    Tagged
    0 Thread(s)
    +1 for using designated Active Objects to organise variables by type. I like to give mine a consistent look, but with meaningful icons, which makes them very smooth to work with. The only is problem is the 26 Alterable Value limit, which means that sometimes you need to use two or more Actives for the same type.


  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Apr 2007
    Location
    Australia
    Posts
    1,151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's easier to create a single active that can hold 26 separate counter values as alterable values, than 26 different counters. If you want to look at things while the game is running, add the active to the debugger and look at it's alterable values in that. The active can also be set to invisible on start, so it's really only there as a container for your data storage.

Similar Threads

  1. iOS iphone widgets-look and feel
    By Just4Fun in forum iOS Export Module Version 2.0
    Replies: 12
    Last Post: 9th July 2012, 09:18 PM
  2. Feel free to use this for everything Lua related
    By Jeff in forum Lua Scripting
    Replies: 0
    Last Post: 27th August 2009, 01:24 AM
  3. Help, starting to feel stupid
    By NaeNae in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 12th December 2008, 04:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •