R0J0hound's Forum Posts

  • Opps... I see I had the subtraction reversed. :p Glad you got it working.

    cheers

  • You'll have to use this plugin to get the date:

    http://c2rexplugins.weebly.com/rex_date.html

    on the start date save the UnixTimestamp (seconds since Jan 1, 1970) to webstorage for later, we'll call this start_time.

    Then any following times you want to see how many days have passed you retrieve the saved time from webstorage and subtract the current UnixTimestamp. That will give you the number of seconds from one date to another. Divide by 60 to get minutes, 60 again to get hours, and finally also by 24 to get days.

    days = (start_time - UnixTimestamp)/60/60/24

  • The closest thing to that would be to use the third party Canvas plugin. It has a rgbaAt expression but it only works to get the color on the canvas object's texture. It also has actions to draw other objects onto this texture which is useful.

    The overall method would be to draw everything on screen to a screen sized canvas object, and after that get the color with rgbaAt.

  • Short version:

    1.The 2500 is from the conversion factor (50) from box2d units to pixels.

    2. Your equation to calculate won't work for all shapes. Instead of just mass you need to calculate the Moment of Inertia for that particular object. After that the only magic number is 0.02 or (1/50) which is the conversion factor from pixels to box2d units.

    3. [quote:2iwgq6s7]AngularVelocity = Velocity / Diameter (pi)

    should be:

    AngularVelocity = Velocity * 180 / (radius * pi)

    Long Version:

    Box2d internally uses it's own distance unit (m) which is 0.02 pixels.

    The conversion is:

    1 [pixel] = 0.02 [m]

    or

    50 [pixel] = 1 [m]

    The set Velocity action and getVelocity expression already do the conversion without help, but the conversion isn't considered with Force or Impulse.

    Before I go any further I'd like to suggest that the mass expression is returning a bad value. The formula for mass with units is:

    Mass [d * m^2] = density [d] * area [m^2][/code:2iwgq6s7]
    Where [d*m^2] is the same as [kg]
    
    So for a 32x32 pixel square with density 1 the mass should be:
    [code:2iwgq6s7]area [m^2]= (height [pixel] * 0.02 [m/pixel]) * (width [pixel] * 0.02 [m /pixel]) = (32 * 0.02) * (32 * 0.02) [m^2] = 0.4096 [m^2]
    mass [d * m^2] = density [d] * area [m^2] = 0.4096 [d * m^2][/code:2iwgq6s7]
    But the mass expression returns 20.48 or 50 times 0.4096 which is incorrect since that makes the units [d*pixel*m].
    
    This is only important because if it were correct you'd only have to multipy by 50 instead of 50*50 or 2500 with the Force and Impulse equations.
    
    Torque is a bit trickier.  The equation for Torque is:
    [code:2iwgq6s7]Torque [kg*m^2*deg/s^2] = inertia [kg*m^2] * ang_accel [deg/s^2][/code:2iwgq6s7]
    
    [url=http://en.wikipedia.org/wiki/List_of_moments_of_inertia]Inertia is calculated differently for different shapes[/url].  For a square the equation is:
    [code:2iwgq6s7]Inertia = mass * (width^2 + height^2)/12[/code:2iwgq6s7]
    For mass we'll use 0.4096 and we'll need to covert height and width from [pixel] to [m] and we get:
    Inertia = 0.4096 * ((32*0.02)^2 + (32*0.02)^2)/12 =~ 0.02796...
    
    I then ran a test to apply a torque of 1 for 60 ticks. At the end the angular velocity was approximately 35.76. From that the acceleration could be calculated with acceleration=(final_speed-initial_speed)/time which ended up being 35.76.
    
    The numbers agreed with the equation when it was plugged in:
    torque = inertia * ang_accel
    1 ?= 0.02796 * 35.76 
    1 ~= 0.9998
    
    This link may also be useful as it predicts motion using equations much like yours.
    
    -cheers
  • For #1 are triggering a floodfill when just hitting a ceiling. It doesn't look like it is.

    For #2 I've noticed the snapping doesn't seem right at times. The equations I used do what they were designed to do: find which square on a staggered grid to snap to.

    I did a test to evaluate the equation.

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

    The formula is about the same as in the bubble shooter capx I've made before. I also compared it to just picking the nearest grid sprite which would be perfect minus the need all the sprites. Anyway there are subtle differences in the gaps. My conclusion is a new formula needs to be found so that snapping isn't done to the nearest square but the nearest hexagon, which would mirror using picking nearest.

    A internet search for "snap to hex grid" would probably be the next step.

    After that the issue of snapping into walls or other jewels may still be there and require another solution.

  • As a note you get the speed from velocityX and velocityY with this calculation:

    speed = distance(0,0,velocityX,velocityY)

    or

    speed = sqrt(velocityX^2 + velocityY^2)

    which is the same, just whatever you prefer.

  • Another idea could be to use the function object.

    global number cur = -1

    On function "next"

    --- set cur to (cur+1)%Function.ParamCount

    --- set return value to Function.Param(cur)

    On any click

    --- Set text to Function.call("next", "apples","oranges","bananas")

  • cool

  • This works

    (time<5 | time>10)?"not now":"now"[/code:gn5necf3]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'd have to see a capx as I don't know from your description.

  • Yes hard. You could use the multiplayer chat example as a base, or use the peerjs third party plugin. Both have the side effect of needing access to the internet to at least get going.

    Or maybe very easy. You could use the clipboard as the way to send messages. Just set the clipboard in one app and periodically check in the other app. Although it could be annoying to the user with the clipboard contents being changed. You could also do it be reading and writing to a certain file.

  • [quote:3s96hura]Also, is there going to be rotation?

    It already has rotation. Objects rotate on collision and there are actions to set angular velocity and torque. Unless you mean something else?

  • Joannesalfa

    For that one remove the "mark neighbors" call in event 5 and add another event right below:

    tile y=32:

    ---- tile set marked to true

  • I apologize I looked at it again and I misspoke, it should have been event 12.

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

  • SgtConti

    Can you provide more details or a capx where it occurs? I don't get an error when using two sprites. Although tiledBg does seem to have an issue when the hotspot is top-left.

    I've been on a break from coding for a bit, but I should be resuming soon.