R0J0hound's Recent Forum Activity

  • Hi.

    The “compare: dt>0” is correct. Dt can be 0 in construct but we don’t want that since we divide by dt, and dividing by 0 would give infinity.

    And yes, we are setting diff twice but the second one is using the result of the first. Basically what that’s calculating is the signed angle difference or: singnedAngleDiff(a,b)=angle(0,0,cos(a-b),sin(a-b))

    Or another way to think about it is first we set diff=a-b then we normalize the angle to the range -180,180.

    The third action had a typo. “da” should have been “diff”. My apologies. The formula defines a damped spring.

  • Giving something momentum basically means you give it velocity and instead of changing the position or angle, you’d change the velocity.

    It’s pretty popular to use lerp() to do an ease out but I don’t think that’s suitable to use with momentum.

    So you’d add a angvel variable to the sprite and then one way you can change the angular velocity is with a damped spring. Diff is the signed angle difference which is like the anglediff() expression but it’s negative if ccw. In the expression that sets the angvel you’ll see 0.1. You can change those in the range of 0-1 to adjust the spring stiffness and the amount of damping.

    Var diff=0

    Compare: dt>0

    — set diff to sprite.angle-angle(0,0,gamepad.axis(0,2),gamepad.axis(0,3))

    — set diff to angle(0,0,cos(diff),sin(diff))

    — sprite: add -0.1*diff/dt-0.1*self.angvel to angvel

    — sprite: rotate self.angvel*dt degrees clockwise.

  • Well one way would be to have one sprite type and call it “card”. You’d have all the different looks of the cards as different animation frames, and you’d set the animation speed to 0. Basically you’d create or destroy individual cards to add or remove cards you own.

    You’d then select certain cards from that with conditions to pick them.

  • It’s probably not random.

    You sound like you have a specific behavior you’re after that you have footage of or have seen. You could start by examining the motion of one leaf and trying to break it down into a path that you could replicate somehow. Worst case you could maybe use a timeline to manually plot a path. With two or three varieties you may get enough variation.

    At the other end of complexity you could try some grid based fluid dynamics to model airflows. Then the leaves would move based on where they were within it since you would have velocity at any point. Then you could model the leaves as slightly curved apply the wind to them based on the angle the wind hits them.

    There are probably many options in between. I don’t have any specific examples in mind though.

  • You don’t want to use Sprite.width since it’s changing. Worst case just use a fixed number such as 64 or whatever width you want it to start at when not rotated.

    I guess it’s sprite.ImageWidth not originalWidth.

  • Interesting take to consider the 0-255 range a relic. It’s standard to represent a pixel with a 32bit integer or 8bits (0-255) per component. That’s used in textures, the screen and when you snapshot a drawingCanvas.

  • Probably just:

    Var rotY=0
    
    Every tick
    — add 50*dt to rotY
    — sprite: set width to self.originalWidth*cos(rotY)

    Also it’s probably not necessary to post the question twice in both the c2 and c3 sections. The forum is already slow and most just look at new posts so they’ll see the question no matter where you post it.

  • Wouldn’t it be simpler to just save the type and position of each card?

    Global text data=“”
    
    On function save
    — set data to “”
    — for each card ordered by card.zindex ascending
    — — add card.x&”,”&card.y&”,”&card.animationframe&”;” to data
    
    Global text tok=“”
    
    On function load
    Repeat tokencount(data,”;”)-1 times
    — set tok to tokenat(data,loopindex,”;”)
    — create card at float(tokenat(tok,0,”,”)), float(tokenat(tok,1,”,”))
    — card: set animation frame to int(tokenat(tok,2,”,”))
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's an example. I think it's cool the planes never collide.

    dropbox.com/scl/fi/yzoz4teghe9etfoa2qml8/flower_path.capx

  • I only use the free version but generally nwjs is not equal to webview2. Namely webview2 hasn’t implemented all the features available in nwjs.

    So basically file a few feature requests for the webview2:

    * be able to hide toolbar

    * fix window.open(url,””,”popup”) to open a new window instead of a new tab.

    Changing the title should be simple in js with:

    window.document.title = “new title”;

    You can also change the title of the popup window with:

    let popup = window.open(url,””,”popup”)

    popup.document.title = “new title”;

    Or you can change it in the html page from the url.

    If that doesn’t work with the webview2 export then file a third issue. Or you can also stay with nwjs.

    Having the two windows interact is up to you. In JavaScript you have access to the popup window to be able to call functions as seen above. And from the popup window you have access to the parent window with window.opener. You can do what you like with that.

  • I’d argue that the web has an inadequate feature set for that. Window.open() can create a separate window but it’ll have to be an entirely different page, it can’t just render parts of the existing project. You’ll probably need to load the same project twice and somehow communicate that the new instance should be a toolbar, or you’d have a specific project per sub window. Also you’re limited with how you can customize the window. It would be dependent on extra features provided by nwjs or webview2 if any. By default the popup window includes a title bar and the url bar and you can’t remove them.

    To communicate between the two you can just utilize some js functions. Basically when you create a window with window.open() it returns the window’s global scope.

    You can transfer things between the two any way you like but you could look into the drag drop api to see if that’s useful.

    developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API

    You won’t be able to do stuff like dragging the toolbar of the window to do that though. The browser just doesn’t provide access to such things. More is theoretically possible in a wrapper such as nwjs but even that doesn’t provide stuff like that. Overall not much is implemented to help with that.