R0J0hound's Recent Forum Activity

  • 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.

  • 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.

  • You can probably find something in one of my posts.

    The first thing is to detect the collision which is simple enough using the "is overlapping" condition. Next you need to get the objects to not overlap. One way to do that is to move the object backward till it's no longer overlapping, another is to push out in the closest direction which could either be done with some creative checking the around the sprite or using the Separating Axis Theorem (SAT) algorithm. The final thing to do is the actual bounce, usually that requires the normal or angle of the edge where the two objects meet. SAT can provide this or you can treat the objects as circles and utilize the angle between them as LittleStain said.

  • Not the camera, but you can make your graphics look like that.

  • wizdigitech

    Just don't use the debugger to view the contents of the array and it won't crash. Actually you should start the array with size (0,1,1). The push will increase the size.

    Alternatively here's another way I did a while ago. It sets the size of the array from the get-go and then uses find() to save on having to loop over every character.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can test it currently. It works but no, it's not finished yet.