fisholith's Recent Forum Activity

  • Awesome! Glad to help out.

  • Hey ex32,

    I may be misinterpreting the question, but there are two main ways an object can be copied.

    Duplicate instance

    Select an object instance in the layout, type Ctrl + C to copy the instance, and then Ctrl + V and click to paste the instance.

    This results in a new instance, which will be affected by the same events that affected the old instance.

    Duplicate object

    Right-click an object instance in the layout, from the context menu that pops up, choose "Clone object type", and click to place the first instance of the new object.

    This results in an instance of a new object, which will not be affected by the events that affected the old instance you initially right-clicked.

  • One possibility to prevent the enemy from jumping, when it can't jump far enough to make it over the gap, you can add two more detector objects, placed even farther out.

    After-gap solid detector

    This detector confirms that there's a near-enough solid object on the other side of the gap, that the enemy could get to it by jumping.

    Notice, though, that this will detect a flat landing spot as a solid, but it will also detect a vertical wall the same way, so it's not good enough by itself. (Unless you don't mind the occasional mid air face-plant into a wall)

    Clear jump path detector

    This detector confirms that there's open air above the landing spot, and open air in the jump arc the enemy would take to get there.

    This helps the enemy distinguish between a true landing spot, and a vertical wall. It also prevents them from jumping if the ceiling is too low to make the jump.

  • Hey chromaticcodex,

    One possible approach:

    1. For the exit objects, add a private text variable named "exitName".

    2. For each exit object, set "exitName" to a unique name. ... (e.g. "snakeTunnel", "lavaTunnel", "spikeTunnel", "comfyPillowTunnel")

    3. Do this for each layout, making sure the doors that are supposed to be linked between layouts have matching names.

    4. Now, create a global variable named "gLastExitUsed". ... (globals are unchanged between layouts)

    5. When the player leaves through an exit object, get the text in the exit's "exitName" and store it in the "gLastExitUsed" global.

    6. Jump to the new layout.

    7. On start of layout, pick the exit object with the "exitName" that matches the "gLastExitUsed" global. Place the player at that door, as if they just entered through it.

  • Hey Keijimura,

    You could place the events that handle player controlled movement inside a group, and then disable that group when the text pops up. When the player acknowledges the text, or it finishes displaying, you can then enable the group again allowing the player to move.

    If you don't want to use groups, you could use a Boolean (e.g. bPlayerMovementAllowed) that can be toggled off or on by NPC text events. In the events that handle player movement you would include checks of that Boolean to make sure bPlayerMovementAllowed is true.

  • Hi all, :)

    Regarding ACEs, is there a best practice for implementing a formula that returns a vector?

    I'm building a math plugin, and I was interested in adding an expression to return the intersection point between two lines.

    To return a point, I need to return the X and Y value for that point.

    The issue I'm running into is that C2 Expressions can't return vectors, and even if they could, there's no vector variable type in C2 to my knowledge, so there'd be nowhere to put the vector anyway. So I'm thinking I may have to use a combination of actions and expressions, to set parameters and retrieve the vector components individually.

    Is there a good or standard way to do this?

    Am I overlooking a way to do this purely with expressions?

    It seems technically possible to make an expression that sets internal variables rather than returning a value, but I suspect using the execution of an expression to change the internal state of an object is not encouraged. :D

  • You can do this with two layers, which I'll refer to as "Foreground" and "Background".

    The Foreground layer is arranged above the Background layer, as you'd probably guess.

    On the Foreground layer, place the CharTiles and ColorTiles.

    If we just stop here, the problem is that the Background layer will be tinted by the ColorTiles too, even though the ColorTiles are on a different layer. fortunately there's a solution.

    In the layer panel, select the Foreground layer, and in the property panel, enable "Force own texture".

    This will prevent the multiply blend of the ColorTiles from affecting any other layer, and so the ColorTiles will only colorize the CharTiles.

    For this to work, the char tiles will need to be white text on a transparent background. The ColorTiles will have no effect where they overlap transparency.

    Now you can put whatever you want in on the Background layer and it will show up behind your colorized ANSI characters.

    Since your CharTiles will be under your ColorTiles, you may need to temporarily switch their Z-orders to edit one or the other.

    More on "Force own texture"

    This setting will force the layer to render it's contents starting from a transparent background, instead of starting from the rendered result of all the layers below it. When a "Force own texture" layer has rendered all it's contents, it will then be pasted on top of the rendered result of all the layers below it. This is why blend effects for objects on a "Force own texture" layer will be isolated from other layers.

    Using Black on transparent text

    If you'd rather work with black text on a transparent background, you can replace the ColorTiles' "Multiply" blend effect to a "Screen" blend effect.

    "Screen" blend is identical to "Multiply" blend except flipped upside down in the 0 to 1 color value space. Screen inverts the inputs, multiplies them, and inverts the result.

    i.e. screen( a , b ) = 1 - mult( 1 - a , 1 - b )

    If you screen any image with white(1,1,1,) you'll always get white. Screen an image with black(0,0,0) and you'll always get the original image unchanged. Screen with middle-gray(0.5, 0.5, 0.5), and you'll get all the image's brightness values moved 50% closer to white. Light-gray(0.9, 0.9, 0.9) will move the image's brightness values 90% closer to white.

  • No worries, perfectly legitimate question.

    Multiply blend is one of several "Effects" you can add to objects or layers.

    There are two ways to add an effect to an object:

    • Project panel: In the project panel, in the object folder, right-click the Tilemap object, and choose "Effects..."
    • Property panel: In the layout, select the Tilemap object, and in the property panel, in the "Effects" section, click the blue "Effects" link.

    Once you have the Effect window open, click the plus

    +

    button to add an new effect.

    The effect list should open. In the "Blend" category choose "Multiply".

    And that should do it.

    If you use multiply to overlay color blocks on the ANSI character grid, you'll probably want the ANSI tiles to be white characters on a black background. This way after multiplying them they will be colored characters on a black background.

    The Multiply blend is going to "multiply" color tile RGB values into the ANSI tile RGB values.

    For blending purposes, the RGB values of pixels are treated as ranging from 0.0 (black) to 1.0 (Max).

    e.g.

    White is RGB( 1 , 1 , 1 ).

    Black is RGB( 0 , 0 , 0 ).

    Red is RGB( 1 , 0 , 0 ).

    Gray is RGB( 0.5 , 0.5 , 0.5 ).

    So if you multiply white (1,1,1) by any other color, the result is that other color.

    e.g. (Note: Here I'm using the font-color to differentiate the first color from the second color, rather than to show RGB channel color.)

    white (1,1,1) * red (1,0,0)

    = (1*1 , 0*1 , 0*1)

    which = (1 , 0 , 0)

    which is red.

    Likewise, if you multiply black (0,0,0) with any color, the result is always black, because each channel gets multiplied by 0.

    So if you think about it, whenever you multiply two colors together, the resulting RGB values for a given pixel will never be brighter than the input values, as you'll always be multiplying values in the 0 to 1 range.

    Practically speaking, the effect of multiply blend is like projecting a colored light onto a colored texture.

    Projecting white light onto a colored texture just shows the texture.

    Projecting "black" light (no light) results in solid blackness, for obvious reasons.

    Projecting red light results in green and blue features not being visible, as they'll have an intensity of zero. Essentially, what you'd expect from viewing the texture under red light.

    Side note, for some reason Construct 2's text objects look kind of weird if you add any blend-with-background type effects to your game, but only in the editor. They'll still look fine at runtime.

  • No problem, glad to hear it worked out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey zardaloop,

    As far as I know, if you have events responding to user interaction in the hidden layer, the event's will continue to run normally whether the layer is invisible or not.

    To disable interaction with that layer, you could track down the relevant events relating to that layer, and alter them, so they include a "Layer is visible" condition.

    That way when the layer is invisible, none of the events relevant to that layer will run.

    If there are a lot of events specific to that layer, for instance if it's a show/hide-able menu, you can put all the layer's events inside a group, and toggle the entire event group on and off when you show or hide the layer.

  • One approach that might work is to have two tileset objects, one for ANSI characters and one for color masks.

    You could then multiply-blend the color mask tileset over the character tileset.

    That would allow you to change the character or the color independently, without needing a unique tile for each combination of character and color.

  • Glad I could help out.

    I built an example as well, though it only shows the process of calculating the unwrapped angle.

    I'm afraid it doesn't apply it to a gloriously cucumber rotating cause.

    [attachment=0:2r12h9lh][/attachment:2r12h9lh]

    I checked out the cucumber example. Very cool, as one might expect a cucumber to be.

    Using System > Wait to time travel

    One way to compare the current unwrapedAngle against the 2 seconds old unwrapedAngle is to:

    • Create a custom variable "unwrapedAngleOld".
    • Every tick: System > Wait 2 seconds; and Set unwrapedAngleOld to the current unwrapedAngl value,

    That should make unwrapedAngleOld continuously play back the unwrapedAngle values from 2 seconds ago.

    I have no idea how optimal this is, but I've never seen a performance hit. Granted I'm using a desktop, and it might be a different story on a mobile device.

    Angle delta math

    As for the mathematics behind the angle_delta formula from my previous post, I can hopefully simplify it a bit.

    In my prior post I wrote it out as:

    angle_delta = ( ( ( a - b ) + 180 ) - floor( ( ( a - b ) + 180 ) / 360 ) * 360 ) - 180

    The reason it looks so awful is that the formula contains a mod() function, which I've written out long hand.

    Here is the formula as it appears if you have an appropriate mod() function available:

    mod( ( a , b ) + 180 , 360 ) - 180

    Unfortunatly you don't have the appropriate mod() function in C2 by default, and that's why I wrote it out in expanded ugly form.

    (Further explained in "C2's modulus" section below.)

    That mod formula I'm using above has the following behavior:

    mod( val , div ) ... = ... val - ( floor( val / div ) * div )

    This is a "floored division" style mod.

    Terrible as it might sound, there are a few different versions of the mod formula, all called the same thing, but all slightly different.

    There's a nice chart showing mod variations on the modulus wiki page.

    C2's modulus

    Now, C2 does provide a mod function in the form of the modulus operator "%", and this is essentially just JavaScript's modulus operator.

    Unfortunately not all mod functions work the same way, and JavaScript's built-in mod is a variety that behaves differently depending on whether the val number is positive or negative.

    This will not work for our purposes because we want consistent behavior for both negative and positive numbers. That means JavaScript's mod, and by extension C2's mod can't be used here.

    (I'm actually building my own math utility plugin right now, and I was initially inspired by the lack of a "floored division" mod.)

    Getting "floored division" mod into C2

    Granted the formula does look a lot nicer with the mod(), and it would be nice to be able to use it in C2.

    There is a way, and I show it in the example capx I attached.

    You can use C2's Function object to create a custom "floored division" style mod function.

    • Create an "On function" event with the function name "mod".
    • Add the action "Set return value", and in the expression, use the "floored division" mod formula I described above.
    • Within the expression you'll need to use Function.Param(0) and Function.Param(1) to get the arguments. (Or you'll need to do what I did in the example capx: Store the args in local variables, and use those in the expression, which may be easier to read.)
    • You can then call this custom mod function from another C2 expression.

    Again, you can see this setup in the example capx if you're interested. It does make the angle_delta function much nicer to look at.

    Note that I renamed the Function object from "Function" to "oF", which just makes it easier for me to read expressions that involve the function object.

    I hope that helps clarify some of the stuff I explained a bit hastily in my prior post.

fisholith's avatar

fisholith

Member since 8 Aug, 2009

Twitter
fisholith has 2 followers

Connect with fisholith

Trophy Case

  • 15-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

19/44
How to earn trophies