R0J0hound's Recent Forum Activity

  • It's a simple enough capx, change it to one object and see what happens.

    The control object acts as a shield so you can run up against the sides of the crushers with out dying. As one object It's just: if player overlaps crusher then die.

  • The front edge has a z of 1 and the back edge has a z of 2. The values were a bit arbitrary, you could pick a different value fro the back edge but then you'd need to rework the formulas. I did some fiddling with the example and stretched the perspective shapes around and actually found cases where the old method works better.

    There may be a math error somewhere in my equation since it seems to need that correction for large values.

  • I don't know of the image you're referring to. If it helps the origin is the top left of the layout and x increases to the right and y increases down. Basically it's vertically flipped from what's used in math books.

  • Like codah said there are many different ways and they really depend on the type of game. One way would be to use some sprites as detectors.

    Attached is a way to make thwomps like in mario.

  • Here's kind of a way to do that, but all collision is done manually.

    The idea is to fill an array with random heights for the terrain, and have a number of sprites across thee screen. Then the height of those sprites can be set from interpolating between array values.

    It's kind of complicated because everything is done manually but perhaps you can pull a few ideas from it.

  • You can do the motion with vars for velocityX, velocityY and gravity. Then the kinetic motion can be calculated with:

    x = x + velocityX*dt

    velocityY = velocityY + gravity*dt

    y = y + velocityY*dt

    To make it bounce there are a few approaches. One simple one it to move horizontally first, then vertically. For either motion the idea is to:

    1. move

    2. if ball is overlapping wall then unto the move and reverse the velocity.

    To make the ball always bounce back up to the same height is a bit trickier. In an idea world we would bounce at the exact point of collision, which can be calculated but even then there will be rounding errors over time.

    A simpler idea would be to conserve total energy. AKA total_energy=potential_energy+kinetic_energy

    Potential energy (PE) is the height of the object off the ground times gravity, and kinetic energy (KE) is the speed squared divided by two.

    PE = -y*gravity

    KE = 0.5*speed^2

    As the ball moves energy is transferred back and forth between PE and KE, and if energy is conserved then the total energy (E) will always be the same.

    E = KE + PE

    This is useful because with that we can calculate what the speed is for any y. You can work out the algebra yourself but it comes out to:

    speed = sqrt(2*gravity*(y - start_y))

    So with that we can correct the speed so the ball always bounces to the same height.

  • It's drawing C2's canvas to a separate, smaller canvas which is used to save from.

  • You'll mainly be interested with the stopping distance which can be derived from this kinematic equation:

    vf^2 = v0^2 - 2*a*d

    where

    vf is the final velocity

    v0 is the initial velocity

    a is the acceleration

    d is the distance

    We want to know how far it takes to stop with a given speed and deceleration. So:

    speed^2 = 0^2 - 2*deceleration*distance

    solving for distance we get:

    distance = -(speed^2)/(2*deceleration)

    Note: if the value you use for deceleration isn't negative you can omit the minus in the formula.

    So then our pseudo code to move the object would be:

    if( speed < max_speed) then accelerate
    
    if( distance_to_target <= -(speed^2)/(2*deceleration) then decelerate[/code:bepp4si0]
  • Use this expression to get a smaller screenshot. Change w and h for different sizes.

    Browser.ExecJS("
    var w = 100;
    var h = 100;
    var c2canvas=document.getElementById('c2canvas');
    var mycanvas = document.createElement('canvas');
    mycanvas.width  = w;
    mycanvas.height = h;
    var ctx = mycanvas.getContext('2d');
    ctx.drawImage(c2canvas, 0,0,w,h);
    mycanvas.toDataURL();")[/code:6otna5an]
  • BSP's would need to be generated first but even then the drawing performance isn't there on my pc with html5. Also agreed a uniform grid would be faster, but it is also is less interesting.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Considering Doom and Wolfenstein 3D ran decent on computers with 1/100th the computing power of today's pc's I'd say some major bottlenecks are being encountered.

  • I didn't investigate it further but with my tests I was able to get away with using 1,2,3... for sid's.