R0J0hound's Forum Posts

  • You can rotate a point around another using a formula like the one here:

    https://www.siggraph.org/education/mate ... 2drota.htm

    And here's a cursory example of that applied:

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

    You could probably do it with less math, but I'm not feeling especially creative.

  • It probably isn't a mistake since it's a format used throughout C2. Here's how the rgb() function in converts it to a single number.

    Number = red & (green<<8) & (blue<<16);

    There isn't a standard color format but if I may, here's a shorter way to convert it to the format you want:

    function hex2rgb(hex)

    {

    return {

    r: hex&0xff,

    g: (hex>>8)&0xff,

    b: (hex>>16)&0xff

    };

    }

  • I don't follow the last post, it looks different than what was originally asked. Here's my solution for the op.

    Global redboxcounter=0

    On redbox created

    --- add 1 to redboxcounter

    Redboxcounter >= 20

    --- subtract 20 from redboxcounter

    --- create bluebox

  • You could look at the json plugin by yann and see if that's something you could work with.

    Alternately you could use the browser object to access the info.

    First step is to get the json data into a variable. Options include:

    * using the Ajax object to get a file added to the project or even from a web address.

    * pasting it into a textbox when you run the game.

    * creating a variable and pasting it as the initial value.

    * using the set variable action and pasting it there. For this one you'll need to first replace all the " with ' and put a pair of quotes around it.

    Ok, so you get the json data with one of those methods and put it in a variable, you then run this action:

    Browser: run js "window.myjson=" & variable

    Then barring any js errors you should be able to access any value in the json with something like:

    Browser.execjs("myjson.presentations[0].name")

    It's just JavaScript so it maybe learning a bit of that could be useful.

    Presentations is an array so the above accesses the first one and gets it's name. At least it should, unless I made some typo.

  • The numbers are somewhat arbitrary. Just know that higher values mean those operators should be done first. The "(" probably didn't need to be in there but I think I added it to assist with error checking. Also I ended up hard coding neg as being right associative.

  • Does the plugin cease to work if you minify as it is now? If your plugin is the only js that accesses the library, and you included the library as a dependency then I'd think there was no reason to change anything in the library.

  • If you limit your variables to a single character then you could make AB the same as A*B. However you'd need to make your own parser instead of using javascript.

    I've done one before here:

    viewtopic.php?f=147&t=153525&p=967756&hilit=parse#p967756

    It's not a plugin and I don't have plans of making any more plugins.

    Here's a more recent example:

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

  • You would only need to round it when you display the number. Another way is to just use whole numbers and convert it to a decimal only when you display it, that way no rounding is needed. I think newt was alluding to that above.

    So instead of:

    Global number num=0

    Every 1 seconds

    --- add 0.2 to num

    --- set text to num

    Do this:

    Global number num=0

    Every 1 seconds

    --- add 2 to num

    --- set text to num/10

  • It's not a bug, it's a limitation of how floating point numbers are stored on a computer and some rounding.

    What happens is 0.2 can't be percisely represented in floating point so numbers are slightly off when doing math. It's much like how 1/3 takes an infinite amount of decimal places in base 10. It happens that 2/10 takes an infinite number of binary bits and floating point only has maybe 50? I forget exactly.

    Look at the accuracy problems section here for more of a read.

    https://en.m.wikipedia.org/wiki/Floating_point

    You probably can find some more explanations by using the forum search on the bugs forum with the keywords floating point.

    All other software that uses floating point numbers experience the same result. The difference sometimes is when putting the number into text they often round the result to say six decimal places instead of the 15 or so seen there.

  • Look in the manual about the mouse plugin. You can use and expression like mouse.x("layer 0") to get the position on that layer. It hAndles parallax, angle, etc...

  • randomly

    I'm unable to see what's amiss. I don't have access to C2 and what you want to do is different enough it's probably easier to start from scratch.

    In regard to the alternate idea in my last post to calculate the impact point exactly: the process is to use algebra to manipulate the first equation into the form ax^2+bx+c=0 and use the quadratic formula to solve for x. Well except it will be time in the equation. Anyways we can disregard that one for now.

    You said the bullet behavior doesn't give X and y velocty. While this is true, you still can convert it over:

    Vx = speed*cos(angleofmotion)

    Vy = speed*sin(angleofmotion)

    You can also convert it the other way

    Angleofmotion = angle(0,0,vx,vy)

    Speed = distance(0,0,vx,vy)

    The most complicated bit of the original example are these three actions:

    add vx*dt to X

    Add gravity*dt to vy

    Add vy*dt to y

    Those change the velocity and position to what they would be after dt seconds. You can replace dt with any duration you like. Next put those actions under a repeat condition and it is done multiple times. So say you repeat 10 times and use 0.1 instead of dt, it'll calculate where the position will be after 10*0.1 or 1second.

    I did skip a step though. Before the repeat you need to set X,y,vx and vy to what the bullet is currently. As a sub-event of the repeat event you can check so see if y is below the ground level, and then stop the loop and place the marker.

    Alternatively you could position a second Sprite at the bullet and move that instead of using Xy variables.

  • statham

    You can still do that as I said.

    Add a new condition:

    System -> pick by comparison

    Select you Sprite as an object type and use the expression Sprite.chipmunk.speed to get the speed.

  • Try Construct 3

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

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

    I purposely didn't add and conditions to compare expressions of the behavior. You should use system-> compare or pick by comparison with the expression to do it.

  • Not really. The errors are passively logged so it's hard to know what causes it. You could try a trial and error approach to run your game for a bit, try some things, close, and see if any errors were logged. Maybe to speed things up you could somehow check when that file is created or modified. That's something outside the scope of C2 but there are ways that can be found with google. With either approach maybe you could narrow down what causes it.

    You could also use a debugger or try recompiling nw.js to stop when those errors occurs so you can check what causes it. Neither sound easy though.

  • randomly

    If you just want to mark the point it hits the ground then you can either just set speed to the bullet's speed or if the ground is flat you can just calculate the impact x directly by taking these two equations and solve for x:

    y = initial_y + initial_y_velocity*time - 0.5*gravity*time^2

    x = initial_x + initial_x_velocity*time

    which would be:

    x= initial_x + 2*initial_x_velocity*initial_y_velocity/gravity

    if the bullet was launched from ground level