R0J0hound's Forum Posts

  • I guess you could move the object by the offset, check for overlap, then move it back.

  • You probably wouldn't want to use the angle of the car to check if another was behind. What happens if your car is going backward on the track?

  • For a game creation tool geared toward beginners this is a hard to understand and hard to explain quirk of picking. It has everything to do with when newly created objects are pickable.

    What Construct does is keep track of three seperate lists:

    object list (OL)

    new object list (NOL)

    selected object list (SOL)

    Before a event starts the SOL is the same as OL, and the conditions do picking that changes the SOL. So far so good, that's easy to understand.

    When an object gets created it isn't added to the OL right away. Instead it's added to the NOL and the SOL is set to just that new object. The NOL is only added to the OL at the end of a top-level event. Bear in mind a function isn't a top-level event.

    Also the pick by uid condition is special in that it can pick an object at anytime after it was created. This is the simplest way to just ignore this picking mess.

    Anyways that's a bit hard to follow so let's consider the examples in your capx.

    Test1

    global spawnedCard=0
    
    on "spawnCard"
    --- create card
    --- set card.carduid to card.uid
    --- return card.uid
    
    on "setScale"
    pick by comparison card.carduid = param(0)
    --- set card scale
    
    start of layout
    --- call "spawnCard"
    --- set spawnedCard to returnValue
    --- call "setScale" (spawnedcard, 0.1)
    Start of layout is triggered and the lists are:
    OL=[], NOL=[], SOL=[]
    
    spawncard is called
    OL=[], NOL=[], SOL=[]
    
    card is created and before the function exits:
    OL=[], NOL=[card0], SOL=[card0]
    
    Back in the start of layout event
    OL=[], NOL=[card0], SOL=[]
    
    setscale is called
    OL=[], NOL=[card0], SOL=[]
    
    it tries to pick the card with pick by comparison condition but since the SOL is empty it fails. The solution here would be to use the "pick by uid" condition.
    
    the function returns and the "start of layout" ends and since it's top-level the NOL is moved into the OL:
    OL=[card0], NOL=[], SOL=[] 

    Test2

    on setscale
    pick card by comparison
    --- set card scale
    
    start of layout
    --- create card
    --- call setscale
    start of layout triggered
    OL=[], NOL=[], SOL=[]
    
    new card created
    OL=[], NOL=[card0], SOL=[card0]
    
    setscale function called
    OL=[], NOL=[card0], SOL=[]
    
    pick by comparison attempted. No objects in SOL to pick from so it fails. Again using "pick by uid" would fix this.
    
    function returns and start of layout ends:
    OL=[card0], NOL=[], SOL=[]

    test3

    Start of layout
    --- create card
    
    trigger once
    pick by comparison
    --- set card scale
    Start of layout triggered
    OL=[], NOL=[], SOL=[]
    
    new card created
    OL=[], NOL=[card0], SOL=[card0]
    
    start of layout ends
    OL=[card0], NOL=[], SOL=[]
    
    trigger once starts. The SOL is set to the OL.
    OL=[card0], NOL=[], SOL=[card0]
    
    card is picked by comparison. This one works because the card we want is in the sol.

    The examples in your capx are fixed as i mentioned by using the "pick by uid" condition instead of "pick by comparison". Again that's because "pick by uid" is special in that regaurd in picking newly created objects. There are other situations where this picking is annoying to deal with, but in this case it's trivial.

    This behavior is a heavily ingrained part of how events work so I wouldn't count on it changing. Also i do believe it was intentional to avoid some bugs, not to mention i'm not sure a better solution as it relates to the picking system is available. I don't think something like this is very nice for beginners though.

  • Anything will require a significant amount of work i think. Also there isn't a plugin to work with no one willing and able to figure out and make the necessary changes.

  • The simplest would be to modify the plugin itself to add new features. You'll probably need to to figure out how it works first.

    Otherwise you possibly could do it with the execute javascript action in the browser object. But scope is your enemy here. Anything saved with var will be gone very soon, so you'll need to attach it to a global object. Next if it needs to interact with what the plugin does already, you'll need to find a path in javascript to that stuff. It's very hacky in my opinion and it will not work after minifying.

  • Couldn't you create the text relative from the coins?

  • Isn't it just an animation and a sound that's played when the player collects it? You either could get existing free to use animation and sound or create your own by any means you want.

  • For making the ai avoid explosions you could use

    https://en.wikipedia.org/wiki/Breadth-first_search or

    https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

    It's kind of along the lines of what mOOnpunk said, but instead of a weight, we just search from the player to the closest non blast radius area. That brings me to another idea, you can use an array as a grid of the level and loop over the bombs and set all the locations that will have explosions. That gives a simple lookup with events.

    https://www.dropbox.com/s/ks3feo35bgyo1 ... .capx?dl=1

    Basically that's the first half of an ai. The blue guy will move out of the blast radius of placed bombs if it can without stepping into fire. It doesn't consider the time left before a bomb goes off which is something most players don't bother with. they just stay out of range of bombs.

    The second half would probably be moving and placing bombs. Finding where to bomb could be done with a similar breadth first search and then evaluating what a bomb would destroy (enemy or block) for each grid location considered.

    The logic would be:

    if the ai is in a blast radius

    move to same place

    else

    find a good place to bomb, move there and place bomb

    To keep the ai from bombing itself you can also check for if there's a place to escape to before placing the bomb.

    Anyways maybe some of those ideas are helpful. More advanced stuff can probably be considered later, but the basics are always good first. Also in the example everything is grid based but the motion doesn't have to be. The units need not even stop of grid centers, but that's something to figure out for another day.

  • ultrafop

    updated link in my post.

  • Pandy

    link fixed

  • oOScuByOo

    Sure, you could just keep it recording everything like normal, but when the length of the array gets too long you could start removing stuff from the front of the array. At 60fps 3/4 of a second would be an array of width 60*0.75 or 45.

  • Reinarte

    There probably are updates to the api that could be useful, but i'm not updating this anymore. It can probably be made to work with the minifier, but same deal, i'm not diving into the source to find out why.

    gamegennick

    No, what the plugin does is probably all it will ever do.

  • atmas

    In the capx it just creates the roads. at the start of the layout. You could just do what you said and only pick the roads off screen and within a certain distance of the player to create cars on.

    Pedestrians could probably be done in the same way, although you probably could ignore the collision detection. Here's another idea along those lines:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use the paster object to draw the objects to, and then you could in turn give the paster objects blend modes to combine them.

  • If they are always flipped you could flip the paster object first before pasting the text. Just center the flip on the center of the text object. Or to make the math simpler use a second paster object with the hotspot centered. The just place it over the text, flip it, paste text, flip it back, and move it to where you want to paste on the other paster.

    If it's flipped on only some machines then we need to detect if the textures are flipped. You can't do this with events but I think you can with JavaScript and webgl. The grab canvas action (I may have forgot it's name, but it's the one that tries to copy the game canvas to a paster object) has some code that finds this out first time it's run. It works by running a minimal webgl renderer to draw onto a 1x2 image. It then reads one of the pixels and thereby knows if it's flipped or not.

    Anyways to fix it in the plugin itself probably entails making the plugin check if textures are stored flipped when the plugin first loads, and the add a check to the paste action if it's a text object being pasted and flip it if need be.

    Or maybe look at the text object's source and see what it does. C2 doesn't have an issue with text flipping normally, so maybe by looking at the text object and C2's renderer you can see where the difference is.

    That's as narrowed down a place to start as I can think of.

    Hopefully some of that helps. I'm happy to answer questions from what I can recall but it's probably safe to say I'm not going to touch the plugin's source again.