R0J0hound's Forum Posts

  • This is how you’d use that or operator in an expression:

     System: pick MapInOutCheck by comparison: (MapInOutCheck.TypeChecked = "ULDR" | MapInOutCheck.TypeChecked = "LDR" | MapInOutCheck.TypeChecked = "UDR" | MapInOutCheck.TypeChecked = "ULR" | MapInOutCheck.TypeChecked = "DR" | MapInOutCheck.TypeChecked = "UR" | MapInOutCheck.TypeChecked = "LR" | MapInOutCheck.TypeChecked = "R" | MapInOutCheck.TypeChecked = "" )
    = 1

    But for something like that I’d utilize the find expression. The list of values are comma separated with commas before and after, and we surround the variable value by commas and find it in the list.

    System: pick MapInOutCheck by comparison: find(“,ULDR,LDR,UDR,ULR,DR,UR,LR,R,,”, “,”& MapInOutCheck.TypeChecked&”,”)>-1
  • Description

    I have been intrigued by a technique for drawing text from a texture using SDFs (signed distance fields). Typically text in construct is drawn to a 2d canvas then moved to a texture which is drawn. Any time the text or font is changed the texture gets updated. SDF text is more like spritefonts. You have one texture atlas and letters are just drawn with quads. SDFs differ slightly from spritefonts in that they can be resized and still have crisp edges.

    Test

    Here is the initial test. I used a tiledBg as the texture atlas, and to draw individual letters, and I used the alpha threshold effect to treat it like an SDF. It compares the text object to sdf text to basically a spritefont text.

    dropbox.com/s/j8hvj98c0nsd0fo/sdf_font.c3p

    The sdf could look better with some antialiasing but that would require a new effect.

    Tools used to make test

    I used this tool to generate the texture atlas and json of the letter metrics.

    evanw.github.io/font-texture-generator

    I also made a small tool to modify the texture to work with the alpha threshold effect.

    dropbox.com/s/2hz7crpwwncr1ny/bw2alpha.c3p

    Multiline text and scrolling test

    I added word and character wrapping to limit the text to an area. I also added basic vertical scrolling. Characters aren't drawn outside of the area and are clipped when halfway in it.

    dropbox.com/s/67ukw6bak4gvq41/no_dom_text_scroll.c3p

    It works but it gets slower the further it scrolls down since it has to process all the text up to that point. I may research how that's usually done. One idea is to process the word wrapping once and add all the newlines in. Then it would be simpler to access particular lines so the scrolling would take the same amount of time regardless. There are some other issues that have come up that I'll work on later.

    Summery

    This is mostly for me to learn about how to do text rendering from scratch. I find it fun that it's possible to do with basically just a texture and a bunch of quads.

    -cheers

  • I seem to recall that type of inventory being made before a few times.

    Here's one idea I just made.

    dropbox.com/s/rwuhpdoblzx3joo/inventory_idea.capx

    Here's an older one with odd shapes.

    dropbox.com/s/tpwx74fq1c43auc/Fit_shapes_into_slots.capx

  • I think most engines that support multiple exports are designed around that from the start. Construct is designed around browser tech so all its exports either are bundled with a browser or use the browser included with the platform. Since making their own browser isn’t feasible their only option is to hope sufficiently feature full browsers become available on all platforms.

    What construct’s exports do do is still helpful. They bundle your game up into one place.

    Porting houses take different approaches. They mostly convert events to c++ equivalents, but when the events rely on browser features it’s probably something they have to often manually address. I do recall one porting house does have their own tool to convert JavaScript to c++, but again they have to handle any access to browser features case by case. I’d guess they are able to port maybe 90% of the game automatically and over time they may accumulate more reusable solutions to the rest.

    After that they help with some optimizing for the given platforms. They also deal with the console companies as a middle man. Companies such as Nintendo require you to sign an NDA to even get a hold of an Sdk to even develop for their platform. There’s probably some per console tweaks that are needed for various reasons. There’s probably a lot more to it than meets the eye. Also the porting houses will be lagged behind any new versions of construct so that’s a fair amount to keep up with.

    Overall I’d say Scirra already has its plate full with all its current endeavors. The porting houses already port games in general and are familiar with most export platforms. Scirra would have more risk involved as it would take a lot of time to get up to speed and maintain comparability with the different platforms to do the ports in a similar manner.

  • That would work. Kind of what I was thinking. The only thing is mouse sensitivity makes no sense when clicking. At least to me. I’d expect where I clicked to be where I clicked.

    What behavior is the op trying to go for? He didn’t explain much.

    Sensitivity could work for click swipes.

    Global number px=0
    Global number py=0
    On left click
    — set px to mouse.x
    — set py to mouse.y
    Left mouse down
    — sprite: set x to self.x+(mouse.x-px)*1.1
    — sprite: set y to self.y+(mouse.y-py)*1.1
    — set px to mouse.x
    — set py to mouse.y

    I guess you could take that idea with mouse lock too.

  • Oh nice. I forgot about that one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don’t think I’ve made a complete example of that.

    Using the physics behavior with the path finding behavior kind of solves that. But it can be janky because the two behaviors fight with how the objects move. It’s slightly improved by setting the physics velocities to 0 every frame, but the behaviors are still at odds.

    To remove the fight you’d ideally just use the physics behavior to move, and not use the pathfinder for movement, although you would use it for finding the path. Basically you’d set the velocity to velocity+(targetVelocity-velocity)/10. Where target velocity is the velocity you’d want to go toward the next waypoint on the path. The /10 is to make it smoother, but isn’t frame rate independent as is. Then you’d just need to check if a waypoint was hit or no so it would move on the the next waypoint.

    The main issues here are not being able to reach a waypoint so it could cause things to get stuck.

    There is also a technique called steering behaviors (not actual C3 behaviors) or boids that I think could be useful here. The math above is basically steering, it changes the velocity till it’s facing a certain direction and velocity. Basically you’d find the paths, or since it’s many objects to one spot you could use dijkstra's algorithm to get kind of a flow field. Then you’d steer the enemies to move along the path, away from each other and walls, and in the average direction the enemies around them are going. A last step would be the physics to keep things from overlapping as a last ditch effort. Lighter than the physics behavior is one technique called verlet physics which has the benefit of inferring velocity from the previous position which could be useful here.

    To handle a high volume of objects using some kind of grid spacial partitioning would reduce the number of collision checks.

    In theory the enemy’s would the flow around the terrain while not overlapping each other.

    Anyways that’s just few rough ideas. Might attempt it later and see how much simpler an actual example would be.

  • Glad it was useful.

  • Here are two older ideas. I’m pretty sure they used a box as the collision shape but I think it could be updated to clip any collision shape by the water.

    construct.net/en/forum/construct-3/how-do-i-8/floating-physics-140019

  • One idea to avoid the trees being clumped too much is to use a single nextSpawn timer for all of them. That would let you specify the min time between trees. You’d just have to rearrange things so a random tree sprite is created.

    The other idea to only allow trees to be places so that it is actually possible to jump over is much harder. A rough idea would be to simulate the path of the player jumping and see if it can clear the trees and land. Might be able to simplify that with a calc of how far before a tree you have to jump and where you’d land after, then combine them somehow. Probably would need to add some tolerances to allow for reaction time and variance from the engine. Anyways could be a rabbit hole of ideas to try.

  • Is it just a straight line between A and B?

    If so you can limit another objects position between them with:

    T=clamp(((b.x-a.x)*(sprite.x-a.x)+ (b.y-a.y)*(sprite.y-a.y))/((b.x-a.x)^2+ (b.y-a.y)^2),0,1)

    X=lerp(a.x,b.x,t)

    Y=lerp(a.y,b.y,t)

    That formula is a vector projection.

    If the path isn’t straight then you’ll have a series of lines. For that you’ll need to incrementally find what line segment to limit the sprite’s position to.

  • Here’s one way. You can change the camera code but it relies on the forward vector which is only set by the look at action.

    One touch changes the camera and a second touch tosses a tomato.

    dropbox.com/s/cd5gad46nqx49sd/Tomato_toss.c3p.zip

  • I mean there aren’t that many 3d features available in construct so trying to do anything beyond the obvious features will be more involved if possible at all.

    For example even throwing a tomato in 3d becomes an involved multi part problem. Construct doesn’t really provide anything that would make it easier.

    1. The tomato would need to be a sprite or a mesh. If a sprite you’d probably want to use a distort mesh so that you can have the sprite always face the camera. But only if the camera is set with the look at action. The camera rotate action makes it harder. Then if 3d there’s the problem of the limited number of 3d shapes. For that you’d either need a third party 3d plug-in, or do some trickery with distort meshes.

    2. To move the tomato we’d need to do the physics from scratch. None of the behaviors will help here.

    Off the top of my head the motion and basic ground plane collision detection would be this:

    Every tick
    — add gravity*dt to vz
    — set x to self.x+vx*dt
    — set y to self.y+vy*dt
    — set z to self.z+vz*dt
    
    Z<0
    — destroy

    To launch you’d set the starting z position, then set the velocity (vx,vy,vz) to the camera’s forward vector times some speed.

    Anyways as you can see there is math involved. And the names of things are different in construct. Like zelevation instead of z. Plus you’ll want to set the project z scale from normalized to regular.

    I know an example would be ideal but I feel like I’m re figuring out how to do it every time. As is it’s hard to just drop an answer without an example and have it be clear how to implement that into construct.

  • If you add a variable t to the pillar then you could do something like this:

    On bullet collides with pillar
    — pillar: set t to 0.5
    
    Pillar: t<=0
    — pillar: set y to self.y-50*dt
    
    Pillar: t>0
    — pillar: subtract dt from t
    — pillar: set y to self.y+75*dt

    With that it will go up at 50 pixels per second. Once it gets hit it will go down at 75pixels per second for 0.5 seconds. You can change all the values.