R0J0hound's Forum Posts

  • 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

  • The force of gravity between objects can be done with:

    F=G*m1*m2/r^2

    Where

    m1 and m2 are the masses of the two objects and r is the distance between them.

    G is a constant. It comes from

    https://en.m.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation

    But since we are not dealing with real world scales we can just fudge it.

    You can try the following. Also to get the moon to orbit you just have to have the perpendicular velocity high enough.

    Global number a=0

    Global number r=0

    Global number f=0

    For each planet

    — set a to angle(moon.x, moon.y, planet.x, planet.y)

    — set r to distance(moon.x, moon.y, planet.x, planet.y)

    — set f to 100 * moon.physics.mass * planet.physics.mass/r^2

    — moon: physics: apply force (f*cos(a), f*sin(a))

  • Thanks but there is no way to send me money. This is just a hobby for fun. A near zero cost hobby at that.

    Anyways, I appreciate the thought.

  • Hi,

    In that capx you can set the camera x,y and angle in event 6. So you can set them to anything you want. You could even just set it to the position and angle of a sprite that you move around with your movement behavior of choice.

    I don't have the mode7 effect installed, nor do I have many third party plugins installed.

    I'll be honest, I'm not going to be able to help with the mode7.fx. I don't like it, and have scrapped it.

  • A second example. Arrow keys to drive. Do a lap to see a ghost of the previous lap.

    dropbox.com/s/635epvwa6yl3oh6/mode7js2.capx

  • Like I've said in the mode7.fx topic I've abandoned it. It does some math to get the look, but it's not clean to make positioning other objects work well.

    But I wanted to play with shaders more, although I don't want to make addons. Anyways here's a mode7 implementation that may be useful. I tried to make it as streamlined as possible.

    construct.net/en/forum/construct-2/your-construct-creations-23/mode7-via-webgl-javascript-155359

  • Here's a test to use custom webgl to do mode7 perspective on a texture.

    * It's free to use.

    * Doesn't use the mode7.fx. It's less fiddly.

    * let's you position objects on the ground.

    * Doesn't work with minifier.

    Look at capx for more usage notes.

    dropbox.com/s/8nqw4dy6z2elaa5/mode7js.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tarek2

    Yeah, that looks like a bug.

    In Event 20 remove the action "node: set dist to dist+2", i forgot to remove that.

    dropbox.com/s/vto9mwobq9uoqsx/power_with_id_multi_source.capx

    HolidayExplanation

    The third example, with that bug fixed, works best for evenly spreading out the power.

    I modified the example to transfer where the power is coming from and tried showing power consumption:

    dropbox.com/s/562xjz7t3rmbrop/power_with_id_multi_source2.capx

    Passing the genId is kind of ambiguous. One will arbitrarily be the owner when there is a tie.

  • Dug up a plugin rex made that looks like it may help.

    c2rexplugins.weebly.com/rex_mode7perspective.html

  • You do not have permission to view this post