R0J0hound's Recent Forum Activity

  • You're not doing anything wrong, most behaviors just aren't very robust when dealing with collisions.

    One solution is to use the physics behavior to handle the collisions. Just set the velocity of the player.

    Another way is to just handle collisions and collision response with events:

    uc74b25debe01f506f418470c9bd.dl.dropboxusercontent.com/cd/0/get/Ch-MSMiQENN22HqdSmlWAiy7ZVPf5SVzqaJDegEFmnb1sK2T-OFsUfMmB4rOiNRvTyzk0PYKTRedlrNYoCkXf_fC2wbKF-DPoFnQxrVWdO1h6vCl9sJMDUeSYNGufhog4QC7wc1Z4f-u6QgZT0q1yPUP/file

    The above treats the player as a circle and works with boxes and circle walls.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So the qarp(a,b,c,t) expression is the basis for that. With one for x and y you will get a quadratic Bézier curve. A and c are the endpoints and b is a control point in the middle. Typically the curve will not touch the middle control point but newt is utilizing a little additional math to have the control point be on the curve.

    Anyways, the t is a value from 0 to 1 to get any point along the curve.

    Basically this is how you’d create points along the curve.

    Repeat 10 times

    — create at qarp(ax,bx,cx,loopindex/10), qarp(ay,by,cy,loopindex/10)

    Newts example draws lines between them with canvas and adds them as waypoints for the move to behavior to move along the curve. Conceptually you can think of the curve getting approximated by multiple lines that are moved along in series. That was done so the speed would be constant. If you alternately just changed t over time and used the qarp expression you could have a more precise curve but the speed would vary.

    The shape of the curve is limited by those three control points. You could use cubic() instead to get one more control point to give finer control. There are other ways to do curves between points too, but you’d have to write the whole equation out.

    All that in the example was just expressions. No js used there.

  • You can use the distort mesh to make it. This example is slightly out of date.

    construct.net/en/forum/construct-3/your-construct-creations-9/example-mesh-distort-sphere-161470

  • So basically you’d just need to set the z when you create it much like the velocities. For example here it starts with a z of -150. Then you can make it stop on the ground by comparing the z with 0.

    every 1 second
    — create shadow at random(640), random(480)
    — create ball at shadow.x, shadow.y-150
    — set z to -150
    
    Every tick
    — set y to self.y-self.z
    — set position to self.x+self.vx*dt, self.y+self.vy*dt
    — add 200*dt to vz
    — add vz*dt to z
    
    Z>0
    — set z to 0
    — set vz to -0.5*abs(self.vz)
    
    Every tick 
    — set y to self.y+self.z
  • You’ll have to refer to the documentation for how to do it.

    Basically you’d access the runtime object, find the list of object types from that, then a list of each instance for each type. Then you can either compare the x y or calculate the distance with:

    var dx=x1-x0, dy=y1-y0

    Math.sqrt(dx*dx+dy*dy)

    Or maybe the sdk has a distance function you can use. Anyways that’s the gist of it.

  • Here’s the rough idea. You’d need to get the actual time from the system. One way to get that is with the JavaScript Date.now() which gives the number of milliseconds from some fixed date.

    Here I specified that clicking a button will make the timer last 5 seconds.

    Then you can do a comparison to see if the timer has passed the endtime.

    All that’s left is to save and load the endtime to local storage when the game starts and closes. You’ll have to consult some docs how that’s done as I haven’t messed with it in a while.

    var endtime = 0
    
    On start of layout
    — set endtime to webstorage.at(“endtime”)
    
    On button clicked
    — set endtime to browser.execjs(“Date.now()”)/1000+5
    
    endtime >= browser.execjs(“Date.now()”)/1000
    Trigger once
    — do something
    
    On end of layout
    — web storage save endtime to key “endtime”
  • Something like this should work. Being mirrored means the width is negative. Using cos on the moving angle gets the horizontal movement. The ?: expression sees if the horizontal motion is negative.

    Every tick:

    — set width to abs(self.width)*(cos(self.moveTo.movingAngle)<0?-1:1)

  • Arrays are basically just a way to store a lot of values.

    If if just want a list of values you can use it as a 1 dimensional array with size (count, 1, 1).

    Another common use, like in that tutorial, is to do a 2d array to have a value for every tile on a grid, or one value for every pixel of an image. So size (width,height,1).

    Also in that tutorial it uses an array to store a list of the x,y,width and height of multiple rooms. So the size is (roomCount,4,1). 4 because there are four values: x,y,width,height.

    You just need to keep in mind what those values mean. So for example you wanted to get the width of the 10th box in that list it would be:

    Array.at(10-1, 2).

    It’s 10-1 instead of 10 because things count from 0 instead of one. And the 2 is for width. 0:x, 1:y, 2:width, 3:heights.

    However, don’t tell me that’s easy to read. It’s rather obscure what it means at a glance.

    All that tutorial is doing is:

    1: place multiple different sized rectangles on the layout.

    2: make paths that go horizontal then vertical between them.

    3: draw it to the tilemap. Basically amounts to looping over the tiles under the rooms and paths.

    4: once on the tilemap you can check the surrounding tiles to mark the ones on the edge as walls.

    4b: in a similar fashion it colors the floor differently depending on what surrounds it.

    Using an array instead of a tilemap directly is merely a preference.

  • Cool. Glad it was useful.

  • That formula doesn’t look familiar but possibly. Most of the formulas I post are either found online or just multiple formulas combined together and simplified.

  • I will say I downloaded one of those so called english word lists and most of them don't look like words to me, but anyways.

    Here is a test to load such a wordlist into a dictionary without hanging the browser. Once loaded it's as simple as the "has key" dictionary condition.

    ucd3a4921195377e28b7818ffce5.dl.dropboxusercontent.com/cd/0/get/Ch7RGVrcrX7DhT04DhRPwkKkBjO-i1c2NTOJOTV4iYUbL8a8IYuc0GnUEUVqeN9MxHHi4W026X-l4_PA902EB5TRkUQ8dnBpjXIABR7_yz7IbhjjToBALaG8HD5umGtV9qfR98aWCsQf2tfFVKDmSHvv/file

    As far as speed goes, its way faster to have the words in a dictionary instead of an array if you need to find if a word is in it.

    With an array it would have the worst case of having to look at every single word before finding it.

    You can do a binary search since the words are sorted to improve that. Maybe a worst case of checking 40% of the words.

    With a dictionary it finds the word more or less directly.

  • Here's the equations. t is how long you want it to take to get there in seconds. And mouse is the destination spot. Probable can put it into a function for easy use.

    var t=1
    On click
    -- set speed to distance(0,0,(mouse.X-Self.X)/t, (mouse.Y-Self.Y)/t-0.5*Self.Bullet.Gravity*t)
    -- set angle of motion to angle(0,0,(mouse.X-Self.X)/t, (mouse.Y-Self.Y)/t-0.5*Self.Bullet.Gravity*t)
R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound