How to set up a Destroyer + it's turrets?

This forum is currently in read-only mode.
From the Asset Store
It's here!
$4.95 USD
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • I have destroyer ships shooting at each other.

    The enemy destroyers have one AI and behavior script.

    These enemy destroyers have multiple turrets on them.

    Each turret has it's own set of sprites, events, AI, targeting, etc..

    (The turrets are set up without turret behavior so they are using some custom sprites for collision detection, etc..)

    How to best set up one destroyer ship 'template' (1 AI for destroyer + 1 turret w. behavior then multiply that turret on the ship) so that I can multiply these destroyers, spawning a second destroyer, which has all turrets set up like the first one and both are attacking the player ship?

    Should I create the two destroyers by hand, positioning all sprites on them for the turret-parts and so make them hard-coded? Like one bunch of commands would be Enemy_Destroyer_1,(on it the turrets with their own behavior) all hard-coded/hand-positioned and it moves, for ex. via global variables and create all Enemy_Destroyer_1..2..X by hand?

    Or is there a way in Construct v1.2 to set up one destroyer template, then just spawn two of this template at different battlefield coordinates, both ship's behaviors fully working, they can attack, maneuver, etc.. as was coded in the template?

  • I'm confused. Can't seem to set up the turrets properly.

    Each turret has 4 sprite parts. If I want to have 5 turrets, must I create 5x4 sprites for all turrets at the beginning of the layout? pfff.. <img src="smileys/smiley7.gif" border="0" align="middle" />

    I want to position all 4 turrets (sprite sets) at different places.

  • you can use containers if each turret is unique, but if you have lets say 4 turrets that are all the "same" sprite, as in a single object type containers may not be the best way. you'll have to give each ship an id, and then give the turrets two variables, one for their ID, and one for their ship ID. using events youll have to make a

    for each ship

    turrets variable 'ship id'=ships('ID')

    -ACTION: TURRET SET POSITION TO SHIP, IMAGE POINT = ('TURRET POS ID')

    you could try it with or without the for each, not sure if it'll make a difference, but sometimes it does depending on what your doing.

    so for each ship, lets say if they had 4 turrets, you'd have 4 turret objects that youd need to create, and give them each the same 'SHIP ID' when you spawn them (you would do this at the start of the layout, or when you spawn a ship by creating 4 instances and giving them their given ships id as 'SHIP ID'), and then numbering them 1 2 3 4 for their TURRET POS ID. that variable would tell each turret what exactly they are on their given ship. of course if you were to follow everything i said youd need to give the ship 4 image points. i realize this is a little confusing to describe in words, so if you have any trouble just reply :D

  • <img src="http://img143.imageshack.us/img143/7615/turret.jpg" border="0" />

    The turrets are created and placed okay. How to move them together with the starship now?

    Every tick do what? Couldn't find a command like:

    For i=1 to 4 Move_object(Turret.i, MyDestroyer.ImagePoint.i)

    ?

  • OK, I finally managed it. Gaaarrhhh..<img src="smileys/smiley35.gif" border="0" align="middle" /> Construct has a very original way of using private variables to move/handle objects created on the fly..

  • I'm glad you handled well. I just learnt something :D <img src="smileys/smiley31.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you using loops to position your turrets on the destroyer?

    If you are, you could just use an 'always' event and sub events, like this;

    Always

    (Sub Event) TurretID = 1   Set turret pos to ship1 imagepoint 1

    (Sub Event) TurretID = 2   Set turret pos to ship1 imagepoint 2

    And so on. You don't have to do it this way, you got it working.

    It just seemed as though you were going to use loops to

    position your turrets, when you could easily do that with an

    'always' event. That's how I would have done it, but you got it

    working, so good for you :)

  • Thanks for the idea, but I couldn't find the "Always" event in Construct v1.2. It would really be nicer with "Always"

    Edit: Found always among events. Thank You!

  • I have a turret sprite, which I destroy at the beginning of the layout.

    At runtime 4 copies of this is created as can be seen above. I gave them private variables.

    Here is the problem:

    It seems, the created turret sprites' .Angle properties cannot be accessed via their private variables ?

    I want to narrow down the angle range of the turrets so they can only rotate away from the ship in a ~110? wide angle. The turrets must not turn toward the other turrets beside them, plus they must of course not turn inside, the deck the ship, so they cannot shoot their own destroyer's control towers into pieces.

    I want to get each turrets current Angle, compare and don't allow it to increase or decrease too much.

    Turret.Angle('ID')

    Turret('ID').Angle

    Turret.Value('ID') & Turret.Angle

    give errors.

    Here an "if" would be helpful, like:

    If (turret('ID').Angle > 320)

       Turret('ID').Angle--;

    Is there any way to access & compare private variables of created objects? I want a lot of turrets created at begin of layout so making and adding 50 unique turrets sprites by hand is not very flexible.

    I thought of maybe making a global variable, create a loop but i can't access the created objects properties AND private variable at the same time.

    I can only set its position by directly accessing the private variable:

    Turret: Set position to object MyDestroyer image point 'ID'

    "Compare angle" does not give access to the created turrets private variable so I could identify, which turrets angle should be compared.

    Compare private variable gives errors, when I try to give it

    Turret.Angle('ID')

    Turret('ID').Angle

    <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Okay, I got it working. Created a loop, which picked only turrets with certain private variables, guess it can be done with arrays too in case of unique ship structures. Then simply with a sub-event I compared Turret.Angle and with "set angle" set the turret angle. It turns out this way "set angle" affects only the turret on which the loop count is at the moment. Good!

    Managed to create an angle range with too loops, so the turrets don't turn inward, over ports of the ship. From this point on it should be an INI file, or:

    1. one row of turrets at left port

    2. other row for right port.

    3. few turrets on the bow

    4. few turrets on the stern

    And the angle-ranges can now be set for each row/group. Hmm..

    This means that I have to begin creating eye-catching graphics design - which has to get attention even in thumbnail size so people click on the screenshots and get hooked - with only 1-2 years of experience, which is not enough.

    Still, failure is not an option, onward is the only way! Albeit very rocky. The greatest task, making eyecandy, cannot be regulated with easy-made Construct commands. Steep slope. So many newbies are falling into the depths below, like me. Game industry nowadays seems like the Wild-Wild West.. :(( <img src="smileys/smiley18.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)