fisholith's Recent Forum Activity

  • No problem.

  • Hey ThunderLion,

    One way you might do this is by changing the zoom level based on the player's distance from the center of the layout.

    You can get the distance between points with C2's built-in distance() function.

    e.g. Below is the distance from the center of the layout to the player:

    distance( layoutWidth / 2 , layoutHeight / 2 , Player.X , Player.Y )

    let's call this "playerDistance".

    Below is the distance from the center of the layout to a corner of the layout, (the max possible distance from the center):

    distance( 0 , 0 , layoutWidth / 2 , layoutHeight / 2 )

    let's call this "maxDistance".

    If the layout is 1000 x 1000 pixels, then the farthest you can get from the middle is 500 px at the middle of a layout edge, and about 700 px in the layout corner.

    (The 700 in this case comes from distance( 0 , 0 , 1000 , 1000 ) ~= 707 ~= 700.)

    So the maxDistance would be about 700.

    Thus, your playerDistance value is going to range from 0 (when the player is in the middle) to 700 (when the player is in the corner), roughly.

    So, if you divide your playerDistance by maxDistance, you get a result that ranges from 0 to 1. (i.e. 0/700 to 700/700)

    Lets call this "normalizedDistance".

    You can set your zoom level to 100 + ( 100 * normalizedDistance )

    With the player in the center of the layout, that expression becomes:

    zoom = 100 + ( 100 * 0 ) ... = 100 + ( 0 ) ... = 100

    With the player in the corner of the layout, that expression becomes:

    zoom = 100 + ( 100 * 1 ) ... = 100 + ( 100 ) ... = 200

    This means your zoom level will smoothly go from 100% to 200%, as the player goes from the center to the corner of the level.

    So the final formula would be:

    zoom = 100 + ( 100 * ( distance( layoutWidth / 2 , layoutHeight / 2 , Player.X , Player.Y ) / distance( 0 , 0 , layoutWidth / 2 , layoutHeight / 2 ) ) )

    Thinking of it in terms of the intermediate variables I described above, the expression evaluates as follows:

    zoom = 100 + ( 100 * ( distance( layoutWidth / 2 , layoutHeight / 2 , Player.X , Player.Y ) / distance( 0 , 0 , layoutWidth / 2 , layoutHeight / 2 ) ) )

    zoom = 100 + ( 100 * ( playerDistance / maxDistance ) )

    zoom = 100 + ( 100 * ( normalizedDistance ) )

    zoom = Some number ranging from 100 to 200 depending on the player's distance from the center of the layout.

  • Ah, I see what you mean.

    And also, thanks.

  • I could be wrong, but I think, in C2 terms, the items that get placed on a layout are "instances" of an object type. So if you copy an instance of an object, you get another instance of that same object type.

  • Depending on the complexity of the detection you want to do, instead of using dedicated detector objects, you could try using the "Is overlapping at offset" condition. It will temporarily move your object to an offset from it's current position and test to see if it's overlapping something there, then move the object back to it's original position before any other events run.

  • 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

  • Try Construct 3

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

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

fisholith's avatar

fisholith

Member since 8 Aug, 2009

Twitter
fisholith has 1 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