R0J0hound's Recent Forum Activity

  • Snapping can be done by converting the xy positions to isometric, snapping that and converting it back to xy.

    Xy to iso:

    ix=y+x/2

    iy=y-x/2

    ISO to xy:

    X=ix-iy

    Y=(ix+iy)/2

    You can modify those slightly to align the grid from somewhere different than (0,0) to say (cx,cy):

    Xy to iso:

    ix=y-cy+(x-cx)/2

    iy=y-cy-(x-cx)/2

    ISO to xy:

    X=ix-iy+cx

    Y=(ix+iy)/2+cy

    And finally the snapping formula:

    Int(X/grid)*grid

    Combined snapping to an isometric grid would look like this:

    set x to sprite.x-corner.x
    Set y to sprite.y-corner.y
    Set ix to int((y+x/2)/grid)*grid
    Set iy to int((y-x/2)/grid)*grid
    Set x to ix-iy+corner.x
    Set y to (ix+iy)/2+corner.y

    After snapping you only need to check grid positions to see if an object is there. Whether that be picking objects at an xy or the closest to an xy that’s a small distance away. You could also check if an object is overlapping a point if you setup the collision polygon to only overlap the base of the object. You could also use an array to store the object’s snapped isometric coordinates *grid. But you’d need to select a corner so that those values aren’t negative.

    The simplest is probably just setting the object’s collision polygon to just cover the base, then put all your isometric objects in a family. Then you’d know if a space was occupied with a condition like:

    System: family overlaps point x,y

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Should be simple as:

    compare Anglediff(Angle(player.x,player.y,enemy.x,enemy.y)-player.angle, 0)<90
    — shoot from right cannon
    Else
    — shoot from left

    Or some variation of that.

  • It’s a dom element, so you can use any css you want to style it, including rotate it.

    w3schools.com/Cssref/css_pr_rotate.php

    Dom elements have a set css action you can use to do that.

  • Looking cool!

    If you end up delving into layouting, aka automatically positioning and resizing elements, I recently found this video that makes it sound fairly straightforward:

    youtube.com/watch

    Also currently your plugin builds and modifies you gui, which is basically a retained mode gui. Another approach is an immediate mode gui that builds the gui on the fly per frame, which has some interesting pros and cons.

    As for the programmer art colors, I do that too, but I've recently been toying with the idea of using a palette generator to get some pleasing colors to go together. I've also seen sites that provide nice palettes specifically for uis. Anyways, just some ideas that could give some inspiration.

  • I generally just derive the formula from scratch if it’s not working. But looks like you extracted the left of the decimal, added your own decimal then did some math on the left that resulted in another decimal.

    Maybe it’s a misunderstanding on what zeropad does.

    Zeropad(1, 3) = “001”

    Zeropad(12,3) = “011”

    Zeropad(123,3) = “123”

    As to the last method. I probably should have used another variable name besides k. Anyways, you just need to change var and it should spit out for example:

    12 -> 12

    1234 -> 1.234k

    123456 -> 123.456k

    12345678 -> 12.345m

    1234567890 -> 1.234b

  • You probably meant something like:

    int(var/10^12)&”.”&zeropad(int(var/10^9)%1000, 3)&”T”

    But you could also do the same thing with:

    int(Var/10^9)/1000&”T”

    You could also do it like this to handle thousands,millions,billions,trillions,etc all at once:

    K= min(4, int(log10(var)/3))

    int(var/10^(3*k-3))/1000&tokenat(“,k,m,b,t”, k,”,”)

    If you have more suffixes you’d add them to the token at portion. I just used 4 suffixes, hence the 4 in the min().

  • If you ran your game logic at a fixed rate you could do that.

    One way to do that is to accumulate dt and once it’s big enough do the logic for a frame. So say try to run at 30fps:

    var t=0
    Every tick
    — add dt to t
    While 
    t>=1/30
    — subtract 1/30 from t
    — do all game logic for a frame here

    We are still limited by the screen’s refresh rate so even though the game is running at a fixed rate the frames will have to snap to the closest actual frame. The above is a simple example but may need some tweaking to ensure the frames are evenly spaced otherwise it looks janky. As a side effect of that, the jank can be much worse depending on the refresh rate.

    One possible tweak could be to compare t<1/30-0.1 or something to smooth out the variances of frame times. But that magic number kinda relates to what the actual refresh rate is. Another idea could be to skip frames evenly and just allow the game to run slower or faster, but results may vary. Part of the issue with improved tweaking you’d need to know the actual screen refresh rate, but that can only be found experimentally and approximately.

    To avoid the jank you could also keep track of the all the state of the objects on the current and previous frames and interpolate between them to give smooth motion. But realistically you’d need to simulate a frame in advance so you’d have a one frame of input delay. And I’m talking a frame at the fixed timestep. Plus doing this is rather laborious to do with a lot of objects.

    Anyways, the main drawback to this is having to implement all logic under that event. You wouldn’t be able to utilize behaviors, and likely not be able to use input triggers. Basically you’d not be able to use all construct features when doing this.

    However, that would allow you to save replays just as inputs that you could playback.

  • Just to be clear, what’s failing is the array load action fails to load your json since it’s wrong somehow?

    Have you looked at the browser console to see if the reason for not loading was logged?

    I hate guessing why something silently fails as much as the next guy. So assuming it’s the json generated from your excel file that’s not a proper array json you can make a checker to narrow it down.

  • The sdk docs about effects mention most of the builtin uniforms. But

    Uniform mediump float opacity;

    Used to be a thing in c2. But it might be gone now

  • Well there’s nothing amiss with that json data as you typed it.

    I pasted them into a text file. Called it example.json, imported it into the files folder in the project, then used Ajax to load the file, loaded it into an array, then set some text from the asJson to see if it all worked. Which it did with my test with r458.2.

    + System: On start of layout
    -> AJAX: Request example.json (tag "")
    -> System: Wait for previous actions to complete
    -> Array: Load from JSON string AJAX.LastData
    -> TextInput: Set text to Array.AsJSON
  • An object type per card vs one object with a bunch of frames is more about being able to do things in less events. It’s personal preference really, if you already have 100 objects and you’re fine with writing logic with that then carry on.

    Storage wise what do you mean? The overhead of one object vs many is likely negligible. Memory wise you still end up with the same amount of images and vram usage either way.

  • Looking cool!

    If you approximate the rounded window with a polygon you can do polygon clipping with an algorithm like:

    en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm

    But I’m certain you could do something simpler than that by utilizing the sdf equation of a rounded rectangle so you don’t have to loop over so many edges.

    Or maybe you could try clipping by a rectangle like you already do and then use a blend mode to draw that within the rounded window. Or maybe drawing to a texture and then drawing that within the rounded window shape. But those kinda depend on what you have access to with construct’s renderer.