R0J0hound's Recent Forum Activity

  • Opened your link. The technical issue was that when i download it on my phone it adds a .zip to the end of the filename and c3 won't open it then. Anyways I have no help other than it's not following what I wrote in my post. Here's an implementation of what i wrote:

    uc02c2f90a4b113467e5b0a12c75.dl.dropboxusercontent.com/cd/0/get/CiH4y_Y7qfo_dzjLMVfbUv_ZPF-pOStS4oirKkp19iO8JsiN2ppaWyh48G9A3ITlPf2lMyS7gvYHXSt22OXc-i2EzCvLjA1UIraCEdA_FdB-YhcUpmsleABgPE0bNm63xt0/file

  • With canvas there is no solution. It uses a non webgl canvas which doesn’t use effects.

    For paster it is indeed copied from the c2 runtime, but it is modified to draw to a rectangle instead of the whole screen. Shortcuts were taken for some of the more elaborate parts of drawing effects. For one the effect parameters just use some default values instead of proper calculated values. And two, it just ignored how multiple effects were applied. As I recall the runtime would do some framebuffer juggling to draw the effect to a texture, then take that texture and draw the next effect to another, and so on.

    Anyways the c2 runtime does it with some temporary screen sized textures. Paster object’s can be any size, and we’d need temporary textures of the same size. So I had three possible solutions. Doubling or tripling the vram per instance, dynamically creating the temp textures, or some hybrid approach to try and reuse textures between multiple instances.

    Or the short version, it’s a missing feature that would require a full solution to be written.

  • I’m replying on my phone and I’m having technical issues opening your file in c3.

    There are some nice interactive tutorials here. One covers vector math with sin/cos. Angles on there are counterclockwise instead of construct’s clockwise but the math works the same.

    demoman.net

  • jobel

    Using sin/cos like that is basically what the “move at angle” action does. So setting the position could be like this instead, which is exactly the same.

    Every tick

    — Blue: set x to red.x + self.d*cos(self.a+red.angle)

    — Blue: set y to red.y + self.d*sin(self.a+red.angle)

    — blue: set angle to self.da+ red.angle

  • Give the object you want to pin three instance variables.

    a - angle from other object

    d - distance from other object

    ra - relative angle from other object

    Then to set it up you’d do an event like this: for this example we are pinning the blue object to the red object.

    Start of layout

    — blue: set a to angle(red.x,red.y,blue.x,blue.y)-red.angle

    — blue: set d to distance(red.x,red.y,blue.x,blue.y)

    —blue: set ra to blue.angle-red.angle

    Then the positioning would be:

    Every tick

    — blue: set position to red

    — blue: move self.d pixels at angle self.a+red.angle

    — blue: set angle to self.ra+red.angle

    That’s basically it. When there are multiple objects to pin to you’d want to store the uid and stuff.

  • [quote]changing to a 30 or 15 degree arc, would give a lot more track design variety, food for thought.[/quote]

    As it is now you can place tracks on a 64x64 grid, which makes making tracks pretty easy in the layout editor. Other arcs wouldn't line up to a grid as readily. I mean an in game track editor is another option, but saving and loading workflows are a bit awkward in construct games.

    Anyways this was meant to be more of a simpler proof of concept.

  • Cool examples AllenR! Looks like you had a lot of fun making them.

    I'm a bit late to the party, but I finally was able to try out an idea to make motion on the curves smoother. It also lets you place cars at exact distances on the tracks so spacing stays good too. Other than that it's pretty bare bones with only one track.

    Anyways here's the capx.

    ucbc4712d62ad6bda6335175e98c.dl.dropboxusercontent.com/cd/0/get/Ch7LNT8UO00jL5YmZ_epBQ8LwIFq-Yn-QKGfDWfOF4aRtXay7l0L4rVgiMIl-aci_9DIwJ3llhRlxhOF5CG_sNtOuhrZPuB9-sbTD5cH-AZkHem7EYSnem328NhqJivq6xk/file

  • I mean you don’t have to use behaviors at all. The collision detection and response would be the most complex to deal with though. It just depends on what you’re trying to do.

    Here’s an example for handling the horizontal motion utilizing physics. I used the joyx variable to handle the left right controls, because if they are both down they will cancel. If nothing is pressed or they are canceled then deceleration will be applied opposite the velocity. If instead only one key is pressed an acceleration will be applied in that direction. For faster turning the deceleration is applied too if the velocity is opposite the direction you want to go. I used a math trick a*b<0 if a and b have opposite signs. Finally the max speed is enforced by clamping the velocity.

    Global number joyx=0

    Every tick

    — set joyx to 0

    Left key is down

    — subtract 1 from joyx

    Right key is down

    — add 1 to joyx

    Joyx = 0

    — xvelocity>0

    —— apply force -deceleration

    — else

    —— apply force deceleration

    Joyx <>0

    — apply force joyx*acceleration

    — compare: joyx*xvelocity <0

    —— apply force joyx*deceleration

    Every tick:

    — set xvelocity to clamp(xvelocity, -maxspeed, maxspeed)

  • Let’s see. The simplest way to move in a parabola from one point to another would be to use the qarp expression. Of course you’ll need a third point as well for the middle but we can calculate that with a midpoint between the two points and move it up by some distance such as 100.

    Basically give your enemy five variables: t=1, x0,y0,x1,y1

    On some trigger to start the tween

    — enemy: set t to 0

    — enemy: set x0 to self.x

    — enemy: set y0 to self.y

    — enemy: set x1 to destination x

    — enemy: set y1 to destination y

    Enemy: t <1

    — enemy: set t to min(1, self.t+dt)

    — enemy: set x to qarp(self.x0, (self.x0+self.x1)/2-100, self.x1, self.t)

    — enemy: set y to qarp(self.y0, (self.y0+self.y1)/2, self.y1, self.t)

    Now since this is a parabola the speed will be faster at the start and end than at the middle. Making the speed constant is tricky. The simplest way is to store a list of points and treat it as a polyline. You’d do a loop to move over each line until a specified distance was moved per frame. Alternatively you could store the previous tick location and iteratively adjust t till the new calculated location from qarp is always approximately the same distance from the previous location.

    There is also the math way to do it. I think the terms are function reparameterization to length. It involves calculus with integrals which I’m a bit rusty on. It could simplify to a reasonable equation though. Typically I’ve seen it approximated with the other two methods.

    Or instead of a parabola you could use an arc instead. Arcs can be moved over with constant speed easily. You just need a center.

    Give the enemy these variables: t=1, cx,cy, a, r

    On some trigger

    — enemy: set t to 0

    — enemy: set cx to (self.x+destination.x)/2

    — enemy: set cy to (self.y+destination.y)/2

    — enemy: set a to angle(destination.x, destination.y, self.x, self.y)

    — enemy: set r to distance(self.x,self.y,destination.x,destination.y)/2

    Enemy: t<1

    — enemy: set t to min(1, self.t+dt)

    — enemy: set x to self.cx+self.r*cos(self.a+180*self.t)

    — enemy: set y to self.cy+self.r*sin(self.a+180*self.t)

    That will make the enemy move in a half circle arc. More subtle arcs could be possible too with further tweaks of the equations.

    Also note both methods will complete the motion in one second. To make it complete in say 0.5 seconds change the *dt to *2*dt in the equations.

  • Ok. So instead of moving the target sprite by a fixed distance, such as 100, you could make it proportional to the speed.

    Something like:

    move 1*player.speed pixels at angle player.angleOfMotion

    That way it will be centered on the player when not moving. Probably you'd want to tweak the 1 if the screen shifts too much or two little. Another idea is to just center the target on the player when the speed is less than a value and otherwise move it by an offset.

    move player.speed<50?0:100 pixels at angle player.angleOfMotion

    Where 50 is the speed and 100 is the offset.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could create a sprite to be the target. So you cam make the target be ahead of the player by say 100 pixels with this:

    every tick

    --- target: set position to player

    --- target: move 100 pixels at angle player.angleOfMotion

    Then you'd do your lerp scrolling to the target instead of the player.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound