R0J0hound's Forum Posts

  • If it freezes it’s a logic error somewhere in your loop events where they never end so it becomes an infinite loop.

    To debug where the error is I usually write it a bit at a time and make sure it works for the simpler stuff before adding more to it. That way it’s easier to track when you introduce the error.

    Another idea is to try to use the debugger to step through the events. Although I haven’t really used it and I’m not sure how detailed it’s able to step through your events.

    You could also use “repeat” or “for” instead of “while” for your loops. With those a logic error would just not work instead of freezing. Also tweaking your logic to use those loop conditions instead may help fix the logic anyways.

    Once you get it not to freeze you could log values to the console or editbox as your events run. And that could be a tool to see what is happening and maybe help you spot where to look for the error.

    Just reading the events and running them in your mind sometimes works too. But breaking things down to simpler steps helps more.

    Anyways, those are some strategies I use.

    I used to be better at debugging others code but lack the time and patience lately.

    What you’re running into with using all those while loops is there are many more places for the code to fail so it’s too tall an order to debug from a screenshot. A minimal example to download is better for other users to fiddle with if they get the urge to give debugging a go.

    There could be some action or condition that’s not working as you expected. For that I often find it useful to do small tests with them to better understand what they are doing.

  • He means the programming language scratch where all coding is done with blocks that that can be dragged and snapped together kind of like legos.

    en.m.wikipedia.org/wiki/Scratch_(programming_language)

    Or maybe blocky which is basically the same. But it’s not clear how that library could be cobbled into construct.

    en.m.wikipedia.org/wiki/Blockly

    Anyways like anything the trick to doing it is to break it down into simpler doable steps.

    Start by having blocks you can drag and drop. Next have locations that the blocks will snap to when close enough. Next is to keep track of how everything is connected, and where to insert stuff and moving stuff to make everything fit. You could either just highlight the drop points or preview the resulting layout as you drag, but that’s objectively more involved.

    Probably best to try something simpler first. Like just a vertical list of sprites you can drag to reorder.

    Another exercise could be to just work on the visuals on how everything should be positioned. Like positioning everything via events.

    Anyways good luck.

  • Do you want the small tilemaps merged into a third tilemap just big enough to combine the two? Or do you want to just draw them onto the main tilemap that covers the layout?

    What is the array you mention for? Tilemaps can already be thought of an array of tiles so using an array too seems redundant and overcomplicate things.

  • You’ll have to show a screenshot of the events. If it’s freezing it’s an infinite loop. For a while loop to end you either need a condition in the same event block as the while, or you need to use “stop loop” somewhere elsewhere in the sub-events. Lastly you need to ensure your logic avoids infinite loops. Often a for loop is easier to do right.

  • Just to clarify you want to detect collisions between instances that have a variable=1 and other instances with variables<>1?

    Easiest way to reference another instance is to use a family with just that sprite type

    So say you have a Sprite added to a family called other, and you added the instance variables to the family you could do this:

     Other: variable<>1
    Sprite overlaps other
    Other: variable=1
    — sprite: set color to red

    The difficulty with this is you need to add the variables to the family. Which can be a bit laborious to change if you already have a bunch of instance variables and events using them.

    An alternate idea is to use dummy sprites that you create on the fly.

    every tick
    — dummy: destroy
    
    Sprite: variable =1
    — Sprite: spawn dummy
    
    Sprite: variable <> 1
    Sprite: overlaps dummy
    — sprite: set color to red

    With this method you may need to do more when you spawn the dummy. The idea is you want the dummy sprites to match the position,size,angle and shape of the source sprite.

    A third way could be to manually loop over each pair of instances. With it you’d get the iid of both instances, and you’d do expressions like sprite(i0).x to access values to compare. If you want to modify an instance you’d use the pick nth instance condition. The loop would look like this:

    For “i0” from 0 to sprite.count-2

    For “i1” from loopindex+1 to sprite.count-1

    Unfortunately the biggest disadvantage of this method is you can’t use the overlapping condition so you’d have to do your own collision detection. Which may or may not be complicated depending on the shapes.

    A final option would somehow use the js api to do it. But that is completely uninteresting to me.

  • If both tilemap are the same size and at the same position with the same tile size then you could loop over all the tiles on one and see if there is a tile on the other. If both tilemaps have a tile at the same position then stop the loop since they are colliding.

    If position, size or tile size differs between the two then it would just become more involved. Worst case you’d take each tile of one and compare the bounding boxes of each tile of the other. But there are likely lots of ways you can reduce the amount of checks needed. Even so, it will be slow with a lot of checks.

  • A few thoughts:

    * there are conditions to compare angles. I’d recommend using them instead of the “value is between values” condition because they handle how angles can wrap around from 360 to 0.

    Another way is to take the angle and calculate a variable for the quadrant number. 1 to 4.

    Quadrant = (round(angle(sprite1.x, sprite1.y, sprite2.x, sprite2.y)/90)+4)%4+1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here’s a few ideas:

    Speed up

    Speed = speed + acceleration*dt

    Slow down

    Speed = speed - deceleration*dt

    Also speed*0.5 is the same as lerp(speed, 0, 0.5)

    So supposedly the way to make that use dt is lerp(speed, 0, 1-0.5*dt) but you’d probably have to tweak the 0.5 value.

    So you’d utilize that idea whenever you’re using a scaled value of speed.

    That should mostly make things consistent. It will still vary a bit at different frame rates though. Sometimes you can throw more math at it in some cases to improve it. Easiest way to make completely deterministic physics is to run at a fixed frame rate but construct doesn’t provide a way to do that.

  • Yeah that condition just evaluates normal math expressions not an expression in a string.

    I think any non empty string besides “0” will be true.

    To evaluate an expression in a string you have some options:

    One way is to write a text parser to extract the operators and numbers and evaluate the expression. That would give you the most control over how it’s done.

    A second way is to use the browser objects execjs expression. It’s basically the eval function js has. It can’t reference variables though.

    Third option would be to find a plugin that evaluates text expressions. I’m sure someone made one before.

  • Simplest is just setting the collision polygon to the shape. In the image editor you can even right click and have it guess the a polygon from the image, but you may need to tweak it.

    The benefit of using a collision polygon is that interacts with the behaviors and collision events.

    The con is it’ll only be as smooth as you make it. So more points on the polygon. Then the smoothness is also reliant on the behaviors collision response, but I imagine it would be ok.

    You can roll you own collision detection and response and represent that shape more perfectly with a completely smooth ramp but it takes more math and some fiddling to setup. And the main con is behaviors won’t be able to interact with that. But it does give you more control over how it works.

  • Yeah that’s how I do it. I’m not sure how to do it otherwise.

  • Basically by not defined I mean having an else after a loop makes no sense to me. When does the else run? When the loop ends?

    Guess you’ll probably want to break it up into chunks to test and verify it’s doing what you are thinking it’s doing and then adjust accordingly.

  • Honestly best you can easily do is add the tint effect to a layer where the particles are. Gotta work within free limits.

    Another idea to explore is a layer with a colored background and the particles with blend modes. But that honestly probably won’t work the same.

    If the particles object lets you load an image at runtime you could use js to modify the pixels of an image and load that. But you’d need to make a plug-in or do something hacky with the browser execjs action to do that. More trouble than it’s worth maybe.

    You could make a plug-in but construct’s renderer doesn’t provide a way to tint a texture. In theory you could hack the renderer to run arbitrary shaders there. But that’s absolutely not worth the trouble. We just wanted to tint an image, not redesign the entire engine renderer.

    Anyways you could probably try the first two. This was meant to give ideas to attempt. They may not work out.

  • You’ve landed on a major limit with the 3d in construct. Collisions (including with the mouse) only happen in 2d on the z=0 plane.

    Seems it’s basically a problem of calculating if a ray from the camera to the mouse position is intersecting the sprite’s quad. Just a bunch of math since construct doesn’t have anything that helps with that. But you could try searching the forum for 3d ray cast for various possible solutions.

    If an object doesn’t have the spawn action just use the system->create action.

  • It’s the same.