ErekT's Forum Posts

  • Ashley:

    What I though I did, and what appears to happen when I run it, was to modify the final render texture to use point sampling instead of linear sampling. That way, when low-quality scaling is turned on and layout scale is 1.0, no linear sampling is applied to any of the displayed graphics as long as they're drawn at integer values. It's meant as a way to allow switching between linear and point sampling during runtime. And it works well for what I intended it to do.

    The reason I posted it here was because it also allows for sub-pixel smoothing when graphics are drawn at non-integers, something I thought could help in the OP's situation; draw at float positions when moving, draw at integers when not. Smooth, but blurred graphics when scrolling/moving.

    Not sure what you mean by referring to property names that don't exist. Which ones?

  • If you're using Node-Webkit savestate files are stored in [User]/AppData/Local/[Your project name]/IndexedDB/

    Don't know about other export options.

  • Animmaniac

    How would you use smoothDt/dt to control global time scale exactly? I've tried both 'Set time scale to 6 * (smoothDt/dt)', and just 'Set to smoothDt/dt'. All I get is a white screen

  • [quote:17zvz6co]Some other game engines like Unity do offer integration plug ins with 'Texture Packer'...but I'm not sure whether this would be useful for Construct or not.

    I think it would. So much quicker to tweak entire sprite sheets if you need to than individual frames. Especially for pixel art, where things like color-swaps for different enemies are common.

  • Cool! Thanks for all the input. I'm learning lots of new things Anyways, here's v2:

    Oops, forgot to set Transmutation to 0 at the second line.

  • Nice! Thanks a lot both of you

  • Just wanted to get some second opinions/tips for a bubble sort function I'm writing. I have ten Character object instances that I want to sort according to where they are along the X axis. Not sure I understand completely how C2 events work when it comes to object instances, but if I got it right I can't reference multiple instances of the same object directly within the same function call. So what I'm doing is run a couple of extra For loops to get to the Character instances I want to reference later, then plunk the values I need from them into local variables that I use for comparison further down the line.

    But that makes for an awful lot of loops within a function that's set to run every tick. I'm worried. Will all this nested looping brutalize weaker computers? Am I doing it wrong/being stupid? Is there a better way? I'd really appreciate any tips or get some reassurance that it's alright

  • How are you doing your camera positioning? I've set up a system that works pretty well for me. The camera, or CamFocus object, will scroll smoothly to a position ahead of the Player object (Character). When it's moved within a certain range of the destination (between 39 and 41) I just snap it into the integer position "round( Character.X + 40 )". The player sprite itself is separate from the Character object and is always drawn at round(Character.X/Y) positions.

    For a camera that's fixed to the player's position at all times, it should be enough to just set camera.x/y to round(player.x/y) and set sprite.x/y to round(player.x/y). If you need a catch-up camera like I do, there's an extra trick you can do that I'll describe below.

    Couple of cave-ats with this tho'.

    One:

    I'm modifying C2's layout.js to make it render to a point-sampled texture. This way I get sharp pixels on integer positions, and interpolated pixels on float positions, even though I've got sampling set to linear in project settings. Only use if you don't mind modifying layout.js every time you update C2. As far as hacking into the official code goes, it's discouraged by Ashley for obvious reasons but this change is entirely cosmetic so I'm pretty much 100% sure it's not gonna break anything.

    Two:

    For a pixel-art game it's not perfect. Like I said, if you just fix the camera position to the player's movement you shouldn't even need to use it. But with a catch-up camera both the player sprite and other moving graphics will get blurred by interpolation until the camera has moved into position. I found that this doesn't look so bad; it's a temporary blur and everything's moving pretty fast so it's not all that noticable.

    Three:

    You need to use low-quality scaling with layout scale = 1 (default) for it to work. But since you're doing a pixel-art game that shouldn't be a problem.

    If you want to try it out, back up layout.js in exporters/html5 and replace these lines:

    Line 540 (inside Layout.prototype.draw = function (ctx)):

    [quote:jiim5lbr]

    if (ctx_changed)

    {

    layout_ctx["webkitImageSmoothingEnabled"] = this.runtime.linearSampling;

    layout_ctx["mozImageSmoothingEnabled"] = this.runtime.linearSampling;

    layout_ctx["msImageSmoothingEnabled"] = this.runtime.linearSampling;

    layout_ctx["imageSmoothingEnabled"] = this.runtime.linearSampling;

    }

    ... with these:

    [quote:jiim5lbr]

    if (ctx_changed)

    {

    // ErekT mod:

    layout_ctx["webkitImageSmoothingEnabled"] = this.runtime.pointSampling;

    layout_ctx["mozImageSmoothingEnabled"] = this.runtime.pointSampling;

    layout_ctx["msImageSmoothingEnabled"] = this.runtime.pointSampling;

    layout_ctx["imageSmoothingEnabled"] = this.runtime.pointSampling;

    }

    And these lines:

    Line 584 (inside Layout.prototype.drawGL = function (glw))

    [quote:jiim5lbr]

    if (render_to_texture)

    {

    // Need another canvas to render to. Ensure it is created.

    if (!this.runtime.layout_tex)

    {

    this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling);

    }

    // Window size has changed (browser fullscreen mode)

    if (this.runtime.layout_tex.c2width !== this.runtime.draw_width || this.runtime.layout_tex.c2height !== this.runtime.draw_height)

    {

    glw.deleteTexture(this.runtime.layout_tex);

    this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling);

    }

    ... with these:

    [quote:jiim5lbr]

    if (render_to_texture)

    {

    // Need another canvas to render to. Ensure it is created.

    if (!this.runtime.layout_tex)

    {

    // ErekT mod

    this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.pointSampling);

    }

    // Window size has changed (browser fullscreen mode)

    if (this.runtime.layout_tex.c2width !== this.runtime.draw_width || this.runtime.layout_tex.c2height !== this.runtime.draw_height)

    {

    glw.deleteTexture(this.runtime.layout_tex);

    // ErekT mod

    this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.pointSampling);

    }

    Then restart C2. Good to go.

    A bonus you get with this is the ability to turn point-sampling on/off during runtime. Just increase layout scale or turn on high-quality scaling to enable linear sampling. It looks exactly the same as with vanilla C2 as far as I can tell.

  • Yeah sprite strips can be imported, but all the animation frames need to have the same width/height and to be evenly spaced. You can't import optimized sprite sheets at the moment, at least as far as I know.

  • No need to build sprite-sheets beforehand (in fact, you can't). Import your image frames into C2 and it'll generate optimized sprite sheets automatically when you export.

  • I think you need to cancel fullscreen first before you can get it to accept a new scale mode with request fullscreen. That's the only way I could get it to work myself.

  • Yeah, the most sure way to get smooth updates for pixel-graphics is to move your player by whole integer increments for every update. Whether or not that's a good solution for you depends on pixel fidelity I guess? You could try moving by 0.5 and round() as well. In theory that means the player moves 1 pixel every second update. Other than that, best way to go is like Tokinsom said and use high-quality scaling/no pixel-rounding. It'll get you non-square pixels but if the screen resolution vs game resolution is high enough it may not be noticable.

  • [quote:s4bmq2mo]I have just found something very absurd. Solves my personal issue. But if chrome is not on my monitor #1 it gets a huge performance hit.

    I've also had weird stuff going on with multiple displays and node-webkit. If I hook up my laptop to a TV with an HDMI cable I suddenly get extremely smooth frame updates, but input lags that feel like a quarter to half a second. This happens even though the TV display is 1900x1080 (or something

    I've tried sqiddster's capx but don't get any noticable input lag in either gpu or cpu lag mode.

    Specs:

    i5 2.66 ghz

    4 gig ram

    intel integrated graphics HD/ Geforce GT 540M

    Windows 7 Home Premium Service pack 1+

  • [quote:trith7gu]Suddenly you end up having to do things like set & compare ID's or use containers, position the enemy to the collision object, give the collision object behaviors and variables instead of the enemy itself, make sure both exist or don't exist together, put them in separate families so one does this and the other does that. Then do you use one collision object for every enemy, or do you make a new one for each enemy? I mean they will have different behaviors and variables and properties so...

    What I'm doing right now. Doable for sure, but a big hassle! Transferring instance variable values back and forth between objects, making sure the right object instance is referenced by comparing ID with the instance variable of a different object, keeping track of em all etc. Makes for convoluted, messy, and bug-prone code. At least in the hands of a programming-impaired person such as myself

    So, +1 for this feature. It would be very useful to a lot of people I think.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If this becomes mainstream for video game graphics I will weep.

    Impressive tech tho.