R0J0hound's Forum Posts

  • 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.

  • 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.

  • From the sound of it that is the case. I can understand it is more performant to do the pasting when everything else is drawn, but it does nerf its use in a lot of ways.

  • If the platform has no thickness you can do this. Just have the origin at the top. Z is any value you want to adjust the effect. 1.5 could be a starting point.

    Set height to self.y-((self.y-scrolly)/z+scrolly)

  • No, I don’t believe so. Not with the features exposed to the event system as I recall. AA can be disabled on html5 canvas elements from JavaScript with a variable that differs with different browsers. I’m not going to touch that though. It requires modifying the plugin.

  • That's a pretty cool result. The issue is caused by the texture packing, it throws off the uv's. I never found a solution. It's just one of those things I considered broken and never touched.

    You can avoid the texture packing by manually loading the animation frames from events. Basically put all the images into the "files" folder in the project bar. Then at the start of that layout set the animation frame and use the load animation frame action to load the image file. Maybe use smaller dummy images initially. It's an idea at least.

  • You’re making an assumption with how it’s implimented. It’s probably trivial to convert, but I don’t find it worthwhile to do so.

  • There isn’t anything I can help with. I only use c2 and am unfamiliar with making c3 plugins.

  • You do not have permission to view this post

  • You’d get better performance with a tilemap instead of multiple sprites. There are a few examples on the forum you can find with search.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you make the river area a solid color you can then use a blend mode to put a tiled background within it.

    So create a new layer. Set force own texture to true. Place a sprite for the shape of the river. Put a tiled background on top and set its blend mode to destination in.

    I guess for the shore lines you’d do an additional layer or something.

    You could also create the river with multiple sprites or you could draw a big polygon with the canvas plugin.

  • I've done it with an array. That zorder action wont really work here. Say you have an instance variable "z" for both sprite and tiledbg.

    Every tick

    -- array: set size to (0, 2, 1)

    for each sprite

    -- array: push sprite.z to front x

    -- array: set at (0,1) to sprite.uid

    for each tiledbg

    -- array: push tiledbg.z to front x

    -- array: set at (0,1) to tiledbg.uid

    every tick

    -- array: sort x

    array: for each x

    -- sprite: pick by uid array.at(array.curx,1)

    ----- sprite: send to front

    -- tiledbg: pick by uid array.at(array.curx,1)

    ----- tiledbg: send to front

  • Plugins seem like an overkill for something like this.

  • It’s been ages since I derived that formula so I don’t know other than it is related to the ball size.

    Basically place the balls down manually, then calculate the y difference between two rows. It actually would come out to 16*sqrt(3) which is about 27.6 but I just rounded to 28 to be able to snap to integer positions.

    I calculated it by placing two balls on one row and one ball between them on the next. Draw a triangle between the centers. Each side is 32. Cut the triangle in half. The horizontal side is 16, the diagonal side is 32 and we can calculate the vertical side with the Pythagorean theorem. a^2+b^2=c^2 where a=16, c=32 and just solve for b