Distort Maps.. enter the matrix

This forum is currently in read-only mode.
From the Asset Store
A template which allows you to customise the controls of your game.
  • Ok I have a distort map on a sprite with 5 columns, and 10 rows something like this:

    00 10 20 30 40 50

    01 11 21 31 41 51

    02 12 22 32 42 52

    03 13 23 33 43 53

    04 14 24 34 44 54

    05 15 25 35 45 55

    06 16 26 36 46 56

    07 17 27 37 47 57

    08 18 28 38 48 58

    09 19 29 39 49 59

    Now I now I could use some loops to set the matrix, the question is, should I?

    If I input the coords manually Ill have an event that's freakishly long, but if there's a difference in performance I'd rather use the faster/ less cpu intensive.

    So which would be better?

    Keep in mind I also have to make another map with columns, and rows switched.

  • Try this comparison CAP:

    http://www.republika.pl/tymczasownik/loops_test.cap

    Layout1: manual

    Layout2: "for" loop

    Layout3: action: "start loop"

    Distortion map is ran 10^5 times and profiler retrieves time used to do those operations (output in text).

    As for my machine, the results for 1st method were about 4x better than Lay2 and Lay3.

  • Profiling the 'set displacement at' actions probably isn't worthwhile: it's irrelevant if you only set the distort map once, and even if you update it every tick, the extra vertices sent to the GPU are probably a bigger overhead.

    Since there can be a lot of distort map points, using a loop is probably the most convenient, from the events.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright thanks guys.

    Actually I've created a bigger headache than just 5 x 10. For what I want to do I need to move the entire width of the row, so its not just one displacement/ one pixel per row, but two.

    So Ill have 12 events for each row, with five rows

    Also I forgot to factor in that the displacement starts at row 0, column 0, so instead of 5 x 10 it'll be 5 x 9, but I still have the same amount of events to make... funny no?

    Edit weeeeeeeeee!!!

    nmy1: 114 On shoot

    nmy1: 214 is moving

    Friendly: 64 Friendly: Pick closest to: nmy1 0 .X, nmy1 1 .Y

    elec1Set displacement (real) at (0, 0) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 1) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 2) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 3) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 4) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 5) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 6) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 7) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (0, 9) to (nmy1 0 .ImagePointX("1"), nmy1 1 .ImagePointy("1"), 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (5, 0) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 1) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 2) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 3) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 4) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 5) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 6) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 7) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (5, 9) to (Friendly.ImagePointX("2"), Friendly.ImagePointy("2"), 0, 0, filter : 0 , 100)

    elec1Set displacement (real) at (1, 0) to (elec1 0 .ImagePointX("1") , elec1 1 .ImagePointY("1") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 1) to (elec1 0 .ImagePointX("1") , elec1 1 .ImagePointY("1") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 0) to (elec1 0 .ImagePointX("2") , elec1 1 .ImagePointY("2") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 1) to (elec1 0 .ImagePointX("2") , elec1 1 .ImagePointY("2") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 0) to (elec1 0 .ImagePointX("3") , elec1 1 .ImagePointY("3") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 1) to (elec1 0 .ImagePointX("3") , elec1 1 .ImagePointY("3") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 0) to (elec1 0 .ImagePointX("4") , elec1 1 .ImagePointY("4") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 1) to (elec1 0 .ImagePointX("4") , elec1 1 .ImagePointY("4") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 2) to (elec1 0 .ImagePointX("5") , elec1 1 .ImagePointY("5") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 3) to (elec1 0 .ImagePointX("5") , elec1 1 .ImagePointY("5") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 2) to (elec1 0 .ImagePointX("6") , elec1 1 .ImagePointY("6") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 3) to (elec1 0 .ImagePointX("6") , elec1 1 .ImagePointY("6") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 2) to (elec1 0 .ImagePointX("7") , elec1 1 .ImagePointY("7") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 3) to (elec1 0 .ImagePointX("7") , elec1 1 .ImagePointY("7") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 2) to (elec1 0 .ImagePointX("8") , elec1 1 .ImagePointY("8") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 3) to (elec1 0 .ImagePointX("8") , elec1 1 .ImagePointY("8") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 4) to (elec1 0 .ImagePointX("9") , elec1 1 .ImagePointY("9") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 5) to (elec1 0 .ImagePointX("9") , elec1 1 .ImagePointY("9") + random 50- random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 4) to (elec1 0 .ImagePointX("10") , elec1 1 .ImagePointY("10") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 5) to (elec1 0 .ImagePointX("10") , elec1 1 .ImagePointY("10") + random 50- random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 4) to (elec1 0 .ImagePointX("11") , elec1 1 .ImagePointY("11") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 5) to (elec1 0 .ImagePointX("11") , elec1 1 .ImagePointY("11") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 4) to (elec1 0 .ImagePointX("12") , elec1 1 .ImagePointY("12") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 5) to (elec1 0 .ImagePointX("12") , elec1 1 .ImagePointY("12") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 6) to (elec1 0 .ImagePointX("13") , elec1 1 .ImagePointY("13") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 7) to (elec1 0 .ImagePointX("13") , elec1 1 .ImagePointY("13") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 6) to (elec1 0 .ImagePointX("14") , elec1 1 .ImagePointY("14") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 7) to (elec1 0 .ImagePointX("14") , elec1 1 .ImagePointY("14") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 6) to (elec1 0 .ImagePointX("15") , elec1 1 .ImagePointY("15") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 7) to (elec1 0 .ImagePointX("15") , elec1 1 .ImagePointY("15") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 6) to (elec1 0 .ImagePointX("16") , elec1 1 .ImagePointY("16") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 7) to (elec1 0 .ImagePointX("16") , elec1 1 .ImagePointY("16") + random 50- random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, to (elec1 0 .ImagePointX("17") , elec1 1 .ImagePointY("17") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (1, 9) to (elec1 0 .ImagePointX("17") , elec1 1 .ImagePointY("17") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, to (elec1 0 .ImagePointX("18") , elec1 1 .ImagePointY("18") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (2, 9) to (elec1 0 .ImagePointX("18") , elec1 1 .ImagePointY("18") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, to (elec1 0 .ImagePointX("19") , elec1 1 .ImagePointY("19") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (3, 9) to (elec1 0 .ImagePointX("19") , elec1 1 .ImagePointY("19") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, to (elec1 0 .ImagePointX("20") , elec1 1 .ImagePointY("20") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Set displacement (real) at (4, 9) to (elec1 0 .ImagePointX("20") , elec1 1 .ImagePointY("20") + random 50 - random 50, 0, 0, filter : 2 , 100)

    elec1Make Visible

  • that is why i loooove the "disable smilies" checkbox

  • Or use

    [code] tag[/code:2y968lmb].
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)