R0J0hound's Recent Forum Activity

  • It’s probably a throwback to how arrays were separate objects in Clickteam products.

    Also it does help keep things tidy to have the array actions and conditions grouped together. At least with how types are handled currently.

    Construct classic actually had a way to assign arrays to variables, although they were pretty much constant. You couldn’t change the size or elements of it, and it wasn’t supported in all places. The feature didn’t make the jump to C2.

    I think it would nice be have as a variable type though. If it made the array object obsolete I wouldn’t mind, as soon as you do something moderately complex that involves picking you realize containers don’t really help a lot.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If the player is moved with the physics behavior too, then no, not with the bundled physics behavior since there is no collision filtering.

    There are other physics plugins such as chipmunk physics you can download and use instead. It for instance has a setting called collision mask for any object using the behavior.

    Set the player to 01

    The enemies to 10

    Any walls both hit to 11

    And walls only the player can walk through to 10

  • It should just bounce. You shouldn’t need to apply an impulse at all.

  • It probably can be simplified to:

    rotate clockwise by (mouse.x-self.x)*k

    Where k is to tune the rotation amount

  • The terrain is just a graph. For any x position you just need a way to calculate a y.

    A simple start would be y=sin(x)

    Or to center it vertically and make the hills bigger you can do y=240+100*sin(x)

    There are many ways to make the terrain more interesting than just a sine wave. You can use a noise plugin, or maybe add multiple sine waves together. Another idea is to just fill an array with random numbers and use cosp() to interpolate smoothly between the numbers.

    So basically a function like this:

    Function terrain(x)

    — i = int( x/100)

    — t = x/100 -i

    — return cosp(array.at(i),array.at(i+1),t)

    Then you can move the player around in any way you like, and you can know if it hit the ground if player.y > function.call(“terrain”, player.x)

    I don’t really want to fight with constructs collision system to somehow make it work with this, so instead you can do it manually. It’s also simple enough to do your own motion with a vx and vy variable.

    Every tick

    — add 200*dt to player.vy

    — add player.vx*dt to player.y

    — add player.vy*dt to player.y

    Set y0 to function.call(“terrain”, player.x)

    Set y1 to function call(“terrain”, player.x + 0.001)

    Set ang to angle(0,y0,0.001,y1)

    Player.y > terrain(player.x)

    — set player.y to y0

    — set dot to player.vx*cos(ang)+player.vy*sin(ang)

    — set player.vx to dot*cos(ang)

    — set player.vy to dot*sin(ang)

    So far so good. I guess I forgot to cover a way to draw the terrain. You could get away with only drawing what’s on screen.

    Destroy circle

    Repeat 100 times

    — create circle at (0,0)

    — set x to lerp(leftScreen, rightscreen, loopindex/99)

    — set y to function.call(“terrain”, self.x)

    You could also stretch rectangle sprites between the circles to give a continuous line.

    To fill the area below you could use all the circle locations along with the bottom two corners of the screen with a canvas fill function.

    The gradients would require reasoning about how you’d want it to look and maybe drawing an offset polygon or placing blurred scaled sprites at key spots.

    EDIT:

    working example.

    dropbox.com/s/q9vpfm2psqr4qfe/terrain_physics.capx

  • dop2000

    Ah, I hadn’t tested it, good to know. I guess in that case it would be a false positive if the imagepoint was actually the same as the origin.

  • That would have to be done inside the plugin, and that’s what save/load actually does. However, no, there’s nothing implemented on that front.

    You can use the canvas.asjson expression to get some json that can be loaded into the array object, but it’s not reversible.

  • I think you mean imagepoint? All objects have an origin and I didn’t think you could rename it.

    If you just access an imagepoint x or y with an expression and if it’s equal to 0 the will mean it doesn’t exist. Usually at least, if you have the sprite near the top left edges of the layout the imagepoint could have zero coordinates. In that case you’d want to move the sprite to a location far away first, then after your check move it back.

  • To mirror around the center of the screen:

    scrollx-(mouse.x-scrollx)

    I've also used

    640-mouse.x

    Where 640 is the screen width, and the you don't do any scrolling.

  • Here's another idea too. The crux is a compare like the following to see if any of the text matches what was typed.

    compare textbox.text = left(text.text, len(textbox.text))

    dropbox.com/s/55xlnwskmv7dy0d/search_system_test.capx

    And then I realized some simplifications:

    dropbox.com/s/9gwsv0q7yugzv1c/search_system_test_2.capx

  • Worst case you can use canvas.imageUrl to get a save of the canvas image. Then to load it you’d take a sprite at the same position as the canvas, load the imageUrl into an animation frame of the sprite, set the sprite size to the same size as the canvas, clear the canvas, and finally paste the sprite into the canvas.

    On a side note the plugin did save/load the image at some point. It possibly could have been disabled in code since it was slow, but I don’t recall. I don’t use the plugin anymore and have ceased any development on the plugin itself to fix issues that crop up.

    I am happy to try to help with usage questions when I can. Probably not with examples, since I don’t have it installed, but maybe I can help point you in the right direction.

  • I agree, the shunting yard algorithm, and reverse polish notation wouldn't be suitable for anything beyond expressions. I've found recursive decent to be awkward and abstract when dealing with precedence, could be just me though. I'm not sure what class of parser I currently utilize falls under but if I wanted to generate a ast I've used the following which I'll drop for reference. It looks similar to the shunting yard algo.

    en.wikipedia.org/wiki/Operator-precedence_parser

    There are pros and cons to different methods for sure. A lot comes down to personal preference. The method I used seems to make it fairly easy to change up the syntax rules and add stuff. Here i added some math functions and 2d vector types to the expression. Along with type checking, but the error messages could be nicer.

    dropbox.com/s/paqwch9pke1pvms/parser_test5_with_vec.capx