R0J0hound's Forum Posts

  • Test 3: Scorched earth style terrain.

    dropbox.com/s/bjnapmhuy5vonch/burntEarth.capx

    It implements single color terrain that you can erase and draw. It's done with sprites used for one pixel wide vertical spans. I thought it faster than using a sprite per pixel. Construct's renderer really is quite speedy, but the event sheet is pretty slow when manipulating that many objects.

    Since this is done with sprites it will work with the platform behavior. Not sure about the physics behavior since it doesn't behave well with changing sizes of sprites.

    -cheers

  • Thanks.

    No, I've only briefly messed with babylon.js. I don't really have any 3d assets to make much use of it. Besides I think Construct only gets in the way when using it. It's better suited to be used directly without construct at all. The goal in the example here was to work within Construct's renderer, as well as try out interpolating between frames.

    For 3d to happily coexist in construct with it's renderer there are four approaches that i've seen.

    1. use a separate html5 canvas stacked on top of constructs canvas.

    2. still use a separate canvas, but it's hidden and it's copied to a texture that is drawn by Construct's renderer.

    3. Just utilize Construct's renderer to draw the 3d stuff. Limited, but that's what is happening here.

    4. Use custom webgl to render onto the same canvas that construct's renderer uses, but the complexity here is any webgl state that is changed needs to be restored when done. Best done with custom webgl instead of babylon.js, because construct's renderer and babylon.js both work as if they were the only ones utilizing the canvas.

    Anyways, 3d is still one of my many interests. Got a gltf importer partially working. The format makes more sense now, but I shelved it before making it render anything.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It was just an example, there's also pngout, pngcrush and for lossy compression pngquant. I haven't tried any of them honestly. Looks like you can fiddle with the parameters to get better results for different images. Likely it's the tech behind these png compression sites, at least that's my suspicion.

  • No idea what png compression c2 or 3 uses but as a user you could manually just do the compression with a tool like

    optipng.sourceforge.net

    Instead of an online tool.

  • Test2:

    dropbox.com/s/ai2pzste5q08hkh/perpixel_col4.capx

    Per pixel collision detection with collision normal calculation.

    Also included some simplish physics to interact. Once the arrays are loaded the balls will never miss a collision as they move a pixel at a time in a loop.

    Tech details:

    The wall sprites are in a container with arrays. When the capx runs some js is run that populates the arrays with the collision and normal for each pixel. Optionally it can expand the collision mask by another sprite.

    Note: The js code probably won't work when exporting so some other functions are included to save/load the pixel arrays.

    -cheers

  • It’s just further reading. Anyways the gist is numbers only can have 15-17 significant digits.

    So you’re running into the limit and it’s rounding.

  • I’d imagine it has to do with how numbers in construct are 64bit floating point numbers that only use at most 15-17 significant digits.

    en.m.wikipedia.org/wiki/Double-precision_floating-point_format

  • Besides using a tilemp with 1x1 tiles, here is a different approach.

    It parses a svg file and uses sprites to make lines around the shapes to use as collisons.

    Added the original image too as a png. Had to fiddle with scale and position to make them line up, so that's not 100% ideal.

    dropbox.com/s/43e80boez5lg33b/svg_physics.capx

  • Tomycase

    The plugin was made to utilize the non webgl renderer. Even with webgl on it uses the non webgl drawing of plugins. Things like tilemap sets up itself internally different with webgl. So in short it won't work, although you could try the paster object which takes advantage of webgl and is similar.

    marceloborghi

    That's out of the scope of what I can help with. I'll answer questions about the plugin here and there, but I've since abandoned this. Anyways, you'll have to debug it more to see why it doesn't work. I usually have to test things a bit at a time to find out what works and where exactly it breaks and try to figure out why.

  • It’s roughly the same solution in C2. Only the canvas plugin there makes it too slow to scan the pixels.

    A tilemap with 1x1 tiles is the simplest way to work with physics, chipmunk or even just constructs collision system.

    In c2 I’ve used js to copy the pixels of a sprites image to a c2 array. It dips into the runtime though and won’t work with minifying unless it was made into a plugin. It would look different for c3 but I don’t use that. Besides the canvas in c3 provides access to pixels anyway.

    An alternate to 1x1 tiles with a tilemap is something called image tracing, or basically taking a raster image and converting it to vector. Then you’d set the collision polygon to that from js.

    Or instead of messing with js at all you could take the image of the maze, open it in something like Inkscape, convert it to vectors (it’s a one click thing there), then save it into a simple to parse format like stl.

    Then in construct add events to load the file and create a bunch of sprites stretched as lines to make up the edges.

  • You have to do something along the lines of.

    1. drawing the mask to a canvas

    2. make a tilemap with 1x1 tiles

    3. loop over the canvas pixels and set the tilemap tiles from that.

    At least for C3 i'd imagine that'd work.

  • totoe

    1. In blender you just export as obj, check “animation” and it will spit out an obj file per frame.

    2. In that converter capx you need to add all those obj files to the files folder, set NUMFRAMES to the number of files, and NUMVERTS to the number of vertices.

    3. In the Ajax call you need to change the name of the files. In the capx it says:

    “Fire_elemental_”&zerpad(loopindex, 6)

    But you’d need to change it to whatever the files are named.

    4. Run it and when it’s done you’ll get a json of the array that you can save to a file. You load that and one obj file of the model in the main capx.

    It all was only done with one object in mind at the moment. But in blender it looks like you can specify what to export and such.

  • I think the biggest issue is getting the 3D assets to do stuff with. That and an idea what kind of game to do. :) I get caught up on the tech side of things.

    Reusing the 2d movements in construct is a handy idea but I guess we could also go on a tangent of doing our own collision detection. Javascript does make it handy to make reusable chunks of code over events.

    I guess the next step would be to make it work with multiple objects and come up with some kind of game. Maybe walk around and slap balls around?

  • Test 1: Animated 3d mesh.

    dropbox.com/s/b1u15kjc0b3vgyh/objAnimation2.capx

    Tool capx to convert a 3d animation from many obj files to an array json:

    dropbox.com/s/m2lw100wf0fqmkr/objAnimation2json.capx

    This is yet another 3d test in c2. The main feature is it is a distorted mesh animation. The idea came about from some recent 3d tests on discord. Loading a simple 3d file format like .obj is simple enough but there is no good simple alternative for a 3d animation. Sure there are .dae .fbx and .glb, but they aren't as simple load.

    This example is done by saving an animation to multiple obj files, then the tool capx is used to fill an array with just the vertex locations for every frame. That is loaded faster in the main capx, not to mention is a bit more compact. Then it's a matter of lerping the vertices from one frame to another to animate.

    There are two modes in the capx controlled by the QUADDRAW constant. When off(or 0) the capx will just draw the animation as a wire frame, which is slower, but should work in C3 since it doesn't do anything fiddly.

    With it on it utilizes mostly javascript to do the drawing and transformation of points. The drawing hijacks an objects drawing function and just uses c2's renderer to draw lots of quads. Other than that the rest is just to make transforming all the vertices faster than doing it via events.

    Notes:

    * There is a pause when it starts as it loads the animation json and parses one object file to get the faces and texture coordinates. The obj parsing can probably be made quicker and maybe cleaner by dropping it into js. As is the most useful speedup was avoiding tokenat to get each line of the file.

    * The javascript used reaches into the c2 runtime and won't work after minifying unfortunately.

    Anyways, this whole thing probably isn't useful for anything but it may be fun for someone to play around with and get some ideas.

    I'll see if i can add to this topic other c2 related tests as i come up with them,

    -cheers

  • You can do it with three variables vx, vy, and t. t is the number of seconds you want it to take to hit the player and vx,vy are the horizontal and vertical velocities we will calculate from t. anyway the arrow launch will look like this:

    create arrow at (enemy.x, enemy.y)

    t = 1

    vx = (player.X-enemy.X)/t

    vy = (player.y-enemy.y)/t-arrow.Bullet.Gravity*t/2

    arrow: bullet: set speed distance(0,0,xv,vy)

    arrow: bullet: set angle of motion to angle(0,0,xv,vy)

    dropbox.com/s/68mhi9hrwsjf7fl/bullet_proj_calc.capx