Itenimum1's Forum Posts

  • I want to have objects go to other objectBs after detecting that objectA is a certain distance or length away.

    Prior to that I want it to find the closest one, which I can always do by looping through each and then storing its distance in a variable and testing it each loop to see if it is lower or equal to this distance.

    But what is the best or better ways of doing this in programming?

    For objectFinder.IsCheckingForTarget

    for objectAs

    if objectA distance to objectFinder < objectFinder.maxDistCheck

    Set objectFinder.UIDOfTarget to objectA.UID

    Set objectFinder.DistanceToMyTarget to dist(self.X, self.Y, objectA.X, objectA.Y)

    Set objectFinder.maxDistCheck to objectFinder.DistanceToMyTarget

    yea and each tick I could have a const store its max distance and reset it when certain conditions are met, such as meeting with its target ((objectFinder.IsOnTarget))

    but thats not the problem

    the problem is I want a new condition to see that if the distance of this nearest one is over another set distance, find something else before it and go to it. I'm guessing i'll end up using my own system of state machines to manage this, how would you approach it?

  • I finished a long list of trial and error making a loop system for (tons) of instances, but now Im trying to figure it out, is the best way to compare (performance wise) by "compare variable" on an instance rather than pick by comparison?

    Because Ive noticed by comparison adds like 40% more CPU usage. (very bad).

    But picking by "compare variable" (built into object) does not.

    Any other methods to pick if its compared to a passed function parameter?

  • ah yes thankfully cc is free to download so I can examine it

  • How would building a plugin using events work exactly? Do you get to export a special field or event after creation or is it basically a plugin-event editor with built in blocks that has functionality of code from the SDK built in, or how? Did Construct classic allow this? Or perhaps other game engine tools? I'm just wondering.

  • I never go above 500. But I make optimizations where I can and very stupid prototypes which dont encompass things like :

    UI

    Saving and Loading manager

    Local storage management (not doing alot of this yet)

  • You do not have permission to view this post

  • > For Each loop, or manually sorting through a counter

    >

    > but

    >

    > You can do this:

    >

    > Every 1 second>>>

    > Enemyslime coinflip == 0>>

    > set Enemyslime.Coinflip = random(1, 3)

    >

    > Enemyslime.coinflip == 1>>>

    > set toggle to <left>

    >

    > Enemyslime.coinflip == 2>>>

    > set toggle to <right>

    >

    > see if this starts choosing them better.

    >

    I see! I'll try when I get back, but do I need to put "round" in front of the random(1,3) so it doesn't choose decimals?

    yeah I forgot, floor(random())

  • Ok I'll give it a shot.

    That must have been it, the order I tested the '=' since i just removed the else and it worked. Maybe i was accidentally doing something else to it since I just disabled a group of events... weird.

    Thanks.

  • For Each loop, or manually sorting through a counter

    but

    You can do this:

    Every 1 second>>>

    Enemyslime coinflip == 0>>

    set Enemyslime.Coinflip = random(1, 3)

    Enemyslime.coinflip == 1>>>

    set toggle to <left>

    Enemyslime.coinflip == 2>>>

    set toggle to <right>

    see if this starts choosing them better.

  • Well I know of one way, is to

    On Mouse is down event>>

    create your sprite at mouse.X/Mouse.Y or Mouse.X(0)/Mouse.Y(0)

    But, for a game LIKE the one you mentioned, you'd have to learn trigonometry or some kind of middle ground of hitting certain button combos and checking length and distance and size of a sprite to manipulate it like a rope and freeze its position. I'm totally unsure. I know there are some rope examples available that deal with free form shapes. You could perhaps try spawning shapes a certain size and length while mouse button is down and when on first mouse button is clicked set shape and length to initial change dir x of mouse and then width to a default size and for change in mouse X and Y since movement calculate shift and shift in change to make the newly spawned sprites take a length or shape of a more square or rectangle depending on the change in shift x and Y.

    Something:

    On Mouse button is down>>>
    begin a .. loop? hmmm dont know, a function that continously loops and compares the x and Y current?
    
    Ok first make 2 variables (globals, or locals) named CurX and CurY) and a MouseTracker object and set it to always folow your mouse.X and Y or Mouse.X(0) and Mouse.Y(0) which I find most reliable.. usually)
    Every tick>>>
    CurX: Mouse.X
    CurY: Mouse.Y
    
    Every tick >>>
    set  MouseTracker position: MouseTracker.X to Mouse.X, MouseTracker.Y to Mouse.Y
    
    Every tick >>>
    Set MouseTracker.MouseXVar to Current Mouse.X
    Set MouseTracker.MouseYVar to Current Mouse.Y
    
    Every tick>>> (all events below go off MouseTracker object vars)
    CurX!= MouseXVar >>
    CurY!= MouseYVar >>
    set CurX to MouseXvar
    set CurY to MouseYvar 
    
    Every 1 second >>>
    Set LastMouseX to Mouse.X
    Set LastMouseY to Mouse.Y 
    
    Every 2 second>>> (all events below go off MouseTracker object vars)
    MouseXvar != LastMouseX>>
    MouseYvar  != LastMouseY>>
    set LastMouseX to MouseXvar
    set LastMouseY to MouseYvar 
    
    On Mouse button is down>>>
    every tick >>>>
    
    //(applied to some variable or mouse tracker.. which could be constantly setting itself to the mouse itself) 
    begin function funcMouseDraw(param0: MouseXVar, param1: MouseYVar, param2: LastMouseX, param3: LastMouseY)
    
    Localvars for function:
    Localfunc1:
    Localfunc2:
    Localfunclast1:
    Localfunclast2:
    
    (dont quote me on this, you may not want to store the variable locally as it may not update, make them static as it seems to help witht his, otherwise dont bother as you can just test the functions params.)
    On function funcMouseDraw>>>
    set Localfunc1 to funcMouseDraw.param0()
    set Localfunc2: to funcMouseDraw.param1()
    set Localfunclast1 to funcMouseDraw.param2()
    set Localfunclast2: to funcMouseDraw.param3()
    1st level SubEvent--->>
    MouseTracker.CurX == Localfunclast1 >>
    &&
    MouseTracker.CurY == Localfunclast2 >>
    &&
    Not overlapping an objectSpriteDraw
    create objectSpriteDraw
    set objectSpriteDraw width to: <some default shape value here>
    set objectSpriteDraw height to: <some default shape value here.. for your default draw shape, using whatever the sprite is>
    
    else
    
    MouseTracker.CurX(or localfunc1) == Localfunclast1 >>
    &&
    MouseTracker.CurY(or localfunc2) == Localfunclast2 >>
    &&
    Is overlapping an objectSpriteDraw
    <Do nothing>
    
    else 
    
    MouseTracker.CurX == Localfunclast1 >>
    &&
    MouseTracker.CurY != Localfunclast2 >>
    &&
    Not overlapping an objectSpriteDraw
    create objectSpriteDraw
    set objectSpriteDraw width to: <some default shape value here>
    set objectSpriteDraw height to: <default shape + or - the change in Y using localfunclast2>
    
    [/code:17pm0o41]
    Anyway, this is a rough idea on how to approach this
    
    -- See, it doesnt help that Construct 2 has no access to the graphic renderer. So we cant draw simple sprites (like real ones) We have a sprite object class which has parameters we pass and is an object.
  • I fixed this is two ways just now and they only slightly confuse the crap out of me: (note: both ways include conditional else statements, where before I had no conditional else)

    First way:

    Pick searcher by  UID of searcher>>>
    Check state>>
    Inverted/Not Target varCondition != CorrectCondition>>> (so not not equals.. which means it does equals? I assume)
    Pick nearest to (searcher.X, searcher.Y)>>>>
    <do stuff>
    Else>>>
    Pick searcher by UID of searcher>>>
    Check state>>
    Target varCondition != CorrectCondition>>>
    Pick furthest to (searcher.X, searcher.Y)>>>
    <do same code above>
    [/code:1mbjwe91]
    
    yes somehow this worked
    this one below makes more sense sort of.
    
    Second way:
    [code:1mbjwe91]
    Pick searcher by  UID of searcher>>>
    Check state>>
    Target varCondition == CorrectCondition>>>
    Pick nearest to (searcher.X, searcher.Y)>>>>
    <do stuff>
    Else>>>
    Pick searcher by UID of searcher>>>
    Check state>>
    Target varCondition != CorrectCondition>>>
    <nothing>
    [/code:1mbjwe91]
    
    Of course, placing the "pick furthest" on the else conditional of this one breaks everything so I had to disable it and make it do no action. Which is also what I want.
    Right now though, I'd be more interested in knowing:
    
    A. Why this does nothing or not work the way I want if there is no ELSE, (makes sense code/programming wise of course, but I'm not coding with a scripted language so understanding event list editors is very confusing sometimes as to what can be accepted and what cannot.)
    
    B. with A, why does this not work if I just have one check at the top with If Target == CorrectCondition and just stop at finding the nearest. I assume it will stop at the nearest and check to see if it is correct, and then cease all further searches with things not nearer than that. Which I assume forces you to use the else condition to searcher either farther, or know that the thing you found is not equal to the condition so try the search again?? This is strange concerning the way I have it set up visually and seeing that it does work this way is confusing me somewhat. As in above it (second way) it is showing me looking for something that meets the condition, and then searching nearest to it. When I disable that objects condition intentionally and expect them to stop, they will, but if I spawn other objects meeting the condition farther away from it they will pause and not go farther unless I spawn something closer that does meet the condition,
    
    then I just added a else, and for some reason it works? (especially concerning the second way, where it chooses you if you are not equal and then literally does nothing and knows to choose things farther away) My only reasoning is that, it has picked the object previously that was not meeting the CorrectCondition and knew to disregard it somehow with the previous loop when it looped back over this statement. I have no idea.
  • Right now I want something to find something nearest to it, the UID for this object is stored, so its picked already, however, I don't want it to find the nearest of something that doesnt have meet a certain condition.

    How do you usually do this inside of construct 2, I tried using For Each loops but it kept choosing the farthest object or last one made and no longer sorted through them accurately in real time.

  • not sure how to go about typing this:

    (GlobalNumberN - CountIDLimitMax) > 0 ? (GlobalNumberN + CountIDLimitMax) > CountIDLimitMax ? CountIDLimitMax + GlobalNumberN[/code:2e86wj3m]
    
    giving me some error about expecting a " : " for comparison or something. I had made a Min and Max value but I wanted to see if I could do it without having to declare a Min variable (which is easy and works).
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In case of someone who is keeping track of this, I combined R0J0hound's method of handling this with my other previously used method of cycling through only a certain number range of instances at a time which keeps the events within afew lines and yet is dynamic enough to be modular. Very nice stuff. (well, appending items needing to do tasks to lists is useful asweell. will experiment further)

    Edit 1:

    Still seems to be some terrible issues with resource management (on instances 1000+, around 400+ it seems OK.) , FPS, and unit count. I'm not sure but it still might require dedicated scoped loops (separate ones) due to the way its either

    1. Being executed

    2. used

    3. built in limitation or issue I cant see.

    oh well I'll keep experimenting with it. Kind of a bummer. Pretty sure itsbecause of the repeat event per tick. I wonder if there is a way to perhaps change the repeat event iteration to every other tick or something? so as not to bog down the processing of tons of units each and every tick?

  • Oh yea, that will loop through 100 times each tick? Will def check it out thanks, basically I'm trying to make the least lagiest for each loops for large amounts of sprite objects who will be given functionality through another function which will do whatever but do it in large volumes. Mostly for stress test purposes. I only use construct 2 to prototype ideas tbh and light game experiments. I was noticing there is a bottleneck everytime I try doing something like this so I had to manually create what you just did in multiple function loops only iterating through scoped object chunks of 1-200, 201-400, etc, etc. Which works great but is made simpler with other functions I discovered (something similar to yours but without nth picking.) I'll give your thing a shot and report back as I require rest now thanks alot