oosyrag's Forum Posts

  • Got an example capx of what you've done? There are quite a few possibilities and it would be a bit silly just to guess from your description alone.

  • How many json files do you have? Straight forward way is to create a function with an event for each file: if param=0, load a, param=1, load b ect... Might be a bit tedious if you have a ton of files, but you only have to do it once.

    Edit: and then call the function with floor(random ()) for the parameter

    Edit 2: answer below way better.

  • Positioning by code is much less tedious than you might imagine. Breaking up a string into it's constituent characters into an array is just one single looped event, and placing them all as sprites again is another.

    It gets more complicated when dealing with individual spacing between characters (depending on the width of the character) and line breaks. Those can be handled based on your requirements though.

    Sorry don't have an example for you right now but if you have trouble figuring it out and don't mind waiting I can put one together pretty quick when I get to a computer tomorrow.

  • Create an array, width set to the size of your number pool (100), height and depth 1. Populate the array with the numbers 0-99, an easy way to do this is:

    Repeat Array.Width times - Set Array at loopindex, to loopindex[/code:37glqkyh]
    Now to pick a number out of the array, use a variable (I would make it an instance variable for the array) called PickedIndex. Also one more (global) variable to save the number that got picked.
    
    To pick a number, you can use:
    [code:37glqkyh]Set PickedIndex to floor(random(Array.Width))
    Set PickedNumber to Array.At(PickedIndex)
    Array - Delete Index PickedIndex[/code:37glqkyh]
    
    In summary, this picks an index from the array based on the size of the array (so it works even when it starts shrinking), saves the value at that index, then deletes that index so you won't be able to get that number again next time.
    
    The troublesome part for you now is to create a set of events to determine which object to spawn based on that number (there is probably a better way to do this, but it evades me at the moment). Highly recommend putting this set of events in a function you can call, with the parameter being which object to create. Note this is actually 0-99 now, rather than 1-100. You can do the latter simply by using loopindex+1 instead when populating the array.
    
    To reset the number pool, resize the array to what you want it to and refill it as done above.
  • So non repeating random. This plugin may be of use

    First though, some advice setting up. Are your Sprite objects unique in that they need to be separate objects? This will be significantly simpler if you were able to use one object with 100 different animation frames as opposed to 100 different Sprite objects.

    Otherwise I think you may need an event for each unique object. Roll a value from 1 to 100, if 1, create object a, if 2 create object b, ect...

    Edit: let me know if you want to avoid using plugins, a similar way to get non repeating integers from a range can be done with arrays as well, but it will be more complicated. Still relatively simple if you are comfortable with arrays though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Put your sprites into a family.

    On click button

    Repeat 8 times - create object family.

  • Browser.ExecJS("Date.now()") will give you the system's Unix time in ms.

    To get seconds, divide by 1000 and round. You should save this value to local storage every x seconds, and compare the current Unix time with the saved time upon resuming the game.

  • Sorry don't have an answer off the top of my head. I'll experiment a bit when I get the chance to see if there is anything that can be done.

  • Sometimes, it pays off to not be too strict about authoritative host when certain requirements need to be met. Bullet spread is definitely a classic problem for real time multiplayer shooters. There are many approaches, for different situations.

    1. Fudge the local visual. Example - Counter strike - the bullet holes a player sees doesn't necessarily mean that's where the server decided the bullet actually went, even if they have the same constraints. It is an illusion, but doesn't necessarily affect game play significantly. For a third person view like yours, this works especially well if you have an "accuracy" type system as well, where a bullet passing through a sprite has a percent chance to do damage or "hit". Running with Rifles is a good example. If it is known the enemy has a chance to not get hurt even if it looks like they get hit, they will be more accepting of fudging done due to mismatching host/client visuals.

    2. Use a seeded random. A possibility, but not recommended with something as numerous as bullets across multiple peers.... Keeping the order synced sounds like a nightmare to me, but I haven't tried it so I might be wrong.

    3. Best for slower projectiles - Have the local input prediction fire off a bullet sprite with 0 angle, and after it receives the actual angle from the host, start correcting the course of the local bullet. The slower the projectile, the less distance it will travel before getting the actual angle, making it not really noticable. There would only be a slight discrepancy near the origin, where the angle has the least impact anyway.

    I think for your particular situation you have two best options - just fudge the player's visual feedback and accept that it might not be "real", or allow the peer to be authoritative on the angle of the shot.

    An additional nice touch is to have seperate feedback for a host determined "hit", like blood or flashing some other indicator. Then even if it looks like a bullet passes through the enemy, if they don't flash maybe it can look like the bullet went by them (above?). Also if it looks like the bullet missed, but host determines a hit, at least the player will get some feedback that there were hits.

    Lastly, the less possible bullet spread the easier it is to fudge acceptably in general, which may be a consideration.

  • I have no idea. Try it and find out.

  • "Access-Control-Allow-Origin:" Is a setting on your web server (Apache?) where the file you are trying to get is located. If you not managing your own web server config, such as with a third party hosting site, you might not have access to this. You can always try inquiring with your host/server admin to see if it can be enabled.

    ref: https://enable-cors.org/server_apache.html

  • Can you give an example of how you are currently assigning custom keys to your controls? It will be easier to see how best to integrate.

    Basically upon entering an "Assign key" state, add events for on left/right/middle mouse clicked - do something. This should be in parallel to your on keyboard key or button pressed.

  • Your second layout does not have an event sheet attached to it. Click the Layout, then check the properties bar to assign an event sheet.

  • Gotta break up your link a bit with spaces so it doesn't get truncated