dop2000's Forum Posts

  • 2. Read this article about issues with using too many global variables, it has a few good points:

    http://tobyr.wtfgamesgroup.com/c2-plugi ... variables/

    You can create groups of events and define local variables, they will be accessible only from their groups.

    You can add "temporary" local variables inside of event or functions.

    Note, that these variables don't always keep their value, so if you want them to preserve the value between calls, you should tick "Static".

    3. Instance variables are great! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> You should use instance variables whenever possible.

    You can attach instance variables to different objects, not just sprites or text. I use them with arrays, dictionaries, some other plugins.

    That Globals plugin advertised in the above link is basically an abstract empty object, used only as a storage for instance variables.

    4. Every X seconds is OK to use in some cases. If you want a better control, use Timer behavior - you can run independent timers per object, per instance, stop/restart timer.

  • Good job with the families! I know it's an annoying task converting objects to families, but it will pay off later.

    A few more things you can improve -

    If you are planning to have more allies, move pathfinding and LOS behaviors to the Allies family.

    You can disable them specifically for the player sprite on start of layout.

    Also, you can add AllyType variable, so you could use code like this:

    Allies have LOS to Enemies

    and Allies.AllyType not equals "player" -> (attack enemy)

    Same with Enemies family, you can add EnemyType if you need to differentiate your events slightly for different enemies. Say, some enemies can fly over obstacles, others don't etc.

    Regarding Reach circles - there is no point in adding them to a container without the player/NPC/enemy.

    Unfortunately, you can't add a family to the container.

    If you want to use variables instead of these circle sprites, you can try something like this:

    On every tick

    For each Enemies

    .... Pick Allies by evaluating Distance(Enemies.x, Enemies.y, Allies.x, Allies.y)<NoticeRange

    On a second thought, a much better solution would be adding several LOS behaviors, name them LOS_Notice, LOS_RangedAttack, LOS_MeleeAttack ect.

    Set different range for each behavior, different obstacles.

    Here is an example of a very simple AI:

    For each Enemies

    ...If Enemies has LOS_MeleeAttack to Allies -> (melee attack)

    ...Else If Enemies has LOS_RangedAttack to Allies -> (ranged attack)

    ...Else If Enemies has LOS_Notice to Allies -> (move closer)

    ...Else (patrol)

    Your NPC animation speed is 0, maybe that's why it's not playing. Open NPC sprite, select animation, you can change its speed in the properties bar on the left.

    It's hard to say what's wrong with your AI code as almost all events are disabled.

    I recommend you start with a simple AI and then gradually add more features to it.

  • CreativeMind

    Thanks! I'm using Solid paddle with curved collision polygon, so will need to adapt your code.

    Here is one more tip - when the ball bounces between two walls at close to right angle (85-95 degrees), it can bounce for ages, which is quite annoying. So I increase the angle a little bit with every collision. Say, if the angle was 86, I make it 83.

  • If you want to save this in a string variable:

    New action -> System -> Set variable -> ...

    If you have a text object on your layout and want it to display this number:

    New action -> myText -> Set text -> .....

  • So you need to convert a number to string with 2 decimal points?

    My method is a bit messy:

    d=round((myVar-int(myVar))*100)

    s=int(myVar) & "." & zeropad(d, 2)

    Or the same in one expression:

    Set s to int(myVar) & "." & zeropad(round((myVar-int(myVar))*100), 2)

    Maybe there is an easier way..

  • divyach

    In C2 click New project, select Template: Infinite jumping.

    Add layer "Background" below "Game" layer.

    Add a sprite to the Background layer.

    Set "parallax=20,20" in "Background" layer properties.

    Set "Transparent=Yes" in "Game" layer properties.

    You will only need to add scrolling down when the player is falling.

  • bump...

  • You don't need hundreds of sprites, you only need one TileMap.

    It's not straightforward, but doable. Create different tiles for different situations -

    1. dug (or digged ) tile and no other dug tiles around

    2. dug tile and one dug tile next to it

    3. dug tile and two dug tile next to it - on right and below

    4. dug tile and two dug tile next to it - on left and right

    5. dug tile and three dug tile next to it

    6. dug tile and all tiles around also dug

    7. grass tile

    You can use these 7 tile types to form any kind of landscape.

    When player digs a tile, check the state of neighboring tiles and select the correct tile type. Rotate it if required.

    Then update the neighboring tiles the same way.

  • The or event picks 4 instances because all 4 instances meet the logic. Right?

    Yes, but the parent "compare instance variable" event picked only 1 instance. So the sub-event should not pick more than 1.

    Also, changing the order of conditions in Or-block should never affect the result! It's against the binary logic.

  • Did some more testing. This only happens with Or-blocks, and the order of conditions matters!

    "Sprite.a=1 or Sprite.c=1" picks 1 instance.

    "Sprite.c=1 or Sprite.a=1" picks 4 instances.

    So I'm 99% sure this is a bug.

  • newt, Sorry, I still don't understand.. This kind of ruins my whole system of belief in how C2 picking works. And it can potentially mean lots of hard to detect bugs in my games...

    Is there a tutorial or something that explains differences between "normal" and system picking?

    How can you explain this?

    System Pick Sprite with c=1    // System picking - only one instance is picked
       
        Sprite.c=1     // This is "normal" picking, right?
                       // picks just one instance
    
              Sprite.a=1   // If I put Or-block into a sub-sub-event under "normal" picking sub-event, 
              or           // it still incorrectly picks 4 instances!
              Sprite.b=1    
    [/code:e6fk0rs9]
    Here is the updated capx:
    [url=https://www.dropbox.com/s/jyc2ctj1hlqh3oo/Picking_Bug2.capx?dl=0]https://www.dropbox.com/s/jyc2ctj1hlqh3 ... .capx?dl=0[/url]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If the path is not a straight line, then yes, it would probably be easier to use physics.

    If you don't want to deal with the wheel rotation, friction, revolution joints etc., you can use an invisible sprite with physics behavior. Push it downhill and then on every tick set your cart to that sprite position and angle.

  • You can put a small invisible sprite inside the cart. When player is in collision with this sprite, start moving the cart.

    You can also disable player's controls while the cart is moving and pin player to it.

  • minigame This is strange. Could you share your capx?