dop2000's Forum Posts

  • Timer would be a better option. You can pause/stop the Timer if needed, which you can't do with Wait.

  • A few other thoughts -

    5. You can get rid of all range circles (PlayerRange, AttackRange, NoticeRange).

    Use instance variables and distance() expression instead.

    PIck Enemies if distance(Enemies.x, Enemies.y, Player.x, Player.y)<=Player.attackRange

    will pick all Enemies within the attack range from the player.

    6. Name your layers correctly and use layer names instead of numbers. If later you have to add another layer between 0 and 1, you'll not need to change layer number in all events.

    7. Use constants instead of "magic numbers".

    E.g. NoticeRange=MAX_NOTICE_RANGE, instead of NoticeRange=600

    See this post for more useful tips:

  • Your game looks great!

    However, it seems like it's going to be a big project and it's already quite messy. You need to get a few things right ASAP!

    1. First, start using families. I imagine wolf will not be the only enemy in your game. You don't want to duplicate hundreds of lines of your code when you add a new enemy type!

    Create families for all objects that can be logically combined - Enemies (include wolf, bear, zombie etc.), Friendlies (Player, NPC), SceneryObjects etc.

    Every time you add new events and feel like you may need to re-use them for a different object, consider creating a family.

    Note, that you can have the same object in several families.

    Say, wolves can be in Enemies family for all enemy-related things (attacking, pathfinding etc.) and in AliveObjects family (vulnerable to cold, leave blood splatter when killed etc.).

    You will need to move all instance variables and behaviors to family level. It's a time consuming task, but you need to do it now, otherwise it will take 10x more time later when your project grows bigger.

    Follow this tutorial:

    https://www.scirra.com/tutorials/535/ho ... o-a-family

    Also, if two objects are very similar (for example different types of trees), it's better to use one sprite with different animations.

    2. Use containers.

    If you add Enemy, EnemyRange, EnemyHealth to the same container, you'll only need to create an Enemy and pin EnemyRange and EnemyHealth.

    You don't need to worry about creating or destroying EnemyRange and EnemyHealth, it will be done automatically.

    You don't need to link them together using EnemyID variable. Every time you pick one object from the container, others will be picked automatically.

    For example:

    Bullet on collision with Enemy

    -> Subtract 1 from Enemy.health

    -> EnemyHealthBar set width to Enemy.health (you don't need to pick EnemyHealthBar by EnemyID)

    With families and containers you should be able to significantly optimize and de-clutter your code.

    3. Use different event sheets. 260 events in one sheet is a bit too much.

    I would definitely move all enemy AI stuff to a separate sheet.

    4. Create a new layout, name it Assets and dump all your objects to that layout. I'm talking about shadows, corpses, steps, range circles, text captions etc.

    C2 requires one instance of each object to be added to a layout, but it shouldn't necessarily be your main Game layout.

    Sorry, I didn't get to the AI part, I think you need to fix all these issues with your project first...

  • Sure, if you share the capx here or PM me, I can take a look.

  • Here is formula for positioning sprites in a circle:

    X=centerX+RADIUS*cos(angle)

    Y=centerY+RADIUS*sin(angle)

    If you change "angle" from 0 to 360, you'll have full circle.

  • Here is a demo:

    https://www.dropbox.com/s/lgjr9t2nck4b2 ... .capx?dl=0

    And another one with several different methods of spawning:

    https://www.dropbox.com/s/0jptlam49u7ug ... .capx?dl=0

  • The easiest way to do this is to put a bunch of invisible sprites - SpawnPoints.

    Then you can do something like this:

    Every 2 seconds
    Repeat round(random(10,15)) times
         System-> Pick random instance of SpawnPoint :  SpawnPoint spawn Enemy
    [/code:2v7a2cd3]
    
    This code is not very good because the same SpawnPoint may be selected several times and spawned enemies will overlap.
    A better solution would be adding Timer behavior to SpawnPoint. Each SpawnPoint instance will be running its own timer and spawning enemies on timer event. 
    You can also add a condition to check if there are other enemies within X pixels from the SpawnPoint before spawning a new enemy.
  • Try "For each" as a sub-event:

    Door overlapping Ground
        For each Ground      ....
    [/code:2olscttg]
  • Not sure if this advice will be helpful..

    In my game, which is also quite a big project, I have lots of separate event sheets for different things - Audio, Background, Enemies, Shop, Coins etc.

    Almost all of them have "Init()" function, which resets static variables, enables/disables groups and does other things like that.

    On start of each level I call these functions - BackgroundInit(), EnemiesInit() etc.

    This helps to keep things organized.

    Changing state for several hundreds of groups at once doesn't seem like a good idea.

    If you think it's the only way, you can try this:

    Make a list of all groups. (to automate this task you can search for "event-group" tag in .xml files of the project using software like Notepad+)

    On start of the game, loop through this list and save the initial state of each group in an array or dictionary.

    Then you can use this data to reset all groups to their initial state.

    Or you can include the default state into each group's name. For example "Player controls #D", where "#D" at the end means "disabled by default".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I made this demo for another post recently:

    https://www.dropbox.com/s/0ex32akdcl7s2 ... .capx?dl=0

    You'll need CSV plugin to open it:

    plugin-csv-csv2array-csv2dictionary_t64326

    As for the button, you can change its appearance with CSS, but I prefer using sprites.

  • Can you try this -

    Create a new empty layout, set it as first layout in project properties. Then preview your project on mobile. Will it still take 4 minutes?

  • I don't have an answer for you, just curious - how slow is it?

    My capx is 15Mb and takes about 5 seconds to load when previewing on my Android phone.

  • Put A and B on the same layer, B above A.

    Set blend mode for B to "Source in"

  • Uglypenguin

    I forgot one thing - in the first two events you need to add "For each enemy":

    Enemy NOT overlapping NoticeRange   
    and Enemy isSearching=false   
        For each enemy                    Function call "StartSearch" (parameter: Enemy.UID)
    [/code:10fox8yi]