R0J0hound's Forum Posts

  • Not in game, the runtime does different setup for webgl on/off when the runtime starts. Best you could do is two exports, one with webgl of and one with webgl off. Then when you change the option your game would cause the the url of one or the other to load.

  • Ashley

    I refined the capx further here:

    https://dl.dropboxusercontent.com/u/542 ... _bug2.capx

    Description:

    The bug is an "or event" that's a sub-event of an empty event affects a following "or event" that's a sub-event of a "for each" event.

    Here's what the events looks like:

    The layout has two sprite types: red and blue.

    Red has only one instance and can be anywhere. It is only required to have the "for each".

    Blue has at least two instances to be able to see the bug.

    The gist of the events is to pick the first instance of blue and make it transparent if it's left or above the center of the layout (250,250).

    It acts as intended for the first instance of blue, but when event 2 is enabled then event 4 also seems to pick any other instances of blue. The other instances are only picked with the second condition of event 4 though. So if any other instance has a y lower than 250 it becomes transparent.

    The expected behavior would be for the other instances to not be picked regardless if event 2 was enabled or not.

    If rewritten without using "or", and keeping the same behavior as the bug, the events would look like this:

    This was tested in r219 in google chrome 47.

  • Probably something like this to set column 1 to column 0:

    set array at (1,0) to array.at(0,0)

    set array at (1,1) to array.at(0,1)

    set array at (1,2) to array.at(0,2)

    set array at (1,3) to array.at(0,3)

    set array at (1,4) to array.at(0,4)

    ...

    set array at (1,array.height-1) to array.at(0,array.height-1)

    But that just screams "use a loop", so...

    repeat array.height times

    ---set array at (1,loopindex) to array.at(0,loopindex)

  • Here's a further refined capx:

    https://dl.dropboxusercontent.com/u/542 ... r_bug.capx

    r219

    Enabling\Disabling the "or event" at event 3 affects the result of the following "or event".

    With the first or event enabled the second or event changed the picked blue from uid 0 to uid 12.

    I'll see if the capx can be reduced further.

  • Without looking at your capx I can guess you're using the system->compare condition with distance() expression to check the range. You can probably fix it by either using the system->"pick by comparison" condition to pick the objects in range or you could loop over the enemies with a "for each" condition.

  • The NWjs runtime is what takes up most of the export. You can look in the NWjs install folder to see the empty size. Next up would be the sound and graphics size. Lastly would be the Javascript, events and layouts but those affect the size much less than anything else. The size of your capx may give a ballpark of the size that would be added to the NWjs runtime size but you'd have to export to see the actual size.

  • Could be an interesting feature. Of course there's nothing stopping you from coming up with your own animation system with events. Here's one I did a while ago using sprites to define keyframes:

  • That sounds like it would work. There isn't really a best way.

  • [quote:1op3hxic]Would it be better practice if I only had things happen when they changed, either by putting it in a function or testing for a keypress? I could be wrong, just seeing if every tick is expensive in processing terms or not?

    I'd say it's irrelevant for something as simple as setting a variable.

  • To make it work on the entire layout you could put the sprite on a top layer that doesn't scroll or scale and make the sprite cover the screen. To effect just a layer could be a bit trickier, worst case the sprite would be on that layer and you'd need to do the math so it covers the screen.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the first one if the value of CurrentWeap never exceeds 9 you could do this:

    every tick
    --- set animation frame to int(mid("0123345", CurrentWeap, 1))[/code:1kn81aia]
    
    Or you could do this if you want to handle double digit values:
    [code:1kn81aia]every tick
    --- set animation frame to int(tokenat("0,1,2,3,3,4,5", CurrentWeap))[/code:1kn81aia]
    
    For the second bit I'd utilize key codes.
    "1" has a key code of 49
    "2" has one of 50
    ..
    "9" has one of 57
    
    You can make a simple capx to inspect the keycode values of certain keys if you wish or there's probably a reference online somewhere.
    
    So basically you then can do this:
    [code:1kn81aia]on any key pressed
    system: Keyboard.LastKeyCode is between values (49,57)
    --- set CurrentWeap to Keyboard.LastKeyCode-49[/code:1kn81aia]
  • "samplerfront" and "samplerback" are the only two that C2 sets up for you.

    You could use a sprite as a second texture. Put it at the top and give it your effect then samplerfront would be your lookup and samplerback would be everything drawn so far.

    In cases where you want to do everything webgl allows you to do with a shader you'll have to write your own plugin. specifically in the drawgl function. You can look at the creature2d plugin I started for an example of using custom webgl outside of what C2's renderer provides. Basically you use the endBatch() function then do anything you want. Only be sure to set the webgl state back to the state it was before your custom code. It'll probably need some trial and error and you'll need to dig around the source a bit but the end result could be cool.

  • You do have the vector though. If you're moving with:

    Set X to self.x+60*dt

    Set y to self.y+30*dt

    The the velocity vector would be (60,30) and the displacement vector in one frame would be (60*dt, 30*dt). So the angle of motion would be angle(0,0,60,30).

    The two ways to avoid collisions is either:

    A. Use the displacement vector with the "overlaps at offset" condition to check if the object won't collide before moving it.

    B. Move out of the object after it is found to be overlapping. I mentioned this in your other topic. The two common ways are to either move backwards till it's out or find the closest direction to move the out.

    Their are pros and cons of each. With A you have to ensure that objects don't start overlapping, and you need to close the gap if the velocity is high. B is more common and reversing the motion is good for stopping whereas using the closest direction makes wall sliding easier.

    Here is a simple collision resolver. All that's required is the X and y velocity the object is moving.

    While

    Sprite is overlapping wall

    --- Sprite: move -1 pixel at angle angle(0,0,self.velocityX,self.velocityY)

    The example in that link does a circle vs box collision resolution using sat with voronoi regions. If you've heard of the flash game N or N+, their website has a write up on the technique. It basically boils down to the distances between between the player and each corner and edge of the box is measured and the shortest distance is used. The distance() expression is used when comparing the distance to the corners and a vector cross product is used to find the distance to the edges. On a side note the motion is done with verlet inergration instead of Euler but that is a different topic.

    Another advantage I like about using sat like in the link is I can calculate the exact position on the edge of the box to place the player. Whereas the example above is an iterative approach that can cause a gap up to a pixel between the objects, but you do get to use the object's collision polygon instead of treating it as a circle. I usually handle the gap by first moving out by pixels and then move back by tenths of a pixel till it's just shy of a overlap.

  • keepee

    Do you have a capx that reproduces it? That line is run when applying forces, but it works here.

  • kmoon11

    The edittime is kind of limited. It can't access any other data other than an object's texture and the values in it's properties. The authors are currently making Construct 3 which is said to mainly be an editor re-write so perhaps it would be possible with that when it comes out.