R0J0hound's Forum Posts

  • The random(1) expression causes the “for each ordered” to loop over the instances in a random order. The loopindex is 1 when it’s on the second instance.

  • Another way that is useful in some situations is:

    For each sprite ordered by random(1)

    — do stuff

    — compare: loopindex=1

    — — stop loop

  • The effect does the outline by shifting copies of the image in four directions. So the corners would look off.

    I may have remembered wrong. It may be 8 directions and the diagonals had sqrt(2) multiplied by it.

    Anyways, I haven’t touched in a long time. Not sure how to get more perfect results.

  • Looping over all the tiles should only be needed to be done once to get the count and update the edges.

    After that you can easily update the count as you add/remove tiles. You can also update the edges by only looking at the tiles around the tiles that changed.

    If a high amount of tiles change then you may not want to update the edges around each one. Instead you could just update the edges of all the tiles on screen.

    Outside of events, if you can do the update via JavaScript it would be way quicker with the loop. The trick is finding a way to accomplish it

  • I’m not sure how c3 does the tweening, but you can do it with an expression. First you have a variable t that will increase with a constant rate from 0 to 1. In the following it does it over 2 seconds. Then to do the ease/out you can use the cosp() expression. But there are other ways.

    Var global=0

    Var t=0

    Every tick

    — set t to min(1, t+dt/2)

    — set global to cosp(0, 100, t)

  • So best I understand it the crosshair is moved with the mouse, and then the camera is moved so it's both looking at the crosshair and is behind the player?

    To do that I set the crosshair position to the mouse position on a 2d non parallax layer.

    To make the camera delayed behind the crosshair I positioned a lag object that lerps toward the crosshair.

    Then I calculate a unit direction vector from the player to the lag object.

    We can then calculate a position a certain distance behind the player to use as the camera position, and then look at the lag object.

    dropbox.com/s/h0pc8l4zl98f8kl/delayed_third_person_camera.c3p

  • winkr7

    Turns out you were right, it runs the next tick. Guess looping backwards over the list works to do that.

    waitlist = []
    time = 0
    
    function wait(t){
     waitlist.append({when:time+t, events:followingEvents})
    }
    
    while(gameRunning){
     time += dt
     run(eventsheet)
     for(i=waitlist.length-1; i>0; --i){
     if(waitlist[i].when<=time){
     run(waitlist[i].events)
     waitlist.remove(i)
     }
     }
    }
  • Not sure. We could test that with something like this:

    Star of layout
    — set text to tickcount
    — wait 0 seconds
    — set text to self.text&tickcount
    — wait 0 seconds
    — set text to self.text&tickcount

    Depending on how wait is implemented we could get 000 or 001.

    Edit: I’m inclined to think it would be 000, aka all wait 0 after a wait will be run. The logic may be similar to the following. If I wanted it to delay to next frame it would be more complex I’d imagine. We could always look at the c2 source to see how wait is implemented too.

     waitlist = []
    time = 0
    
    function wait(t){
     waitlist.append({when:time+t, events:followingEvents})
    }
    
    while(gameRunning){
     time += dt
     runEvents()
     for(i=0; i<waitlist.length; ++i){
     if(waitlist[i].when<=time){
     run(waitlist[i].events)
     waitlist.remove(i)
     i-=1
     }
     }
    }
  • It probably works like this, at least that’s how I rely on it working.

    Update loop

    — run event sheet

    — run wait events that are done

  • Here is a way to rotate around any point. Set cx,cy to the point you want to rotate around, and set a to the amount to rotate.

    var a=1
    var cx=100
    var cy=100
    
    rotate a degrees
    set position to
    (self.x-cx)*cos(a)-(self.y-cy)*sin(a)+cx, (self.x-cx)*sin(a)+(self.y-cy)*cos(a)+cy
  • Here is an alternate way. It checks the value with all the other values and if any match it randomizes the number again and re-does the check.

    dropbox.com/s/z0an316nusgc6nu/unique_random_list.capx

    If you were only concerned with the values 1 through 6 you could do something simpler like this too.

    dropbox.com/s/mb9he4ke03d7r23/unique_random_list2.capx

  • sir lolz

    Not with this plugin. The paster plugin supports that.

  • You have to loop over the array backwards.

    Var i=0
    Var count= Array.width
    
    Repeat count times
    — set i to count-loopindex-1
    — array.at(i) == 0
    — — remove array at index i

    Or you can

    Var i=0
    Every tick
    — set i to 0
    
    While
    i<array.width
    — array.at(i) == 0
    — — remove index i
    — — subtract 1 from I
    — add 1 to i
  • Idk, using a wave collapse function doesn't seem to keep everything connected.

    Here's an experiment with it. I don't think I provided enough tile cases since it can't resolve a few tiles. It was interesting to mess around with though. It probably could be made to erase those dead ends to try again. It would also be nice to give some tiles more weight than others.

    dropbox.com/s/grb9i41yhpy8uhp/waveFunctionCollapse.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First you find an equation to get the circle that goes through the three points, and then there was some extra math to transition from one angle to the other to plot points on the arc.

    dropbox.com/s/rwk6kjs9brx8myr/arc_through_3_points.capx