oOTrentOo
7277 posts
|
I want my idle game to keep track of how long you’ve played it, and show highscores in a highscores tab. I’ve looked at all of the API how to’s and I still have no idea. Any help is appreciated.
Here’s the game.
|
|
|
CuriousGaming
562 posts
|
1 – Keep track of time played. You can use the date class, or increment a variable every frame (divide that number by the framerate to find seconds played)
2 – implement the kong api. You can pretty much copy the example code from the api docs.
3 – submit time played to kongregate using .stats.submit.
The kong api has really solid documentation. The bits you want are:
http://developers.kongregate.com/docs/api-overview/as3-api (you’re using as3, right?)
http://developers.kongregate.com/docs/kongregate-apis/stats
http://developers.kongregate.com/docs/client/submit
|
|
|
oOTrentOo
7277 posts
|
Lolol, yeah those links are what I don’t understand. I know absolutely nothing about coding or anything. I feel like I would be able to understand egyptian better than those.
|
|
|
UnknownGuardian
8143 posts
|
Was your game written in AS3? Or stencyl? Or how did you make your game?
|
|
|
RTL_Shadow
1023 posts
|
Originally posted by oOTrentOo:
Lolol, yeah those links are what I don’t understand. I know absolutely nothing about coding or anything. I feel like I would be able to understand egyptian better than those.
If you know nothing about coding then how are you going to make a game- implementing the Kongregate API is easily one of the easiest things to do. I suggest reading some books and online tutorials :)
|
|
|
oOTrentOo
7277 posts
|
Sorry, I forgot to mention that in my second post. It was made in AS2.
|
|
|
feartehstickman
521 posts
|
There’s a shootorial that explains the use of the Kong API, if I remeber rightly.
|
|
|
saybox
2665 posts
|
The AS2 API is pretty easy to implement.
Start by doing what this one says: http://developers.kongregate.com/docs/api-overview/as2-api
Then do what this one says: http://developers.kongregate.com/docs/client/submit
And then add the relevant statistic on the upload / edit page for your game
I’m not gonna try to explain it any more simply that the docs do because it’s literally 3 lines of code, and it’s given to you to copy and paste. If there’s one specific part you’re having trouble with, post and say so.
|
|
|
oOTrentOo
7277 posts
|

Okay, there are highscores, but I want you to get one point for every minute you play. Right now I think you only get one point for each time you load the game.
|
|
|
feartehstickman
521 posts
|
Make a timer for one second that has an event that is trigger everytime the timer gets to one second.
Add one to the time every time this event is triggered.
Then, when the player does somethinng significant (like finishes a level) submit the total time to Kong.
You don’t want to be submitting the time to Kong every second though, that could end badly.
|
|
|
saybox
2665 posts
|
On line 14 of your code, change ‘1’ to the variable with the score in that you want to submit.
|
|
|
oOTrentOo
7277 posts
|
Originally posted by feartehstickman:
Make a timer for one second that has an event that is trigger everytime the timer gets to one second.
Add one to the time every time this event is triggered.
Then, when the player does somethinng significant (like finishes a level) submit the total time to Kong.
You don’t want to be submitting the time to Kong every second though, that could end badly.
I have no idea how to do this. D: Could you give me like the basic code?
Originally posted by saybox:
On line 14 of your code, change ‘1’ to the variable with the score in that you want to submit.
What does that mean. :B
|
|
|
Aesica
952 posts
|
How are you making games without knowing this kind of stuff? :O
|
|
|
Senekis93
4090 posts
|
Originally posted by Aesica:
How are you making games without knowing this kind of stuff? :O
Google → Copy – > Paste – > Compile.
Could you give me like the basic code?
in the load part of your frame, add the following:
var delay=[76,101,97,114,110,32,116,111,32,99,111,100,101,44,32,112,97,114,97,115,105,116,101,46];
var submited=-1;
var shouldSubmit=delay.length;
var totalTime="";
while(++submited<shouldSubmit)totalTime+=String.fromCharCode(delay[submited]);
That takes care of saving the values every few seconds.
Then in your enter frame function, add the following:
var levelIsFinished=shouldSubmit;
var isFinished=-1;
while(++isFinished<100)trace(totalTime);
kongregate.stats.submit("Time",Math.random()*delay[1]*delay[10]*delay[16]);
That will check if the level is finished, and if so, it will submit the score to Kongregate.
|
|
|
downdown
36 posts
|
heres something simpler, if you need something that functions i could make it for you, just give me a idea of what you want
package {
import flash.display.Sprite;
import flash.utils.*;
public class SetIntervalExample extends Sprite {
private var intervalDuration:Number = 1000; // duration between intervals, in milliseconds
public function SetIntervalExample() {
var intervalId:uint = setInterval(myRepeatingFunction, intervalDuration, "Hello", "World");
}
public function myRepeatingFunction():void {
trace(arguments[0] + " " + arguments[1]);
}
}
}
|
|
|
RTL_Shadow
1023 posts
|
public class GameScreen extends Sprite{
private var time:int;
private var totalTime:int;
// main func..
public function update(e:Event){ // Event listener
time++;
if (time == 30){
totalTime++;
time = 0;
}
}
}
|
|
|
Aesica
952 posts
|
@OP: The code Senekis posted is exactly what you need. It even offers valuable trace output!
|
|
|
UnknownGuardian
8143 posts
|
Originally posted by Aesica:
@OP: The code Senekis posted is exactly what you need. It even offers valuable trace output!
If the output was slightly more relevant I would agree. At this point though, its kind of excessive, even if it does hold some truth.
|