monitz87's Forum Posts

  • You could try something like having the Aces to total 11 by default and then using the conditional expression. Let's say you already have the summed total in a local variable called CurrentTotal, and you're just missing the Ace (which you can simply leave for last by ordering cards in the player's hand by ascending value.

    You could do something like

    CurrentTotal = CurrentTotal + Ace.Value > 21 ? CurrentTotal + 1 : CurrentTotal + Ace.Value

  • I believe it's a precision thing. The chance for the enemy's sprite X position to be actually EQUAL to the image point X just when you're checking is pretty slim. You should work with approximate ranges, like so:

    enemy_bbox X < Player_Target.ImagePointX(1) - 2

    enemy_bbox X > Player_Target.ImagePoint(1) + 2

    This checks if the enemy is within a 2 pixel distance from the point. The thing is, you cannot have both AND and OR conditions within the same event, so you will have to use another subevent to check for image point #2, and then either repeat the same actions in both subevents, use a 'isCloseEnough' variable and set it to 1 when the enemy is inside either of the ranges, then do the actions in a subevent with the condition isCloseEnough = 1, or (which I think is the better solution) create a function which takes two X values and a range, returns 1 if they are within the range, or 0 if they are not, and then use System Compare two values like so

    System Function.Call("IsWithinRange", enemy_bbox.X, Player_Target.ImagePointX(1), 2) = 1

    -or-

    System Function.Call("IsWithinRange", enemy_bbox.X, Player_Target.ImagePointX(2), 2) = 1

  • Also the chances that that values match exactly are slim. The usual technique is to use collision or overlap checks, possibly with hidden objects, positioned to the image-points.

    That's normally true, but we don't know exactly how he's handling his movement, so maybe it's just that precise.

    In any case, blackhornet is right, you shouldn't trouble yourself with manual collision detecting, since the engine does that quite well by itself

  • What do you mean with "physics don't happen in the same speed"?

    In any case, another way of doing it would be shooting an invisible ball with the same physics properties as your actual ball a little before, in the same conditions (speed, angle, etc), and check if that one hits.

    The other way would be doing the actual calculations yourself, but that defeats the purpose of having a physics engine.

  • I think your

    "Enemybbox (inverted) X = Player_Target.ImagePointX(1) | Player_Target.ImagePointX(2)"

    condition is written the wrong way

    What you want to do is

    Enemybbox (inverted) X = Player_Target.ImagePointX(1)

    Enemybbox (inverted) X = Player_Target.ImagePointX(2)

    And if you want to invert the whole condition (to check if they are actually touching) you should do

    Enemybbox X = Player_Target.ImagePointX(1)

    -or-

    Enemybbox X = Player_Target.ImagePointX(2)

  • You can do a neater version of the function using the "Array -> For each XY element" condition instead of a nested for, but this way is more efficient because it loops backwards on the array and stops as soon as it finds the last element that matches your search.

    There's a slight problem with this however: this implementation assumes that rows have higher priority in the ordering of elements than columns. This means that in this array

    0 2 4

    3 5 2

    4 2 1

    The 'last' 2 would be the one on (1,2), and so LastYIndexOf(2) would return 2

    While if you gave higher priority to columns, the last element would actually be the 2 on (2,1) and so LastYIndexOf(2) would return 1

    You have to take this into consideration when filling your array. It's not a big problem though, since general convention is to give rows higher priority anyways.

  • Have another variable isWithinObjectiveTime which is set to 1 as soon as the objective starts, and set it to 0 after the objective time has ellapsed. You can do something like this

    And then add a condition to check if isWithinObjectiveTime is 1 in the event that checks for a kill.

    I'm guessing you want to have multiple objectives at the same time. In that case, you should create an 'Objective' object, have objectiveTime and isWithinObjectiveTime as instance variables, and try using the timer behavior (which does the same thing as Every X seconds, but on an individual level for each object

  • zatyka 's solution is exactly what I would propose. Any other solutions would be just doing what the ordered for each does in a more roundabout way

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you tried using a global variable and adding 1 to it every time the player gets a kill within the alloted time period?

  • Yeah, families are definitely the way to go. Barring that, I think you're gonna waste a lot of time finding a suitable solution to your problem, only to scrap it all once you get the full version.

    What are you using to store your path? I can't see your capx because I'm not at my computer :c

  • You can try adding a "Stop" boolean variable to your enemy object, and have this check in a base level event

    Enemy moveTo is moving

    Enemy is Stop

    and use the moveTo Stop action to make it stop moving and then do whatever you wish

  • Exactly. Is there any way to get this check for the Y-Axis?

    you can implement your own YIndexOf function and then call it in expressions with Function.Call("YIndexOf", Array.UID, element)

  • The System -> For Each condition runs once for every instance of the Object Type you pick. In that particular case case you are making the event loop through all your Array instances (of which you only have one). If you wish to loop through the array elements, you have two options:

    Use the Array -> For Each XY element condition (you can use the Array.CurValue, Array.CurX and Array.CurY expressions within the event to access the current element, current x index and current y index respectively)

    Use two nested System -> For events from 0 to 99 and access the elements using the Array.At expression with loopindex like so:

    System -> For "X" from 0 to 99

    System -> For "Y" from 0 to 99

    ........ Do something with Array.At(loopindex("X"), loopindex("Y"))

  • lastIndexOf gives you the X index of the last match of the value you are searching for.

    So, if your bidimensional array is

    1 2 1 2

    3 4 5 6

    7 2 1 5

    lastIndexOf(7) should return 0, because that is the X index of the last appearance of the value 7

  • The keyboard object has a "Keyboard.LastKeyCode" expression which returns a number representing the last key pressed (which you can store in a variable), and a "On key code pressed" trigger which receives the key code as a parameter. You can create variables to store the KeyCodes currently assigned to each action in your custom controls, and then use the "On key code pressed" trigger to execute them.

    I attached an example capx