troublesum's Forum Posts

  • Yes, you need append a parameter/string to the file name in the c2runtime.js script tag and change it when your file changes.

    Locate this text in the "index.html" file

    <script src="c2runtime.js"></script>

    And change to something like this

    <script src="c2runtime.js?version=1.0"></script>

    The browser interprets the whole string as the file path even though what comes after the "?" are parameters. So next time you update your file just change the number in the script tag on your website

    Example

    <script src="c2runtime.js?version=1.1"></script>

    This will trick the browser into thinking it s new file and not used the cached file.

  • Kniggles Your GET string you typed in is missing an argument. You need an "&" symbol just before password in text so the GET string parameters now where the username value stops and password parameter starts

    "http://mywebsite.com/getscoresPLAYERone.php?username="&playerName&"&password="&password

    In full string view it would like this

    [http://mywebsite.com/getscoresPLAYERone.php?username=troublesum

    &password=12345]

  • Robsta - The best way I found to do this so far is to synchronize instructions instead of objects for multiplayer platform based games. Its bit more complicated but I call functions cross device to achieve this. Here's a working example of a multiplayer platform using functions. Maybe you can adapt it to your project if you like how it works.

    Open a few browser windows, click connect on each and then use arrows to move.

    [attachment=0:pwgnwr68][/attachment:pwgnwr68]

  • Not bad.. I like the little intro story, but didn't like having to press enter every time. Could just be me but i would make that a play sequence with an option to skip (for return players). The camera work (view positioning) was nicely done. Good transitions, very impressive. Game play and user experience was intuitive, I knew what i was supposed to do and how to do it, accept when the player looses health when getting hit, the fading trail almost feels like i got a speed boost as opposed to being hit. Just the visual effect i guess but at first i was confused at to what had happened. After few screens though i got a little bored because after i kill an enemy if i die before finishing the level and respawn those enemy's are no longer there so i get bored going through game terrain to catch up to where i last died. Maybe don't have the player start so far back when they die so they always get instant action or re-spawn the enemy's so i have something to do catching up to my last point. Lastly I would just add some more parallax objects like clouds or something so as I'm scrolling the movement doesn't feel so fixed the few that are there don't feel like enough to keep persective. But all in all this has a lot a potential. Nice Job!

    Not game related:

    The file appears to be large and takes a while to load.. the first time you load it you just see a black box for quite some time and don't realize the file is still loading. I refreshed the page a few times thinking it broke. I would add some sort of spinning wheel if you can to indicate loading.

    But again. Nice job!

  • xoros Yeah is more complicated... Ill try my best to describe how it works (as a developer i can write pretty complicated/convoluted code)

    So to start out what I do is call functions simultaneously on all devices. I sync instructions not objects. Take a look at the Player event "Keyboard LeftArrow" You will notice i call two functions. One of them calls a function "MoveLeft" to move the player on my screen using a simulated action. You will notice the "MoveLeft" function takes a peerid as the parameter. This is so the function will for work any player (as you will see this is the same function each client will call as well using the the peerid they receive).

    [attachment=0:22fjanwm][/attachment:22fjanwm]

    The other function I call "Sync_MoveLeft". This is where the magic happens. "Sync_MoveLeft" packages up the function name "MoveLeft" and a peerid (which is my id since im the one that called it and loads them to a dictionary and then sends the dictionary AsJSON to all peers. Each peer receives the JSON string and loads it back into a dictionary on their end. They read the function name they are supposed to call and the parameters (peerid) they should pass to it and call that same "MoveLeft" function for me on there screen. All clients call the same function. pretty neat...

    But I found that the signalling just wasn't quite fast enough and the player would stutter a bit while moving. This where extrapolation comes in. What did was a create method for telling the peers to persist the function call on there end. You will notice in the Sync_MoveLeft function I also package up a persist value of 1. On the peers end they see this persist value and load the dictionary for constant use on their end. So every tick they will now call the move left command with the same peerid even if i don't send another. Poof! the player moves smoothly now.

    But now the player will move left to infinity so I need a way to tell it to clear that persisted action. So in the "Sync_MoveLeft" I also package up a persist tag (action tag really) with a key name "move" and the peerid of the player (more than one player could be calling move left at the same time). So what each peer does is when the see a persist value of 1 they check the perstsTag and if a persistTag already exists is clears it. So MoveLeft is persisted until MoveRight is called or stop is called. Bingo.. solid movement and precision control. If i call the same function twice thats not big deal because the persits tag will match and just keep using the same function anyway.

    Last just to account account for any potential lag I send a set position command every 30 ticks while I'm moving to ensure player objects don't drift to far out of sync while performing persisted actions.

    And that in a nutshell is how it works. Theres a bit more in there but I think if you follow the code along with the comments it should make more sense over time. Its just nice to know that you can achieve smooth movement you just have to do some of the heavy lifting you self and write some extra code.

  • I haven't used LiteTween but MoveTo is so simple it fits the paradigm of C2 perfectly. MoveTo would have my vote to be inducted into official status. In any case I never understood why something like this wasn't standard in C2 to begin with.

  • Every time i see a post referring this I make the argument that for platform multiplayer games the current method of if interpolation doesn't work very well. What I do is sync instructions instead of objects and get perfect results. Its a bit more complicated but it works. Not realizing what I had developed after researching I found that what im doing is called extrapolation where the client predicts position based on state instead of plotting between two known points.

    Here is an example platformer that syncs instructions (function calling) instead of objects. Your welcome to try and adapt it. Just open it in a couple of browsers, click connect then use arrows to move players. You will see the synchronization is near flawless.

    [attachment=0:xtgdvv0o][/attachment:xtgdvv0o]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ahh.. out of my league... good luck

  • "random()" will produce a floating point (decimal) number between 0 and 1 Ex. 0.24523 at which point you can round or perform some math to clean up the number as desired.

    To choose from a list of possible values you can do "choose(1,2,3)" which will randomly select either 1,2,3 as per the example. Is that what you mean by distributed?

  • You could try syncing instructions in stead of objects. I use extrapolation (predict location based on active state) instead of interpolation (plot movement based on known points) to coordinate movement.

    My way is much more complicated but for platform games it provides the results your looking for. What I do is call functions simultaneously on each device to sync the action instead of the object. Here is an example capx to demonstrate the theory. Open on multiple browsers, click connect. use arrow keys to move objects. Try it with 2,3,4 players and see

    [attachment=0:16aa78t5][/attachment:16aa78t5]

    Edit: I have reduced all the code from this example to simple plugin but haven't released the plugin yet (I'm debating on whether its worth the head ache of supporting it). In the mean time this example with out the plugin works if you want to give it try.

  • The more flexible the system the more logic you need to get specific results.

    I updated your capx

    [attachment=1:zyj9rkp0][/attachment:zyj9rkp0]

    There are so many ways to validate the click, some easy some hard. This is just one example that takes into account the relative position and zindex of the green sprite. I usually use variables to enable what i want clickable. But based on your example i chose to do this.

    [attachment=0:zyj9rkp0][/attachment:zyj9rkp0]

    In any case that's just the nature of programming. sometimes you have to do the heavy lifting.

  • You could Just add is visible to the condition or set variable when you want it enabled.

  • Having experience creating (multiplayer) plugins I can say that certain input expressions need to be explicitly in a certain format (string,int,etc) so as not to break the functionality of the object. The plugin parameter types are a predefined by the creator of the plugin as to what it will accept "paramAny, paramNumber, paramString" usually for a reason. In the case of multiplayer message (where i have a lot of experience) the problem you would have is that if you try to send a number it will always have to be converted to a string before being sent by the plugin. So when its received on the other end you will get a string in stead of the int you sent any way. You would have to convert it back to an int on the other end regardless.

    The best method for maintain data types for string transmission is JSON. With out any 3rd party plugins the easiest way to pass data is to load it into a dictionary, send the dictionary AsJSON and then when the peer receives it that load that JSON back into a dictionary and act on the data. By doing it this way you can maintain data types and can send complex instructions all in a single transmission. I can say with certainty that its just as fast and completely reliable as i do all of my multiplayer data transmission in this format.

  • Bl4ckSh33p - I had the same problem and after debugging the multiplayer plugin I found that once the peer connects to the room it still has to wait for the host to link to it. Its not part of the original process of joining the room. There is a peer condition called "Is Ready for Input" that you can work with to determine when its ok to start sending messages.

    Edit: Apparently I missed your last line as you mentioned "Is ready for input"

  • I posted this on your other thead but wanted to reply to this one as well.

    Make sure your encapsulating the php array in the format that the C2 array is expecting.

     $myArray = array();
        $myArray[] = 4;
        $myArray[] = 3;
        $myArray[] = 1;
        $myArray[] = 3;
        $myArray[] = 1;
    
        $output = array(
    	'c2array' => true,
    	'size' => array(
    	    0 => count($myArray),
    	    1 => 1,
    	    2 => 1
    	),
    	'data' => array()
        );
    
        $x = 0;
        foreach ($myArray as $value) {
    	$output['data'][$x] = array();
    	$output['data'][$x][0] = array();
    	$output['data'][$x][0][0] = $value;
    	$x++;
        }
    
        return json_encode($output);
    [/code:3rbxiej0]
    
    The resulting JSON string would look like this :
    {"c2array":true,"size":[5,1,1],"data":[[[4]],[[3]],[[1]],[[3]],[[1]]]}
    
    You can now take this string as is and load to the Array in C2