R0J0hound's Forum Posts

  • There's a third party 3d plugin that lets you load and rotate any 3d model.

    There's also a third party plugin that lets you rotate any object in 3d.

    You can also utilize distort meshes to do the rotation.

    Here is the only function you need to do rotation. Here it's just xy, but you can modify it to do xz or yz rotation. You can also combine them for a simplified expression.

    newX=x*cos(a)-y*sin(a)

    newY=x*sin(a)+y*cos(a)

    When using distort meshes the points xy position are defined in the 0-1 range so you'd map a layout xy to mesh with:

    meshX = (x-sprite.x)/sprite.width+0.5

    meshY = (y-sprite.y)/sprite.height+0.5

    The 0.5 is when the origin is centered.

    dropbox.com/scl/fi/o65y9e62zd2wmqko554ic/3d_card_flip.c3p

    To make the cards two sided it calculates the normal and does some math to see which side of the card is facing the camera.

  • You can do it with the qarp() expression.

    x=lerp(ax, bx, t)

    y=qarp(ay, (ay+by)/2-400, by, t)

    where ax,ay and bx,by are the two endpoints and t is a variable that you'd gradually change from 0 to 1 and vise versa to go back.

    In the example I just set t to a triangle wave that ping pongs from 0 to 1 and back with abs((time/duration+1)%2-1) since it matches your example.

    alternately you could just do set t to clamp(self.t+dir*dt/duration, 0, 1) where dir is -1 or 1, and the clamp avoids overshoot. You could then compare if t is 0 or 1 to see where it's landed.

    dropbox.com/scl/fi/zxa5wnncpmhyrovadxia0/jumpArc.c3p

  • The sprite's outline shows because it's drawn before the walls. To fix you need to somehow make it draw after the walls. I know 3d layers have a setting to do the drawing based on distance or zorder. Maybe try one of those. In the zorder case you can then set the sprite's zorder to bottom or something like that.

  • The light actually has its own frustum and it may very well be off. Ideally it contains the whole scene.

    But I’ll be honest here it’s unlikely that I’ll be doing any more changes to this plug-in any time soon.

  • How are you placing the dotted lines?

    It looks to just be nodes with a tiledbg stretched between nodes to make the lines.

    You could do an evert like this.

    On clicked on node
    Node overlaps line
    Pick all node
    Node overlaps line
    — Node var=5
    — — set text to “connected”
    — else
    — — set text to “not connected”
  • Fiddled with it a bit and here are my findings.

    There isn't a way to render a scene from a different camera angle in the same frame. If we could there is probably a way to calculate where we'd position the camera from the mirror. The second issue is the drawingCanvas doesn't work with 3d meshes since they have no zbuffer and it doesn't seem to transform 3d relative to itself. We could render one frame from the mirror, save that with canvasSnapshot, and render the next from the game camera, but that is slow and would flicker annoyingly.

    What we can do is duplicate the objects and position them in mirrored locations behind the mirror. We'd want the duplicate objects to only be visible in the mirror so one idea is to have the duplicate objects on a layer with force own texture and have a mask sprite over the shape of the mirror to limit drawing to that area. If all the duplicate objects are behind the mirror this should work fairly well. It will be a problem if any part of the objects are in front of the mirror since the masking will fail then. We can improve that by not duplicating objects that aren't in front of the mirror or culling by a view frustum through the mirror. Still to better fix it we'll need to clip the individual polygons by the mirror, but this requires all your meshes to be done with a distorted sprite per polygon.

    The masking sounds like it should work, and does in the simple mirrored floor case, but I'm curious if we may run into issues with wall mirrors or something.

    Anyways here's a semi-simple floor mirroring test by duplicating things.

    dropbox.com/scl/fi/tg6b00a8oeaiuwaaw7i5u/floor_mirror.c3p

  • Canvas doesn’t seem suitable for that. Try pasting 3d stuff onto it and see that it has no zbuffer so it looks wrong.

    Anyways I’ve seen people do mirrored floors by duplicating the 3d stuff below.

    Another guy did portals by using a mask and duplicating the 3d stuff behind the mask. He didn’t post an example though so you’d have to experiment in that area. It doesn’t seem like it would work but I admittedly don’t understand some subtleties of constructs renderer

  • You can think of it as an xy graph. For each x position you have a formula for y.

    What you have now is basically y=random() which will be jagged no matter what. You can smooth the random by storing random values in a lower resolution array and interpolating with more mesh points.

    So roughly you could have an array with 10 random(-100,100) values and with 100 mesh points you could read from that.

    t = loopindex/100*10

    Y = cosp(array.at(int(t)), array.at(int(t)+1), t-int(t))

    Another is to just jam a bunch of sines together with different frequencies, amplitudes and offsets.

    Y=50*sin(x/50)+ 25*sin(x/13+33)+10*sin(x*5+100)

    Just fiddle with all the values and/or add more sin() till you get a shape you like.

    Another option is to use the advanced random function. With it it has a perlin noise function which is a smoother noise.

    Y= noise(x*k)*100

    Where k is a value to tune the frequency.

    The last step would be convert that to distort mesh units.

    X = loopindex/N*sprite.width+sprite.x

    Y = whatever function you decide to use

    Set mesh point (loopindex,0) absolute (loopindex/N, (Y-sprite.y)/sprite.height

  • Generally you don’t want all the characters in a selected font. A font can have anything from a few characters to the entire Unicode character set of around 4 billion.

    I guess it should be possible to parse a font file and find all the characters defined in it. All the different font formats are documented online.

    But generally with a spritefont you’d only want the characters you use in it. Especially with construct spritefonts since they aren’t packed densely. You can eat up a lot of vram with too many.

    You could make a tool to look at all the text files in a project and list all the unique characters and use that?

  • Construct text don’t use escaped values but JavaScript does. So to use \ in js you’d need \\ with replace(var,"\", "\\") or something.

  • One frame behind would be from double buffering. 2 frames from triple buffering. Guess it’s mostly dependent oh what the browser does, or maybe graphics card settings. No idea if construct does its own buffering on top of that.

    Typically games hide the windows cursor and just position the mouse to hide that.

    Chrome does have a feature when creating a canvas context to be desyncronized, which lets it bypass a lot of the browser’s renderer to be single buffered, but there seem to be drawbacks such as tearing and I’m not sure if other browsers support it.

  • I'd say there is nothing wrong with the way you're doing it. It works and it's easy enough to understand and modify.

    A lot of the events have a similar structure so yeah you could make it so most of it as data instead of all events. That has the benefit of being easier to change how it works with a few events instead of changing all the events. The data can be array/json/xml/something else but it comes down to what you want to do.

  • The c3p file is just a zip file with all the games source as jsons of the events and such.

    The exported project packs all the game into a data json, and the runtime and plugins are minified together.

    Most porting services go the route of generating code from the source, but I think at least one just makes their own runtime which uses the same exported data json. But even if they have tools that automate most of it I think they deal with things case by case since construct is heavily tied to html5 tech.

    In short there is nothing readable that will show how events equate to JavaScript. You’re better off just writing equivalent code from reading the events manually.

  • I tried opening it. No new ideas. Maybe rotate the layer instead of the layout? I ran out of time to fiddle with it. JavaScript won’t provide anything more than what you can do with events.

    I won’t be able to debug it. If the sprite isn’t being drawn where you touch then construct isn’t doing what it should or we just aren’t understanding what is happening. I gave the rotation formula to give a way to correct it. With 90 degree turns the coordinates come out to either

    -touch.y+2*scrollx, touch.x

    Touch.y, -touch.x+2*scrolly

    If it’s not drawing the whole area then check the drawing canvas size.

    If none of that works or doesn’t makes sense then I’m explaining it poorly or missing something.

    Probably best to wait for someone else’s answer at that point.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Rotation is just an extra step. The math to rotate is:

    NewX=(x-centerX)*cos(a)-(y-centerY)*sin(a)+centerX

    NewY=(x-centerX)*sin(a)+(y-centerY)*cos(a)+centerY

    So you’d take the mouse location and rotate it by sprite.angle around the sprite’s location as the center. And you’d just use that rotated mouse location in the steps in the previous post.

    The scaling is already handled.

    You could have it work with the origin in other locations such as centered but it just takes fiddling with the math a bit.