R0J0hound's Forum Posts

  • Logomachine

    You could draw those sprites to the "paster" or "canvas" plugins, and then destroy the sprites to reduce the number of objects. The physics behavior itself has more features that we need. Basically we only need a simpler physics for the particles and a per-pixel collision detection. Such collision detection isn't compatible with polygon collisions, so all motion would need to be done via events. Drawing to the terrain is doable as stated above, but with a huge amount of moving pixels it would be faster setting pixels directly rather than using sprites and such which is faster for larger objects.

    Lastly to get the utmost speed js should be used instead of the event sheet.

    Elliott

    It's the type of game that needs as much optimization as possible and C2's general purpose nature isn't efficient for it. It does stuff like per-pixel collisions, and reading and writing pixels which C2 doesn't do because such features, even when optimized are only usable for low-res games.

  • This expression will get the red of the pixel under the mouse:

    Browser.ExecJS("var canvas=document.getElementById('c2canvas');
    var ctx=canvas.getContext('2d');
    var pixel=ctx.getImageData("&int(LayerToCanvasX(0, mouse.x, mouse.y))&","&int(LayerToCanvasY(0, mouse.x, mouse.y))&",1,1);
    pixel.data[0];")[/code:3193z21z]
    
    You can get the other color components by changing the 0 in
    pixel.data[0]
    to 
    1 for green
    2 for blue
    3 for alpha
  • BlueSkies

    Yeah it's the same way to access pixels.

    Logomachine

    Physics would work in concept, but in practice it would be much too slow. A manual per-pixel motion as you describe would be a bit faster, but you'd need to implement most of it in js to get a useable speed.

  • In a simple case the general score could just be the sum of the scores.

    a+b+c+d

    You can further tweak that to give some scores priority over others like:

    4*a+3*b+2*c+d

    which would give the "a" score the highest priority.

    It can be more finely adjusted to adjust the priorities of the scores. You could even pick the factors at random to get a unique ai.

    I suppose you could use any arbitrary formula to combine the scores into one value as well, but probably simpler is better.

  • It's a limitation of sorts. A forum search of "top level event" should give some topics about this.

    Basically event 1 is a top level event, and event 2 is a sub event.

    When you create and object it becomes the only picked object of that type. However it isn't added to the sprite list yet.

    I think I explain it better in another post

    Say there are 3 sprites, with uid's 1,2 and 3.

    When event 1 starts c2 internally has these three lists.

    Sprite 1,2,3

    Picked 1,2,3

    New empty

    So an object is created with uid of say 4 and at the beginning of event 2 the lists are as follows:

    Sprite 1,2,3

    Picked 4

    New 4

    Notice the new object isn't added to the sprite list yet.

    In event 2 the "pick all" condition only picks everything in the sprite list, so the result is:

    Sprite 1,2,3

    Picked 1,2,3

    New 4

    Finally after event 2 there are no more sub events of event 1 so this is a top level event and the new list is merged with the sprite list.

    Sprite 1,2,3,4

    Picked 1,2,3,4

    New empty

    Anyway there are a few ways to deal with this.

    One I've used is to just create the objects in one start of layout and effect the sprites in a second one:

    Start of layout

    --- create sprite

    Start of layout

    --- sprite: set opacity

    Another way could be to do your events as you have it but modify the new object as you create it and use pick all to affect the existing objects.

  • Ah, I was hoping there was more to it. Last I looked I couldn't find any issues with the code at that line and I haven't been able to reproduce it.

  • heliogame

    "angle()" is an expression so I mean using the expression

    angle(0,0,self.vx,self.vy) [/code:3yxzni2q] when setting the angle.  Also I didn't mean using the bullet behavior.  "bullet" was just the object name I used.
  • I don't think regex is suited for that. A better way would be to add each number to a dictionary to eliminate duplicates. for example:

    global string list1= "112, 113, 112, 114, 113, 112,"

    global string list2=""

    repeat tokencount(list, ",") times

    --- Dictionary: add key tokenat(list, loopindex, ",") with value 0

    dictionary: for each key

    --- add Dictionary.CurrentKey&"," to list2

  • If I enjoyed doing it (which I did), then it was time well spent.

  • You can find a equation by googling the distance between a line and a point.

    If a and b are the two points of the diagonal and p is the other point then the distance from p to the line would be:

    Abs(((P.x-a.x)*(b.y-a.y)-(p.y-a.y)*(b.x-a.x))/distance(a.x,a.y,b.x,b.y))

    Edit:

    Oops you wanted y distance, that would be this:

    Abs(Lerp(a.y, b.y, (P.x-a.x)/(b.x-a.x))-p.y)

  • jobel

    With 8 instead of 4, then with one ray it would do twice as many intersection tests.

    In general if there is no culling, the number of intersection test will equal=

    (number of rays) * (number of image points)

    So if you increase either then the amount of time will increase proportionally.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes you can, it becomes much simpler to do physics when it's just in a line like that.

    The motion is simple: increase the speed with gravity and move down with the speed.

    Collision detection is done by looping over the blocks from the bottom up. If the current block overlaps the block below push it up and set it's speed to the speed of the block below ...and repeat.

    https://dl.dropboxusercontent.com/u/542 ... olumn.capx

    ps. the speed change isn't physically correct when the objects collide. The actual speed of both blocks after a collision should be the average of the speeds, but it would add some complexity to the events.

  • looking at it again you'll probably want width>400 since by subtracting from the width it should be shrinking.

  • Repeat 1 means the animation is played once. I tested using 0 instead and it's the same, so it would seem 1 is the minimum number of times an animation will play thru.

  • For that simple case, yes.