R0J0hound's Forum Posts

  • You mean heavy on cpu usage? Test it and see how heavy it is. Setting the force is basically just setting a number and has a negligible performance impact.

  • It's possible in theory, but in practice it would be hard to get it to the point where it works the same as it does in javascript and html5. Not to mention it would be hard to update it to stay on par with c2 releases.

    Now if you utilized a javascript engine like v8 or spidermonkey you can get most of the way there with most of c2's runtime running as is you just need to impliment html5 stuff like images,canvases, input, etc in c++ or something.

    I was able to do that with a couple hundred lines of Python with v8 and sfml as the input/graphics backend. It just runs an html5 export to do it. I've been meaning to covert it over to c++ to eliminate the overhead of Python. But anyway the idea is to just impliment the system specific stuff in c++ and run everything else with js.

  • For that you could use Bresenham's line algorithm for a nice result. But it isn't simple.

    You could use lerp to do it like this:

    https://dl.dropboxusercontent.com/u/542 ... _step.capx

    but you'll have to handle the case when deltay is more than deltax and do the loop in that direction.

    Edit: actually this would do it:

    variable delta= max(abs(x1-x0), abs(y1-y0))/32

    repeat delta times

    --- create sprite at (round(lerp(x0, x1, loopindex/delta)/32)*32), round(lerp(y0, y1, loopindex/delta)/32)*32)

  • spongehammer

    For shifting the CoM as mattb said is to attach multiple objects together. At least for now that's the only way.

    mattb

    Looks good, you can also utilize the "on pre step" condition to negate the acceleration of gravity on the object, but looks like it's working well as is.

    The wrapper project is stalled currently. I'll pick it up again eventually though.

  • The level rectangles need to be pinned to the sprite you drag and then you can give the rectangles a variable with the name of the layout to go to, which you can use with "go to layout (by name)"

    https://dl.dropboxusercontent.com/u/542 ... lide2.capx

  • What is your use case for getting all the points between two lines? You mean for picking objects on the line?

  • As zenox said it mainly depends on the user. C2 makes a lot of things very easy, for things that aren't easy you can still do it with events in most cases. The SDK is nice and all but it isn't really necessary unless you want to interface with something outside of C2 like some js library that isn't covered by existing plugins. So most don't need to use it, as the event system can handle any logic you can devise.

  • Here's a capx for wall sliding with the 8dir behavior.

    https://www.dropbox.com/s/0ll7vaonp0h5w ... .capx?dl=0

    All it is is a superior way to push the player out of solids than what the behavior does by default. Well, actually solid isn't used so that we can handle collision response ourselves instead of letting the behavior do it. The player is treated as a circle (which solves your third image), and the walls are all rectangles. The algorithm just calculates the closest corner or edge on each wall and moves out in the opposite direction. The velocity isn't messed with and it appears to work well enough without doing that.

    It has no dependence on the 8 behavior so it could be used in other ways. All that it needs is a player sprite and box sprites for walls with four image points at the corners.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For orbits with physics you can do it using equations of actual orbiting. Some info and capx on it here:

    Basically you can do the gravity force with "newton's law of universal gravitation" and set the orbit by setting the velocity to a calculated "mean orbital speed" and set the direction to be perpendicular to the direction from the moon to the planet.

    Calculating the impulse to change directions may be doable, just your standard algebra problem, but it's probably simpler to just set the velocity directly.

  • I was pretty sure SAT isn't used in C2. Just checked and no it's not. It does the collision detection with either bounding box overlap tests, which are very fast or "line intersection" and "point in polygon" tests for polygons. Collisions are resolved in most (all except physics) behaviors using the runtime's pushout functions which basically are loops that check for an overlap, move a bit and check again until not overlapping. The function used to push out in the nearest direction uses a spiral scan pattern to find a free space.

  • tgeorgemihai

    I think the jump is related to how the behavior finds the closest free spot to resolve a collision. It does checks in kind of a spiral at times from what I understand, which is decent for arbitrary object collisions but not so much when hitting a flat wall it would seem.

    I can't think of any solutions offhand to fix the little jumps other than just implementing the movement from scratch to have more control.

    Here's my go at it that works similar to the platform behavior but only works with un-rotated boxes.

    The cyan box is the one done with events and the grey one is the platform behavior for comparison.

    https://dl.dropboxusercontent.com/u/542 ... _plat.capx

    The basic loop is

    1. move with any platforms the player is known to be on

    2. move based on controls and based on what sides of the player is blocked

    3. resolve collisions by moving the player box out the closest direction of the wall boxes.

    4. mark the walls the player has around him and stop velocity in those directions.

    It does have room for improvement, like anything, but it works ok. The cases when the player gets trapped will need to be handled.

    Edit:

    For the sine behavior you can find the distance moved by adding two variables ox and oy to the object and then in "on created" and an every tick at the bottom of the event sheet set ox and oy to the object's x an y. The the x and y distance moved would be x-ox and y-oy respectfully.

  • system: pick random instance of sprite2

    --- sprite: set position to sprite2

  • You can do it with a sprite that has a hotspot at it's left. Then you can position it to (x0,y0), set it's angle toward (x1,y1) and set it's width to distance(x0,y0,x1,y1). The height of the sprite is the thickness of the line.

    An example that does this is here:

    Another idea is to use the canvas plugin which has an action to draw a line.

  • Those things can be done by adding some conditions to check if lives=0 and such.

    Look at this tutorial, it will help you get the concept down.

    https://www.scirra.com/tutorials/37/beg ... onstruct-2

  • Your formula is wrong. You have this:

    Self.iniy-JumpStrengh_green*(time-Self.time)+Gravity_green*(time-Self.time)^2[/code:19hjq2f2]
    
    You forgot the 0.5*.
    [code:19hjq2f2]Self.iniy-JumpStrengh_green*(time-Self.time)+0.5*Gravity_green*(time-Self.time)^2[/code:19hjq2f2]
    
    [code:19hjq2f2]y = y_initial + y_velocity_initial*time + 0.5*acceleration*time^2[/code:19hjq2f2]
    
    After that it will still differ in height with the platform behavior, a little.  Yours will give the same jump height regardless of the framerate, but the platform behavior will vary a little.
    
    This is basically how the platform behavior does the y motion:
    every tick:
    --- add gravity*dt to vy
    --- set y to self.y + vy*dt
    
    In order for it to be truly framerate independent it would need an extra term:
    every tick:
    --- add gravity*dt to vy
    --- set y to self.y + vy*dt + 0.5*gravity*dt^2
    
    It's not as simple a change as that when I looked in the platform behavior's source, but that's the general idea.