R0J0hound's Forum Posts

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

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

  • —

    You can test it currently. It works but no, it's not finished yet.

  • kmoon11

    Thanks for the elephant sample, that should be enough of a test case to get things working correctly.

    I'll have to decline putting this on github for now since I don't use github. If you want a link to the plugin this is where I'll keep a working download:

    Thanks for the technical help too, but it shouldn't be necessary. Between the source code, the documentation, and existing examples it looks like I've got everything I'll need.

  • zenox98

    The pause with ajax is the time it takes to load the file into memory from the disk. The disk is the slowdown here. When the project is exported then it would likely take longer to load from the net than from the disk.

  • This should be faster. I've used something similar before to load the entire English dictionary.

    Global text data=""

    Global text word=""

    Global text c=""

    On ajax complete

    -> set data to Ajax.lastData

    --- repeat len(data) times

    --- -> set c to mid(data, loopindex, 1)

    --- --- system: c=";"

    --- --- -> array: push back word

    --- --- -> set word to ""

    --- --- else

    --- --- -> add c to word

  • Some functions, but you can also make things simpler by not using a sprite per substance, instead have one substance object, but multiple instances and use a an instance variable to distinguish the two. If you do that you can reduce the amount of events down to five even if you have hundreds of substances.

    For multiple players I'd just add multiple instances of your player object and add a variable to distinguish between the two. The dictionaries relate to a single player so I'd put them in a container so each player has their own. Then adding a "for each player" to the last three events should get you most of the way there. The function will need to be modified so the player.uid is passed as well, then the first thing the function should do is pick by uid the passed value. You can do it without a container with variables but I don't feel like working that out.

    OBJECTS:

    Dictionaries: sub_dict, potion_dict

    Sprite sub_sprite with text variable "name". Set the value of "name" to the name of the substance.

    Spritevplayer with text variables "slotA" and "slotB". Both should start with a value of "".

    EVENTS:

    player: on collision with sub_sprite

    [inverted] sub_dict: has key sub_sprite.name

    system: compare: player.slotA+player.slotB <2

    --- sub_dict: add key sub_sprite.name with value 1

    on function "make potion?"

    sub_dict: has key function.param(0)

    sub_dict: has key function.param(1)

    --- potion_dict: add key fuction.param(3) with value 1

    --- sub_dict: delete key function.param(0)

    --- sub_dict: delete key function.param(1)

    every tick

    --- call function "make potion?" ("substance1","substance2","potion1")

    --- call function "make potion?" ("substance1","substance3","potion2")

    --- call function "make potion?" ("substance2","substance3","potion3")

    --- ... and so on

    Potion_dict: for each key

    player: slotA = ""

    --- player: slotA set to Potions.CurrentKey

    --- sub_dict: delete key Potions.CurrentKey

    Potion_dict: for each key

    player: slotB = ""

    --- player: slotB set to Potions.CurrentKey

    --- sub_dict: delete key Potions.CurrentKey

  • I made it less than a month ago so it's still new. Since then I haven't touched it. I usually code in spurts instead of slow and steady.

    What is left to do with it is pretty simple. Just adding actions to change the animation, the speed, the position in the animation, and animation blending. It's just a matter of using the functions built in to the js library provided by Krestel Moon so it's not complicated, I just haven't done it. As far as rendering with webgl it's complete, but I probably won't get it working if webgl isn't available, and making it render in the editor is impossible.

    I can't run the software on my Vista machine (it needs 7+), and so far I've only found one export and that has only one animation in it. If I could get an export with two or more animations in it then I can get the animation blending working. Without that I can't test it, and coding blind is the best way for it not to work.