Shindoh's Forum Posts

  • Am I right with my observation of the behaviour of the Function Object?

    Let's say further down our list of events we have a "Call Function" Action next to an event.

    But we check for the Function before that Event. We check "On Function" in our Event List above "Call Function".

    Now in one Tick, we check the Event List from top to bottom.

    The first time the Event "On Function" is checked, it is ignored.

    Now when the Event (containing the "Call Function) itself is actually checked, it will first perform all Actions for that Event, until the Action "Call Function" is encountered. If it encounters "Call Function" in the Actions list of an Event, it will stop reading Actions after this and instead check all Events from top to bottom again for "On Function" with the same name. And it will execute all of the Actions for those Events first.

    When it is finished doing so, it will continue reading the Actions from the Event in which "Call Function" was just executed.

    Am I right?

    I think this checking behaviour is pretty important to know to use the Function Object properly and avoid unwanted results. It should be noted in the documentation. I only noticed this because something strange was happening, and I am constantly running with a very low Fixed Framerate to check what my code is doing, how exactly it is being checked and run. But I imagine if it runs faster, and things are harder to see, the processes going on, and their order are often harder to understand, if something is just seen for 16ms (in the case of 60 FPS). That could lead to bugs, that You later can't understand.

    The way the Events are checked in one Tick should always be clear to the user to avoid confusion.

  • I don't see such a big problem.

    If You did the jumping animation of the wolf close to its real jumping behaviour in life, the two front legs should be reaching forward, with the back legs spread to the back (in mid-air). And when he is landing, he should be landing with his two front legs first, and as they are touching the ground, the two back legs would come forward and probably touch the ground close to the front paws (slightly behind or in front of). Then the front legs make a slight step forward again, to ease out the body.

    (Just google "wolf jumping" to see what I mean.)

    So basically this should be able to look pretty natural, if You mimick its real moving behaviour.

    Of course depending on which angle he is jumping from, say from below, or from above onto the surface, You'd have to change the angle of the animation a little.

    For example, if I had the full animation, as I described above, I would generaly do it like this:

    Let's assume the mid-air sprite is 100px wide. And the hotspot (for determining its position) is in the middle of the sprite. I roughly guess the size of the paws as 10px now, so the sprite needs to be on the surface with at least 10 px, to move onto it.

    Assuming You're jumping from the left:

    If Wolf is Jumping AND If Mid-AirAnimation is playing AND If Wolf.Left + 90(px) Equal or Greater than PlatformSprite.Left AND Wolf.Bottom Collides with PlatformSprite.Top -> Play LandingAnimation; Move Wolf.X with about 90px. (because body is easing out in animation and taking a step forward for landing)

    Of course You would have to slightly adjust it for different jumping angles, like I mentioned before. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Thank You for the fast reply, Ashley.

    But if V-Sync works that way, shouldn't the lag theoretically get worse each second then? Like I wrote in my example with the counting of the second?

    In other words, reading of the code is not affected by it. So I might press a button, the program realizes it exactly on time, as fast as it can, but the graphics card draws the necessary frames to the buffer, and sends them to the screen only as it is ready.

    To my current understanding, since we have two things basically running at different speeds, the distance between the two will get bigger with time. Like in my example.

    So the frames lagging behind will get more with time, but it doesn't happen in reality. That's what I don't understand.

    Indeed, why not just limit the speed of the processing cycle of the events? So it will only always check the list of events/code with a time interval given by the the Hz of the screen refreshrate. Shouldn't that solve the problem very easily?

    I mean I just don't understand if fixed framerate has no problem with lag the way it works, why doesn't the program just recognize the users screen's refreshrate and then set the fixed refreshrate to that of the screen.

    In that case I don't even see the use of v-sync, it seems very limiting.

  • Okay, I feel like I have some misunderstand, or am missing something about the concept behind Fixed Framerate and V-Sync, because something doesn't make sense here.

    When we set a Fixed Framerate, as I understand it now, we basically set the speed of the repetition of the processing & rendering cycles for the computer, which is why there is no lag.

    When we set V-Sync, it is possible to get lag, if the processing and rendering is much faster than the refreshrate of the screen. I don't understand this. That means V-Sync doesn't set the speed of the repetition of the processing cycles, but actually just let's it wait and only allow to display new images, when the screen is finished with the old one? Why doesn't it just work as fixed framerate, just set to the refreshrate of the screen then?

    Now let me define lag. Lag means executing an input, but having the related action on screen appear delayed, not on time with the input.

    Now if it is that way, I don;t understand another thing. If the lag is due to the speed difference, it should theoretically get worse with time. Let's say the refreshrate of the screen is 60Hz and the speed of the processing is 120FPS, twice as fast. So let's see, it'd go like this, or not? -> 1st Second- Screen(showing): 2 Frames; PC(has): 4 Frames; 2nd Second- Screen: 4 Frames; PC: 8 Frames; 3rd Second - Screen: 6 Frames; PC: 12 Frames.

    In other words, in this example in the beginning we have 2 frames difference, and on after 3 seconds, we have 6 frames lagging behind.

    Why doesn't anything here make sense to what I see?

    I just recently tried to read up on that again, to see what causes screen tearing. Which (interestingly enough), I understand how it happens, but it never happens, even if I make an experiment on my laptop. I know its' refreshrate is 60 Hz, but no matter what fixed framerate I put, it never tears. So I don't get it again.

    I feel like I missed something.

    Thank You for any help I could get clarifying this.

  • Thank You tulamide. Yeah, that makes perfect sense now, I didn't think about that. If I'd want to change something later on, I'd have to change it in every single event sheet again and again for the layouts. And of course the reduced amount of events. Indeed, with repeated groups it could get huge later on.

    It would be nice to include this thinking on the use of the event sheets and groups in the documentation. Maybe list it in optimisation tips or an area for "good working habits", or a reference on the page for event sheets and groups respectively.

  • But You see, that's where I feel there is not much more than a cosmetic difference.

    Let's say we have a separate event sheet for our animation system.

    Then for every new level (new layout), we include it into the new layout's event sheet. What we then see is a small line, saying "Inlcude Event Sheet: ..."

    Now, what if I just had all the code from the animation event sheet inside a group?

    Then what we would have is, instead of "Include Event Sheet: ...", a line saying the name of the group "Animation System", which we could expand.

    Now for every new level, we just copy the layout with it's event sheet, or include that layout's event sheet in the new layout, and delete all the parts not fitting the new level, and add the parts specific to that new level.

  • I remember seeing some people using seperate event sheets, and just including them in the current one for the layout.

    I was wondering if there was any benefit I can't see over having groups inside the event sheet?

    Thank You <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the fast reply and letting me know, guys! <img src="smileys/smiley1.gif" border="0" align="middle" />

    I'm going to give it a try later.

    Although weird that it works, without seemingly giving the value to the variable in the other enemies, at least not visibly so in Debug Mode.

  • In my example we have several kinds of enemies, all in the enemy family.

    Now every enemy has the private variables for OriginalHeight and OriginalWidth.

    These variables are set to their respective height and width values of enemy objects and instances at the start of layout, once.

    Now in theory I thought, it will set the variables individually for every object in the enemy family. However what I can see in Debug Mode is that only one kind of enemy in the enemy family gets the values set. The other kinds of enemies have the variable, but don't set any value, it stays zero.

    My confusion comes from the fact, that despite this, one of the formulas I used, containing these variables values, still works for every enemy type.

    I basically set the position of the player in a certain case to: "enemy.X - enemy.OriginalWidth/2 - player.Width/2" and the same for Y and Height.

    Divided by 2 because their hotspots are in the middle. I want to position them exactly next to each other, and both sprites so to speak with their feet, the bottom of their sprite at the same Y position.

    The enemies purposefully for testing this have different sizes.

    So I don't understand why, although their variables basically have the value 0, the positioning of the player still works fine for the other enemies?

    Thank You in advance. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • The way I would do it:

    Grab Ledge:

    • When Sprite Position reaches near ledge during a jump, stop Jump Event.
    • Change Animation to LedgeGrab-Animation.

    (Align the frames of animation with their Hotspot so, that they will be perfectly aligned with the ledge/wall.)

    For the Pull it depends on how much animation You want to use.

    Depending on that I would program it differently to make the movement more smooth.

    The easiest way would be to have no extra Pull-Animation.

    Instead, to get up the ledge from the grab, You trigger a Jump.

    So You would be jumping up the ledge from Your grab.

    I think a lot of old 2D games used this method.

  • Could You describe in detail how Your event to do so looks right now?

  • Hey newt, thanks for Your quick reply!

    I think You misunderstood my problem. In fact the animation plays fine this way, although I see that Your code should actually be the right one when I think about it? lol; I mean it doesn't keep displaying the first frame of animation with my code, it plays normally and loops.

    Anyway, my problem was not with the display of the animation, but the correct movement in time, relative to the animations original fps. It was animated to be seen with 16fps.

    That means, the sprite should only move forward in X, when it changes frames to the next frame in its loop.

    Now the application itself is set to run with V-Sync.

    The animation itself in its "animators properties" area is set to run with 16fps.

    So, as long as the Thumbstick is held in the forward direction, the walking animation will be playing, it will play with it's own fps set in the animator and should be move forward in X, every time the frame changes.

  • As long as I press in one direction with the Thumbstick of a Controller:

    • The walking animation is played.
    • Every next frame of the animation the sprite should move += 10px.
    • I want to keep the game V-Synced.

    Right now, my code is:

    if Xbox360GamePad.LeftThumbstickX(1) > 0:

       Player.SetAnim(walk)

       if Player.OnAnimFrameChange():

          Player.X += 10

    The walk animation's own speed is set to 16fps in its own settings.

    But what happens now, the Sprite seems to move with the V-Sync speed, instead of the 16fps. Way too fast.

    What did I oversee here?

    Thanks in Advance!

  • Hey guys,

    If I remember right there are two Controller Plugins for Construct?

    The last time I checked, there was no way to check for how far a Thumbstick has been pressed (or rather tilted) into a +-X/+-Y direction, the same for the shoulder triggers.

    Did I miss something now, or back then?

    I know Game Maker has it's xInput plugin made by someone from the community, where You had full control over everything.

    Thanks in advance!

    EDIT:

    I just found an old post about it, the values for the Thumbsticks and Triggers are accessible in an expression (left_thumb_x) and (left_thumb_y) etc. with a value scale of -1 to 1 respectively for the Thumbsticks and a scale of 0 to 1 for the Triggers.

  • Guys, I love You. And R0J0hound, exactly that! Thank You!