Game replay?

Get help using Construct 2

Post » Fri Jan 06, 2012 5:40 pm


I'll try to fix the CAPX...Weishaupt2012-01-06 17:40:37
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 06, 2012 5:45 pm

Here you go...

B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 06, 2012 5:57 pm

Thanks @Weishaupt, @Yann. you guys really helped me out.

If only there was a way to save this, and view it at anytime :o
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 6:22 pm

i dont think that this will work
but... try it

Make a checkpoint object with 2 private variables X and Y . it will be a point sprite and set invisible

add to your script:
during all the race:
spawn CheckPoint object on sprite player 2

for each instance
set local value

awwww... i cant do it :(
maybe you can figure out how you can save each instance value
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Fri Jan 06, 2012 6:28 pm

@kbdmaster, I don't really understand..
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 6:44 pm

@kbdmaster
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).Yann2012-01-06 18:44:47
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 06, 2012 6:50 pm

@GingerBatMan
Also you can add
[code]System: iterator = tokenCount(log,newline)-1
-> System: set Replay to 0
-> System: set iterator to 0[/code]
nested under event 2 just after event 3
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 06, 2012 7:41 pm

@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?
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Fri Jan 06, 2012 7:58 pm

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
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 06, 2012 8:33 pm

@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?
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Megavolt, mnashwan, shinkan, stylie1, tarek2 and 16 guests