R0J0hound's Recent Forum Activity

  • If the physics had a fixed time step and always did the same number of steps per second, then the same impulse would give the same result. Barring any differences in the number calculation from one machine or js engine to another.

    That said I’m not sure how close you can get to doing that. I think you can specify a fixed stepping with physics, but the number of steps per second is frame rate dependent.

    The term is called deterministic when the same result happens each time. Might help for googling general solutions.

    Off hand the solution I can think of is to do the physics with events. We just need a way to do a fixed time step, and always do x amount of frames per second. There’s an article online called “fix my timestep” that gives a way. The physics is beyond that. Anyways that’s probably the roll your own solution. There may be features that make that simpler.

  • I think the way to do it would be to have a frame for every angle.

    X rotation from 0 to 360

    Y rotation from -180 to 180

    So if you wanted a frame for each 10 degrees that would be 36*36 frames.

    So the next step is to map an x,y angle to a frame. Z is handled by the sprite angle. A starting formula could be this:

    36*int(angX/10)+int(angy/10)

    X and y could be swapped depending on how your frames are laid out. You also want to ensure the angle is in the range 0 to 360. This should do it:

    Ang=(Ang%360+360)%360

    Ok cool. So all that’s left is to rotate the ball around in 3D somehow. I’m thinking just some physics. Simple case you’d want it to roll in the direction the ball is moving. Looks like it can spin in place in your gif. Might need some more 3D physics calculations. But I can’t calculate that off the top of my head.

  • To use a different uid. Change the parameter for the overrideDrawGl function.

  • All those events into one?

    On touched select_arrow

    — set body to ((select_arrow.body arrow?-1:1)+body+4)%4

    — local storage: save “key body” to body

    — set animation to tokenat("default,tux,mick,king", body, ",")

  • sqrt(Object.Velocity.X^2 +Object.Velocity.Y^2)

  • Glad it worked. I’ve never used that noise function. I thought for a second I may have answered wrong as I’m not sure what those rgb stops do exactly.

    I agree with you it would be more useful if the noise function was in a more useful range.

    Edit: as for the hard lines, it could be clamping. Isn’t the noise value a decimal number?

    You could try to use 28 and 72 to be the low and high values in the equation to give a slight buffer.

  • If that’s the range you can make it from 0 to 100 with

    (X-29)/(71-29)*100

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What a cool bunch of different graphics effects. The bobing and tilting are nice touches that make the motion cooler.

    Nice use of pixel data too. No need to process more than you need to and it seems to make it more interesting when you can draw the curves instead of relying on stiff math curves. Anyways, looking forward to seeing more. The pixel examples I made work differently but could benefit from canvas use if I used C3.

  • Hi.

    I don’t have an example but I think you can break it down in to simpler parts and see how they could be done.

    I guess I should play the game, but from watching videos this is what I can gather.

    1. The enemy moves around in the empty area and won’t leave the boundaries.

    2. The player can move anywhere inside the boundary too, but when it’s on the edge it’s safe.

    3. When the player leaves the edge it draws lines behind itself.

    4. The player can’t cross this edge, and if the enemy touches this edge or the player it kills the player.

    5. When the player makes it back to the original edge the area the enemy isn’t in is filled and the boundary edge is updated.

    I may be overlooking some aspects of the game, and it does look like some things can be more complex but as a start that covers most of it.

    Number 5 is the most novel. There are a few ways to think of it. One way that seems to work well in my mind is to have the boundary of the level be a polygon. When the player moves from one edge and makes it to another it splits the polygon into two. We then test which polygon the enemy is in and filling the other.

    Filling a polygon can either be done with a flood fill or more efficiently a scan line at a time. Canvas sounds like it would work well, or maybe a bunch of 1px thick sprites.

    So the laundry list of things to do would be:

    Point inside polygon test.

    Split polygon by poly line

    Fill polygon

    Others may have different ideas.

  • You didn't specify the size of B, but if it can be thought of as very small it will make things simpler. Does B bounce too, or is it just getting destroyed?

    The first is to find the point of collision and the normal. Since B is small you can just use B's position when it overlaps A. The normal is a bit trickier, but you can find it with something like this. It assumes that A is a rectangle. It just find the closest edge on A and uses it's normal

    variable best=1000
    variable normal=0
    variable d=0
    variable a=0
    
    set best to 1000
    repeat 4 times
    -- set a to A.angle+90*loopindex
    -- set d to (loopindex%2=0)?A.width/2:A.height/2
    -- subtract (B.x-A.x)*cos(a)+(B.y-A.y)*sin(a) from d
    -- compare: d < best
    ---- set best to d
    ---- set normal to a

    So the next part is to calculate the impulse. It's taken from here if you want the source of the math:

    en.wikipedia.org/wiki/Collision_response

    rx,ry is the offset from A to B

    relvel is the velocity between the two objects at that point, along the normal.

    cross is the cross product of r and the normal.

    j is the impulse magnitude

    vx, vy is the horizontal and vertical velocities

    w is the angular velocity

    variable rx = 0
    variable ry = 0
    variable relvel = 0
    variable cross = 0
    variable c = 0
    variable j = 0
    
    set rx to B.x-A.x
    set ry to B.y-A.y
    set relvel to (B.vx - (A.vx+A.w*PI/180*-ry))*cos(normal) + (B.vy - (A.vy+A.w*PI/180*rx))*sin(normal)
    set cross to rx*sin(normal)-ry*cos(normal)
    set j to -(1+e)*relvel/(1/A.mass+1/B.mass+1/A.inertia*(-ry*c*cos(normal) + rx*c*sin(normal)))

    Before we go further the units used by the physics behavior needs to be taken into account. Construct physics uses degrees per second for angular velocity. The equations above need radians per second.

    So above A.w is replaced with A.w*PI/180.

    Also the physics behavior I don't think gives you the inertia of an object. But for a rectangle you can calculate it with

    inertia = mass/12*(w^2+(1/w)^2)

    Also bear in mind when I use A.vx in the equations above I mean A.physics.velocityX. Similar to vy and w.

    Ok, cool so Now we have j, which is the magnitude of the impulse. Since we can't apply an impluse at as specific location can just set the velocities directly.

    set vx to A.vx-*1/A.mass*cos(normal)

    set vy to A.vx-*1/A.mass*sin(normal)

    set w to A.w-j*1/A.mass*cross*180/Math.PI;

    Barring any typos on my part that should work.

  • JaviApps

    There is no update for this plugin for c3. This plugin probably should be retired. It works best with the non webgl renderer. It was made to somewhat work with webgl but is a performance hog.

  • Test 3: Scorched earth style terrain.

    uc4c8a039ffe3bc5f9c29c5c9055.dl.dropboxusercontent.com/cd/0/get/Ch76Cdgj1VXb8oSov6Wgu7IRecmWl1aqNqEn8xqri38m_LAPt-o5yXRyRJfVExTY6A8QoV1FNhUAkSxcoqoQjmWxY-e86pJBK_uN7GBdBSdRc07wjbzqZBkxXUD9b1ZxrZ3ZTD6ziBrHEtfdvEBvWM9h/file

    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

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound