Arcticus's Recent Forum Activity

  • For the distance, you can use the System object's distance between points expression in the math section.

    it's formatted thusly;

    distance(x1, y1, x2, y2)

    The x1 and y1 refer to the first object to compare and the x2 and y2 refer to the second object, so in the case, the enemy would probably be x1, y1 and the player would be x2, y2.

    The condition I would use is the 'Pick by comparison' under the enemy object's conditions list in the 'Pick' category. So it would look something like this:

    Pick by comparison

    Value 1: distance(enemy.X, enemy.Y, Player.X, Player.Y)

    Is lower or equal to

    Value 2: <insert distance in pixels you want the enemy to notice you>

    Then insert the follow/attack action that you're currently using.

    IF you're using a version of construct that does not have the system object's 'distance between points' function, simply use pythagora's theorem

    So replace distance(x1, y1, x2, y2) with: (it's a little more complicated)

    sqrt(((enemy.X - player.X) ^ 2) + ((enemy.Y - player.Y) ^ 2))

    ^^ This is actually simpler than it looks, in plain english it's:

    The square root of; the distance between the enemy and player's X coordinates squared plus the distance between the enemy and player's Y coordinates squared. High school maths ftw

    I hope this has been useful

  • You could probably change the firing event into the 'blink' event. This is a pretty long post so I'll bold the more important stuff in my rants.

    So if we use something similar to my previous example:

    if player is within range of the gun

    --->Look in the direction of the player

    <subevent>gunthing animation Blink is not playing

    ------>add timedelta to gunthing.Value('Timer')

    if gunthing.Value('Timer') is greater or equal to 1000

    if gunthing animation Blink is not playing

    --->Change gunthing animation to blink

    --->Set gunthing.Value('Timer') to 0

    If gunthing is playing 'Blink' animation

    --->add timedelta to gunthing.Value('Timer')

    <subevent>if gunthing.Value('Timer') is greater or equal to 1000 (or however long you want the blink to last)

    --->Inset your gun shooting code here

    --->Set gunthing.Value('Timer') to 0

    Once again, I've been naughty and not actually tested this, but this where I would begin if I was about to try and achieve what you're after. To achieve the 'if animation blink is not playing' condition, add a condition 'If animation blink IS playing', then right click on it and click on 'invert condition'. This makes it so the event triggers when the OPPOSITE of what is listed in the condition is true.

    I don't know how much you know about subevents, but I'm using two there, that's where you either click on one event, click on it again and then select, 'create new subevent' or you drag an existing event underneath and to the side of another existing event (so it's indented). There's probably smoother ways to do this code, but I made it so the blink has its own timer check too in case you want it shorter, like 500.

    The thing with subevents, they behave exactly like a normal event, except that the event that they're indented from has to also be true. I basically threw that in there for two reasons, I'm so used to doing it these days, and it cuts down on having the same condition in multiple events:

    For example:

    Instead of this:

    If player is running

    if jump is pressed

    --->do this

    If player is running

    If fire is pressed

    --->do something else

    You can condense this using subevents (it may seem like not a whole lot at the moment, but in larger projects it really helps):

    If player is running

    <subevent>If jump is pressed

    ------>Do this

    <subevent>If fire is pressed

    ------>Do something else

    The advantage, besides saving space, you can also use the event 'If player is running' in the above example to also have its own action too when neither jump or fire is pressed and just running is playing, if that makes any sense.

    I hope this has helped and that I've said it in an understandable manner Sorry if it's miles long haha. If you have further questions or need me to translate or illustrate what I mean, I'll be happy to help.

  • The way I would do it, is just make two more global variables

    something like:

    savedX

    savedY

    and when you're saving the globals and about to swap layouts:

    set savedX to (Square.X - Circle.X) * -1

    set savedY to (Square.Y - Circle.Y) * -1

    ^ This will give you the Circle's 'offset' from the Square's position

    When you load up the new layout

    set Circle.X to Square.X + global('savedX')

    set Circle.Y to Square.Y + global('savedY')

    I've only -kinda- tested this, it should work though

  • You could have drawn the gun facing left, if you draw it facing right, it should work.

    Construct treats facing right as the 'default' rotation

  • Hey there, just as an additional thought;

    If you wanted to make it so each gun fired at a different time to each other, but still at regular intervals (assuming you have multiple guns going), you could always give the gun object a private variable called like 'Timer' and do something like this (semi-pseudocode):

    if player is within range of the gun

    --->add timedelta to gunthing.Value('Timer')

    if gunthing.Value('Timer') is greater or equal to 1000

    -->Do your shooting code here

    -->Set gunthing.Value('Timer') to 0

    if player is out of range of gun

    -->Set gunthing.Value('Timer') to 0

    (or if you want the gun to fire as soon as you're in range)

    --->Set gunthing.Value('Timer') to 999

    I know it's probably pretty sloppy and I haven't actually tested it, but it should work close enough, obviously you'd use something like the system object's 'calculate distance between objects' condition under math (i think that's what it's called) to determine the range of the gun.

    Also i -think- 1000 is the value for one second, so if you wanted two seconds, you would replace that value with 2000 or whatever suits your fancy. The best approach would be to make a global variable called something like 'gunInterval' and use its value instead of rewriting code.

    If you have questions about all that garbage I just said, feel free to ask

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How was it with performance? What would happen if you had a couple of hundred of those mini canvases? That's a big ask I know, I don't really need anything like that at the moment, I'm really just wondering if a quick, easy, per object masking layer type thing is available at the moment

  • Hey all, this is partially a help request and partially a suggestion, depending on what the answer is heheh. Sorry if this has been covered somewhere, as usual, I did a quick search on it beforehand and didn't find much.

    So what I'm wondering is, yes we can do layer masking and stuff, but is it possible to mask an individual object? And by extension, multiple objects on the same layer? By that I mean, similar to an alpha map.

    Perhaps a better question would be, do objects have an individual opacity mask? If so, how do I use it?

    If not....

    I suggest that construct (probably construct 2) have an opacity mask option of some kind for sprites

    Potential possibilities include:

    Clever shadow casting

    Cool dissolve effects

    Destructible Sprites! Imagine shooting a hole in a tank!

    Anything a cool, crazy community could think up!

  • Ah rightio

    That's a real drag then, thanks Arima

    Yeah Newt, let's just say I'm using one 'Box' Sprite but using families to do all the coding for it and the .Count would work fine, as soon as I did something like add another sprite, 'Box2' for example, the .Count would fall over and only return 1

  • Ah I get it.

    The for each method works a little better for what I need.

    Thanks for your input guys

    The actual counting isn't the real issue for me here, it's that I really thought Family.Count should have done it, the weirdest part was that it DID do the trick fine, until I added a different object to the family. I don't actually think families are supposed to behave this way, correct?

    I haven't submitted it to the tracker or anything as yet because I haven't been around here a lot recently so I'm not entirely sure if this has been addressed yet and I'm posting to see what other people have to say about the issue. If other people are having issues with it, I'd glady pop it on there

  • I haven't tried it yet, but I would imagine a

    For each FamilyName

    Add one to some variable

    would work, but it's just odd that it works fine with one object in the family and breaks when there's more than one

    (By one object in the family, I mean there is one object that I've used many times, I intend to put many different objects in this family)

  • (TL;DR = read bold)

    Hey everyone, I'm not sure if this is addressed somewhere, I did have a look around and found some pretty old posts.

    I'm just wondering what's the go with Family.Count?

    I've been using it recently to count all of the objects in a family, and it was actually doing so quite fine (I had read somewhere that Family.Count would return 1 due to you only having one 'instance' of the family object in the game)

    So yeah, it was working completely fine counting all my objects UNTIL I put a different object in the family. Up to this point, all the objects in the family were different instances of the same test object and I was coding it with families just to save time for when I do in fact have different sprites in the family. Once I put a different Sprite in there, Family.Count ONLY returns 1.

    I know I'll probably have to do a For each addition thingy in the meantime, but I kinda don't think the .count function should work completely fine in one case and then break in another...

    Any help?

  • It's looking REALLY good, I can't wait for this game

Arcticus's avatar

Arcticus

Member since 23 Nov, 2007

None one is following Arcticus yet!

Trophy Case

Arcticus has no trophies yet!

How to earn trophies