fisholith's Recent Forum Activity

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Hey gwerneck,

    (Edit) I just checked the System >> "angleDiff" expression, and it always gives a zero or positive answer, meaning it doesn't give you the direction of the change in the angle, so it won't work here.

    One possible approach is to calculate the change in angle between ticks,

    store that change in a running total,

    and track that running total instead of tracking the objects rotation property directly.

    Here is a formula that will give you the change in angle as the shortest CW or CCW rotation, and it works seamlessly across the 360-to-0 transition.

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

    Where a and b are your two angles.

    e.g.

    a = 5, b = 355: ... ( ( ( 5 - 355 ) + 180 ) - floor( ( ( 5 - 355 ) + 180 ) / 360 ) * 360 ) - 180 355: ... = 10

    a = 355, b = 5: ... ( ( ( 355 - 5 ) + 180 ) - floor( ( ( 355 - 5 ) + 180 ) / 360 ) * 360 ) - 180 355: ... = -10

    Remember, if you compare two angles with a difference greater than 180 degrees, the angles will be treated as a shorter rotation in the opposite direction.

    e.g. A raw difference of +270 is treated as -90.

    As long as the total distance rotated per tick is less than 180 degrees that shouldn't be a problem though.

    So, to use this in place of directly tracking the object's angle property, you can do the following:

    Create a custom variable "unwrapped_angle".

    Every tick, get the change in angle between ticks, angle_delta( currentAngle , angleRecordedLastTick ), and add it to "unwrapped_angle".

    Then you should be able to use the unwrapped_angle in place of the objects built-in angle property.

  • I tested out the capx in FF, Chrome, NodeWebkit, and IE.

    I seem to get the same additive blending effect in FF.

    Below is an image showing screenshot comparisons of the four platforms I tested.

    I changed the background image to a stone texture with a sharply defined edge, to make the FireFox blending behavior easier to see.

    [attachment=0:1iybqo88][/attachment:1iybqo88]

    At the far right is a recreation of the FF example composed entirely in Photoshop, with the Logo set to additive (Linear Dodge) blend, and overlapping the stone. I lined up the recreation to match the FF example, down to the pixel, and the resulting Photoshop recreation is exactly identical to the FF version.

    So it looks like FF really is using the additive blending mode for some reason.

    FF: v35.0

    Chrome: v40.0.2214.93 m

    Hope this helps out.

  • Problem Description

    When previewing in NodeWebkit,

    and receiving C2's "Cannot create an instance" error message,

    the bottom line of the paragraph is chopped off.

    The popup appears in the form of a Windows alert popup, (I'm using Windows 7)

    This bug only seems to occur in NodeWebkit. When previewing in Firefox or Chrome, the entire text is fully readable and is NOT chopped.

    The image below shows how the error popup (top of image) appears on my computer.

    [attachment=0:3rxed8ev]No instances error.png[/attachment:3rxed8ev]

    Also seen in the image, is a program called GetWindowText (bottom of image) which I used to extract the popup text so I could read the entire message. That was before I realized that the chopping issue seems to only occur in NodeWebkit.

    Attach a Capx

    [attachment=1:3rxed8ev]bug - NodeWebkit - No instances error.capx[/attachment:3rxed8ev]

    Description of Capx

    When you run the capx, it should preview in NodeWebkit and display the chopped error message popup described above.

    (This capx was created by following the "Steps to Reproduce Bug" instructions I included below.

    Except I also drew a little face on the sprite, which is not an included step. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">)

    Steps to Reproduce Bug

    • 1. Create a new project.
    • 2. In the project properties, in the "Configuration Settings" property group, set the "Preview browser" option to "Node-Webkit".
    • 3. In the layout, create and place a new sprite object.
    • 4. Remove the sprite object from the layout, such that the sprite remains in the project's "Object Types" folder, but so that no instances of the object exist in the layout. (You should get a message explaining that you have deleted the last "sprite" instance.)
    • 5. In the event editor, create a new event, with the condition "On start of layout", and the action "Create object sprite on layer 0 at (0,0)".
    • 6. Run a preview of the layout.
    • 7. You should see an error message appear in the form of a Windows alert popup. (I'm using Win7) The bottom line of the text is chopped off. On my computer the last readable words are "To resolve this add at least one".

    Observed Result

    The text of the error message is chopped off at the bottom, and so the last part of the message is missing.

    On my computer the last readable words are "To resolve this add at least one".

    Expected Result

    A popup with the entirety of the message visible.

    The end of the text message, when fully visible, normally reads "To resolve this, add at least one instance of the object to the project, on an unused layout if necessary."

    Affected Browsers

    • NodeWebkit: YES
    • Chrome: NO
    • FireFox: NO
    • Internet Explorer: NO

    Operating System and Service Pack

    Win7 x64 - Pro

    SP1

    Construct 2 Version ID

    Release 195 (64-bit)

    Built at 15:36:00 on Jan 19 2015

    Release notes link: http://www.scirra.com/construct2/releases/r195

  • No problem, glad to help out.

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