R0J0hound's Recent Forum Activity

  • So just to clarify you have an animation of a 3d ball rolling and you want it to be syncronized with the motion of the ball?

    In the simple case of having an animation of the ball rolling to the right you can set the angle to be the same as the angle of motion as you have above.

    The second thing to do is correlate the animation speed with the speed of the object's motion.

    So depending on the number of frames you can find the time for a full rotation with:

    Time_for_full_rotation=num_frames/animation_speed

    So we can the find angular speed with:

    Time_for_full_rotation*angular_speed=360

    Which then solves to:

    Angular_speed=Animation_speed*360/num_frames

    You can then relate linear speed to rotations with:

    Speed=radius*anglular_speed*pi/180

    Then combining the two:

    Speed=radius*animation_speed*2*pi/num_frames

    And solving for animation speed we get our formula:

    Animation speed=Speed*num_frames/(radius*2*pi)

    Speed can be calculated as you have.

    Radius is half the width of the ball.

  • Two colors would make an interesting art style. This game does it and it looks pretty cool:

    http://dukope.itch.io/return-of-the-obra-dinn

  • smk

    Thanks for the detailed write up. I always enjoy reading about that kind of low level stuff, and I could only gather so much from skimmed through the source. To post links, I've seen newcomers putting then inside

     tags and the forum doesn't erase them.
    
    @spongehammer
    @Logomachine
    I was toying with a way to access pixels to see how fast it could be from construct and here's a working test:
    [url=https://dl.dropboxusercontent.com/u/5426011/examples28/imageData.capx]https://dl.dropboxusercontent.com/u/542 ... eData.capx[/url]
    It's fast but only when using js.
    With a 160x120 image, updating all the pixels took an average of 12 ms on my machine.  For 60fps that plus everything else needs to be 16ms or less.
    The event system on the other hand was way to slow to loop over the pixels.  I actually just looped over a 160x120 array to set each xy to a random number and got an average of [b]230 ms[/b].
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound