Game replay?

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • You can't name instance variable as X and Y 'cause it would conflict with the inbuilt .X and .Y for position.

    Also in your solution you suggest to spawn a lot of objects to work as a path remainder (breadcrumb). But it's too heavy to create a whole object when you just want to store 3 values (X,Y and Angle).

  • GingerBatMan

    Also you can add

    System: iterator = tokenCount(log,newline)-1
      -> System: set Replay to 0
      -> System: set iterator to 0

    nested under event 2 just after event 3

  • Yann, Thanks!!! makes things a little better :)

    A few questions if your genius mind is up for it :)

    1, Saving the replay?

         - Can your mind figure out how to save a replay?

    2, Controlling the replay -

        - Pausing and resuming the replay? (RexRainbows pause function does not quite pause this)

        - Speed control? - Can i control the speed of the playback?

  • Right now Replay is a System-Event based on a flag, so it is executed each tick. You could "rewrite" this to be in a execute every n second event to control the playback speed.

    A save way for a save would be a client/Server connection

  • Weishaupt, thanks and sorry for being a pain with all my questions :)

    How would I do this serverside? I have a server which im currently hosting high scores on, So will it be similar?

    Here is the PHP for posting..

    <?php

    // read variables from POST data.

    $username = $HTTP_GET_VARS[name]; <-- DEFINE THE USER??

    $score = $HTTP_GET_VARS[score]; // <-- MODIFY THIS TO SEND THE REPLAY??

    // verify the username is set and not empty

    if (!isset($username) || $username == "") {

        echo "failure";

        exit;

    }

    // verify the score is set and a number

    if (!isset($score) || !is_numeric($score)) {

        echo "failure";

        exit;

    }

    // format the username and score as a comma delimited row

    $entry = $username . "," . $score . "\n";

    // append entry to the score file

    if (!file_put_contents("scores.csv", $entry, FILE_APPEND)) {

        echo "failure"; // failed to write to file

        exit;

    }

    echo "success";

    ?>

    Then Return the data

    <?php

    /** Return a list of top scores. */

    // read variables from GET data

    $num_scores = $HTTP_GET_VARS[num_scores];

    // read each line in scores.csv as a string into an array

    $scores = file("scores.csv");

    // define a comparator to sort items by score

    function compare($s1, $s2) {

        // split the strings by their delimiter

        $a1 = explode(",", $s1);

        $a2 = explode(",", $s2);

        // compare the scores

        return $a2[1] - $a1[1];

    }

    // sort the array of scores

    usort($scores, "compare");

    // output the requested number of top scores

    for ($i = 0; $i < $num_scores && $i < count($scores); $i++) {

        echo $scores[$i];

    }

    ?>

    Can i send:

         - int(tokenat(state,0,","))

         - int(tokenat(state,1,","))

         - int(tokenat(state,2,","))

    instead of score? the retrieve it?

  • You and neither your questions are a pain. I enjoy being helpful and passing on my "knowledge".

    About the server issue, I have to ask you to wait till tomorrow, or for some other user to comment on it.

  • Tehee I feel Special ;D.

    Thanks sure i'll wait.

  • Quick thinking...since the recorded data is nothing else but a string, you should be able to handle it just like the score....

    just try it...

    PS: you probably have to change the delimiter characters of you PHP

  • Weishaupt,

    I allready tried to modify it allready, Didn't go so well.

    Changed the variable names and then was like what now? :S

  • ok...like I said, then it has to wait till tomorrow....

    ....could me give a little more details about the server side?!

  • Ok, I'll wait. Thanks

    "could me give a little more details about the server side?!"

    Like what?

       -What I need to happen on the server?

  • Is the server run by you....what kind of server is it? just a webserver answering the requests...

    I see that your php uses HTTP-Requests, but how are they handled on the other side.....

    Maybe I am way of now...if so, I just have to educate myself a litte more before presenting a solution

  • Here is the rar containing the scoring system, and a capx(I did not make this, im just using it)

    "Is the server run by you....what kind of server is it? just a webserver answering the requests..."

         - Yes I am using just a webserver

    "I see that your php uses HTTP-Requests, but how are they handled on the other side....."

         - Download the .rar it should answer than in the "readscores.php"

              - The Post handles posting the score's, Translates the data into a .csv file format, Then the readscores.php puts them into a array and displays the data.

  • Forgot to add a Weishaupt :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't know if you noticed but the 'log' variable... is in CSV (Coma Separated Value)... Just saying :D

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)