Guizmus's Forum Posts

  • Well, I don't like problems I can't correct.

    So here is the debug. In the runtime.js of the pathfinding behavior, just add the following code in the behinstProto.oncreateFunction, once this.a is set (line 73) :

              this.inst.add_bbox_changed_callback(function (_this){

                  ?return function (inst) {

                        _this.a = inst.angle;

                  ?};

              }(this));

    I used what I learned from your code in particules plugin (the only one I found using the add_bbox_changed_callback function), but I didn't see any "remove_bbox_changed_callback", so I didn't know if and how to remove the eventlistener once the object is destroyed. Not finding the function in any other behavior made me think there was a more appropriate function, didn't find one though.

  • Hey DoudouSupreme

    Long time no see ^^

    I saw that you couldn't, also saw your "bug report" about it ^^ I'll send my mail.

    For your problem, please, upload a capx ^^

    The problem is event 61. You think you picked the volume with the condition "NPC Is overlapping Volume" when in fact you picked both. You have to pick the NPC first.

    If you don't, the overlapping condition will just pick the 2 NPCs and the 2 volumes (they are overlapping at first). Then, the NPC : Pick instance with UID will just restrict the picked NPC to the one you wanted. In the end, your "picking set" will be the 2 volumes and the NPC. I'm not sure what the function calling will send in Volume.UID, as there are 2. Not what you want anyway.

    Next, you could easily just change the Find Path parameters to :

    X : random(Volume.Width)+Volume.X

    Y : random(Volume.Height)+Volume.Y

    Making the NPC obligated to move inside the volume.

    Last thing, event 62, the function picks a volume, but no NPC is specified, so all NPC are selected. You have to add a second parameter to the function (NPC.UID) and select the NPC too in the function event. You could also forget about the volume.UID, as with the PathFinding I suggested, you should be able to pick the volume with the same "NPC is overlapping Volume" condition in the end of event 62.

  • Link to .capx file :

    https://www.dropbox.com/s/6b0lqvb8zb6cejh/bugPathFinder.capx

    Steps to reproduce:

    1. create a sprite with pathfinding

    2. during execution, change sprite angle

    3. calculate path/move along path

    Observed result:

    The sprite angle is reinitialized to its spawning angle before moving.

    Expected result:

    The sprite should start moving using its current angle.

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer: yes

    Operating system & service pack:

    Windows 7 SP1

    Construct 2 version:

    r136

    ------

    Some personal observations after research in the behavior code, the problem is that the a variable (the angle of the object, store into the behavior) is set on creation of object, and then used in the tick function when isMoving is set to true (starting moving), if the rotation is allowed of course.

    But the behavior never calls runtime.add_bbox_changed_callback, never updating its inner angle (a), making it believe it never rotated, even if the sprite (or any over draw-able object in fact) called setAngle

    Hope this helps.

  • xoros

    Invisible sprite is a nice way too, you are right. More C2 friendly. A little less CPU friendly maybe, as the arrays in V8 are really fast.

    Though, the invisible sprite is a lot easier to manipulate, to rotate for multiple shape test for example.

    If, like you suggest, you create a "test Sprite" for each shape you want to test, and move it/rotate it everywhere possible within the flood generated shape, and test if the test shape is included in the flood shape at every step, you should be good too.

    Only difficulties are :

    • testing ALL possibilities. You'll have to use the basic tile size to minimize the possibilities.
    • testing if all of the testing shape is included in a minimum of events, because this test can be done a lot of times in a row...

    For simple shapes, other algorithm can be used, maybe more CPU friendly, but I don't see another method for testing any imaginable shape you want to create.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Darklinki

    Sorry, I tried to post screenshots from dropbox in an unusual way, they didn't make it ^^

    Here is the project, it's just my first real test on C2, no value, it can be easier to understand.

    Screenshot

    Capx

    Thanks a lot for taking a look !

  • Well, first of all, let's try not to test all the grid all the time. If your gameplay is based on switching 2 tiles (like most match 3 are), you should "just" test those 2 for shapes. In 2 steps then, first detect all the same color tiles, then detect if the current group makes a shape.

    1/ detect all the same tiles, it depends how you store your grid. I'll suppose you have an 3 dimensional array for it (X,Y for the grid, Z for the tile type/color). Best way to detect every tile would then be a recursive function, selecting currentTile, flaging it with a Boolean (so it's not re-analysed), and comparing its color to the 4 adjacent tiles. Run the function on every detected tile then, and collect an array of (tileX,tileY) during this function.

    You should then have something like this (let's say we detect a L shape) :

    [(5,5),(6,5),(5,4),(5,3)]

    2/ detecting the shape from the tile array returned

    First of all, find Xmin and Ymin in the array, and then substract it to every couple, so you have something like this for the current example :

    [(0,2),(1,2),(0,1),(0,0)]

    Next thing is a function that tests if a matrix contains an certain shape. A shape is described by another matrix, just like the previous one. The test is done by comparing if every couple of the shape is also set in the matrix to test. If the matrix to test is bigger than the shape matrix, you will have to test it multiple times with all the offsets possibles so all the matrix is tested.

    Don't go rotate the matrix or anything to test all the possible L orientations, just call again this test function with other shapes representing the L shape in multiple orientations.

    Repeat the 2/ with all the shapes you want to test, and you should be done.

    This seems really... heavy to code in C2. I personally would use a plugin for this if I did it.

  • NECROKRIEG

    You didn't understand the goal of clamp. clampx(val,min,max) is a function that will return :

    val if min<val<mx

    min if val < min,

    max if val > max

    By changing like you did, you set the minimum progress to 0.5, so the movement was half done from the start.

    I modified your last capx to include a textbox for you to change the speed on the go, and see how it works. On my computer, you could clearly see the difference between 0.1 and 10 for example.

    Capx

  • You have to understand how the lerp works here.

    lerp(a,b,x)

    0 <= x <= 1

    returns the point between a and b, proportionally to x. So you have to play on x and how fast it goes up to 1, to change the speed.

    Let's say you have a global variable called "speed", being a float between 0 and Infinite, Infinite being max speed, 0 being not movable. The total animation will have a duration of 1/speed seconds.

    In your last .capx, just change the line where you set progress to clamp(progress + dt, 0, 1) to clamp(progress + dt*speed, 0, 1)

    You will then keep the frame independancy, and will be able to set the speed as you like.

  • Very good work on this !

    I had hard time to really take a grip over the bird physics though, but once it's done, it's fun !

    Just one thing, very good idea to do a tutorial like this, but maybe it should cover the full extend of the gameplay ? Not just grab the first 3 triangles, but also drop them in their respective nest ?

  • This computer specs : Windows 7 SP1 64bits, 4Go RAM, dualcore AMD 1.8GHz, Graphics : AMD Radeon HD 6380G (low config)

    Without clicking anywhere : 60FPS

    Drops to 40 FPS at first destruction. Next clicks let me in the range of 50 to 60FPS.

    Spamming click drops down to 30FPS

  • Just to be precise, don't think of functions in C2 as "defined functions". It's more of an event called. You can have multiple "On function **** events, they will all trigger when you call the function. Functions are not defined, don't think of it as in JS for example.

  • Hey CrudeMik !

    So what you need is a white tilde background, positioned and sized over the area you want to invert.

    Add the effects "overlay" and "inverse" to it, and here you go.

    Here is a sample capx demonstrating it. The overlay has drag&drop to test it out.

  • To make it faster requires to optimize the forEach loop mostly. In this loop, we are looking for the point that has :

    • exactly 1 neighbor
    • isn't plot already
    • has minimum weight

    The problem is that every time the loop is done, neighbor count is recalculated for every (X,Y). I tried to add a 3rd Z layer on the Array, storing the number of neighbor for every point, and maintaining it every time we plot one more time (so only in the plot function). This let me remove completely the greedy calculation of the local "neighbors", that was removed too.

    Last optimization, changing the organisation of the ForEach Loop to check the conditions in a special order :

    • first, neighbor count, as the set of cells with only 1 neighbor is finite and minimal in the maze
    • second, applying the "not constructed" condition"
    • last, the most greedy, the "minimum weight" check

    It works consistantly on a bigger maze, I didn't try to go higher than 100x100 though

    capx

  • hi,

    you have the same tools for windows or web at http://www.bfxr.net/

    I use this for all sfx in my game, it's very good.

    Thanks a lot anata ! Great link !

    I'm not very good at it though, I can try to make something, but it's likely to be garbage ^^

  • Well...

    I liked that subject...

    I made a key mapper with C2...

    Please send a screenshot when you've set all the keys, if the gamepad is detected by the the browser.

    It's quite self explaining otherwise, input in center of joystick is by clicking on the joystick. X and Y Axis of the joysticks are "hit" when the joystick hits 100% bottom or right respectively (left and up are not to check).

    capx

    Screenshot