randomly's Recent Forum Activity

  • You can also simply set the button to "disabled".

    Done.

  • [quote:3g6wjlw4]in case anybody is disconnected and has to connect back, he will get a new number.

    To prevent this, you could add an array or a dictionary that store each player's group number together with their Multiplayer Alias.

    When a player connects, he will be assigned to his group and the host will save the player's alias to the dictionary.

    In case one player disconnects, he simply has to login again with the same alias. The host will then assign the player the group number that is stored under his name in the dictionary.

    _________________________________

    [quote:3g6wjlw4]what is common to all players and what is specific to each

    Basically, there are three groups:

    peer, host and common.

    You can't be peer and host at the same time.

    The first player that joins a multiplayer room, automatically becomes the host for that room.

    The main difference between peers and the host is:

    • the host can broadcast messages to all peers
    • peers can only send messages to the host or to a specific peer

    In the event sheet, you differentiate between these two to not include actions that can't be executed anyways (like trying to broadcast messages as a peer). You can also give host-specific tasks (like in your project) since the host is the only person that can broadcast messages.

    (You can test whether you are host or not by checking the condition "is host")

    __________________________________

    [quote:3g6wjlw4]when I create an object such as a dictionnary on any layout, how does this work in a multiplayer ?

    You need to keep one thing in mind:

    In Multiplayer, nothing apart from positions or angles can be directly shared between peers.

    You need to distribute information via messages and by using the host's broadcasting ability.

    ([object].AsJSON is very helpful there).

    Let's take the example of a dictionary:

    • The host would have the "ultimate" version of the dictionary
    • when something happens to a peer that needs to change the dictionary, the peer will send those information with an appropriate tag to the host
    • The host will read that message, edit his dictionary and broadcast his dictionary as JSON to all peers
    • The peers, on receiving the host's message, will load their dictionary from the JSON in the message
    • Now everybody has the same dictionary

    Also remember that, most of the time, you don't need to create separate objects for the host and the peers. Like in the dictionary example, you could add one dictionary to your project, that is used differently by peer and host.

    ______________________________________________

    [quote:3g6wjlw4]And when you say to give that task to the host, do you mean the host is the one generating the smart random and then send their numbers to each peer ?

    Exactly. It would be a mess if every user generated their own number.

    We need a central user who stores the group numbers of every player for later use.

    If every peer generated their own number and stored it locally, we would need to send that information one by one to each peer when it is needed. If it is stored at the host, he can simply broadcast what is needed for everyone and send messages to peers that require special information.

  • Take a look at this plugin by andykenobi , it supports Android and PC.

    PushJS plugin

  • [quote:ptttuyru] Upon connexion, every player gets the next value in the smart random list.

    Oooooooohh...........

    OOOHHH...

    Now I see where you are going. That's actually a waaaay more intelligent solution than mine. Wow.

    As long as you give that task to the host and the host only, it's fine.

    I didn't understand it at first, I thought you want to give that task to every peer on connection.

    (If you have problems with understanding and you didn't read it yet, take a look at this: Multiplayer tutorial: concepts)

  • You simply add a "*2" at the end of the calculation.

    Or, after the calculation you set the text of the pot to "int(Self.Text) *2"

  • The shadows are rendered on top of the solids, that's why.

    Either move the ShadowLight's Z index below the solids or Create a new layer, put the ShadowLight on that layer and move the layer below "Layer 0".

  • [quote:3hlelo8t]But with a threshold of 0 in the smart random, I would always get a balanced distribution. So even if I do not check if the group is full, the balance would still be maintained.

    I'm not sure if I misunderstand you. If I comprehend you correctly, you want to generate the group number from the peer, right? Each peer generates his own group number?

    If that is correct, I'll tell you why that won't work:

    The peer can generate a random number, 1, 2 or 3 and every number is generated just once.

    But the peer doesn't know whether a room is full.

    So if he generates 2, and keeps that number, he will be in room 2.

    But what if there were already 6 users in that room?

    Only the host should generate group numbers since _he_ knows whether a room is full.

    (I have the feeling, I really didn't understand you..)

    ___________________________

    [quote:3hlelo8t]I wanted to try it, but I am using the free version for now, so I can't use "families" right now.

    Ah, right, I forgot about that, sorry.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound

    Huh, I'm not sure whether I fully understand what you are saying..Am not that familiar with javascript.

    And even if I manage to get a download with javascript, no idea how to use the download into C2.

    Anyways, I'm going with the server-sided value now.

    (Quick side-question: Does anything speak against downloading .exes over 1MB with AJAX and writing them to disk with NW.js? If that's too complicated, nevermind, I'll open a new thread for that)

  • [quote:13vtgef4]All I need is a global variable "group" for each player that is set on connection by smart random (start 1, end 3, threshold 0). Doing this would guarantee the balance between groups right ?

    Well, actually it would have to be a bit different.

    Since there is a player limit for each room, you need to take into consideration whether the room is already full or not.

    The variable "group" won't be set on connection by the peer but by the host.

    The host will have three dictionaries, one for each room, in which he stores who is in that room.

    When a peer connects, the host will check the first dictionary whether it is full. If there is space, he will add the player to the dictionary and send him his group number.

    If the group is full, check the next dictionary.

    You can add randomness by multiple ways.

    One would be to have every player set a preferred group on start which is generated randomly (pun not intended). This value is sent to the host when connected. The host will then first look in the dictionary with the number that has been sent and continue looking numerically. (System condition "For each ordered").

    ___________________________________

    [quote:13vtgef4]Sometimes, I would need more than 3 groups

    You will have to add the appropriate amount of dictionaries and change the random generation like you said.

    (Checking of the dictionaries won't be affected since "For each" automatically looks at the count of the objects)

    You will also have to add events to the host "On [groupX] message" to cover all groups.

    ______________________________________

    [quote:13vtgef4]Also, when you say it will be hard for the host CPU, do you think that would actually take a lot of time to deal with all the comparisons ? More than 30 seconds ? Several minutes ?

    I don't have much experience with this, but I'd say not that much. Several minutes? Definitely not.

    It depends on many factors.

    Of course, it depends on the computer's specs, a bit on the internet speed (not that much though) and on the amount of messages that are posted by the players at the same time.

    You would really have to test this out.

    One thing to experiment with would be to create a new project, designed for the host only.

    This would be started first, would be no player, and his only task would be to handle everything host-related.

    Having a separate host instance would increase the performance for everyone, since there won't be one player who is always doing the host tasks and the host won't have to deal with the peer-only stuff.

    ________________________

    [quote:13vtgef4]When you are the host, you also send message with a tag corresponding to your group value and you broadcast every message you get. However, you only display those who have a tag corresponding to your group value.

    Assuming, you don't go with the separate host, that is correct.

    As a host, when receiving a message, you would have to get the group number of the user the message came from.

    (Compare "FromID" with ID in group dictionary)

    Then, you would broadcast the message to everyone with a group tag attached to it.

    As a peer, when receiving such a message from the host, you would have to parse the message to retrieve the group number. Shouldn't be too difficult. (If you need help, PM me or google for it)

    _________________________________________

    [quote:13vtgef4]When you are a peer, you send message with a tag corresponding to your group value. And even if you get messages from everyone, you display only those that has a tag corresponding to your group value.

    [quote:13vtgef4]When you are the host, you also send message with a tag corresponding to your group value and you broadcast every message you get. However, you only display those who have a tag corresponding to your group value.

    Almost correct! (Again, assuming, you don't have a separate host)

    As a host, you wouldn't need to send the message with a tag corresponding to your group value, thus, a regular message like a peer would send.

    You can simply broadcast it, since the peers will only display messages that come from the host and are declared as "host broadcasts messsage". (Like in your .capx, you probably just wrote that wrong)

    ________________________________________

    Something not related to the Multiplayer part:

    I noticed you still have the many, many Sprite1, Sprite2, Sprite3,... events.

    Did you try what I wrote on my first post? This would make it more compact and easier to handle.

    Try this:

    • Add a family containing all the sprites, e.g."Sprites"
    • Add a family instance variable, e.g. "index"
    • Edit that variable for every Sprite and set it to the Sprite's number (don't set it in the event sheet, set it in the object properties)
    • Delete that long chain of conditions you referred to (Spawn=X, Spawn=Y,...) and replace it by this:
  • R0J0hound yeah sure, I could create a server-sided value with the size and let the user download that info.

    I was just wondering whether there is any easier way in the AJAX plugin.

    You could figure out the rate of the progress and give the user an eta as well

    As soon as I have the filesize, I can do that, yeah.

    Thanks for the answer.

  • Where do you upload your game to if I may ask?

    I probably can't help you anymore from this point on..

    I still believe that the project property "Fullscreen in Browser" might be the issue.

    But, seriously, I don't really know..

  • Hey everyone,

    I'm using AJAX to download patches for my NW.js exported project.

    When downloading an update via AJAX, I'd like to give the user feedback on how far the download is, not only by the overall progress, but also by how much of the filesize has been already downloaded (X MB of Y MB).

    Since my patches' size isn't static, but varies with each release, I can't use a static number.

    So, the question is: is there any AJAX-built in possibility to get the size of the requested file?

    If there isn't one, I guess I'll have to set a server-sided key with the release's size.

    Thanks for any answer!

randomly's avatar

randomly

Member since 26 Sep, 2016

Twitter
randomly has 1 followers

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies