High Score Lists

I am new to Java--I started learning about 2 weeks ago. I have just programmed my first game in Java, but I don't know how to make a high score list. As of now, during gameplay, the game keeps track of the user's score like this:
g.drawString("Score: " + GameState.cur.tailLength*10, 25, 30);GameState is a class. cur is an instance of GameState.
tailLength is an integer variable that keeps track of how long the tail is (the game is a snake game, where you eat food and your tail grows & scoring is 10 pts per food eaten).
If anyone has any ideas for how to make a high score list inside the java applet, I would greatly appreciate it.

You're going to need to store previous game scores somewhere (start with an ArrayList) when each game has ended. Then, you can draw then whenever you want to. Later on you can store the scores in a file or even a database.

Similar Messages

  • How can I make a high scores list?

    I've heard a lot of options. I've tried writing to a perl script, I've read about signing an applet (which seems needlessly complicated). I just would like to know what is the easiest way to save a list of 10 high scores for a game that I'm making? If anyone out there has tried this already any advice would be REALLY appreciated
    thanks!

    What I'm trying to do is make just a high scores list for the game as a whole. It will be one high scores list of 10 names/scores that will be there for the applet. I already have everything set up to read the scores and order the scores in the program, i just need to know what the best way to save them permanently for the next time they need to be used is. I have the scores saved in a string array and I could write all the code myself to get those strings set up in whatever format I may need. But I just need to know how to save them once the applet is closed.

  • Online high score list

    Hi guys,
    I was wondering how I could implement a high score list into a java applet game i wrote. The logic isnt what im worried about, its writing to a file that is on a server that i dont own. It's my school's webspace...do i have access to do this?
    If I dont have access, how would I do this, there are tons of online games with high score lists, so how do they do it?
    Appreciate the help,
    Brian

    Only you would know if you have the permission to do this!. BTW you cannot write to a file from an Applet unless it is signed.
    What I would do if I wanted to do this is, Create a webpage that has access to write to a file or database, then inside my applet use a HttpURLConnection to call this webpage with the paramaters passed along the query line:
    http://www.yourHost.com/TopScores?name=Gary&score=12345

  • Help with online high scores

    I'm working on a marathon runner game ( http://www.locopuyo.com/MarathonRunnerBeta1.zip ) just for the fun of it. What I am wondering is what the best way to make a high scores list would be.
    I have mySQL on my server, I don't know if that is the best way to do it though.
    I don't know at all how to connect files on the internet with java.
    I was thinking it might be easier if I just had a plain html web site that I could edit in my java program using ftp, but I don't know how to do that and dont' even know if it is possible.
    Any help would be much appretiated.

    since you have MySQL on your server, I'm going to go ahead and assume you have PHP installed also. If so, you can do the highscore work in PHP and just have the game query that script. Basically (if you know anything about PHP and web queries in general) you just query the URL of the PHP script with a few GETVARS. In the simplest (and most easily hacked) way is something like:
    http://yourserver.com/game/highscore.php?action=submit&name=bob&score=5000highscore.php (your script) would then use MySQL to store the data of the GETVARS ($action,$name, and $score).
    All you need in Java to query this script is the URL class.
    URL url = new URL("http://yourserver.com/game/highscore.php?action=submit&name=bob&score=5000");
    url.openConnection(); // this is where it is queriedhighscore.php is where you need to do your database work. If you don't know anything about PHP or if this sounds too easily hacked, you might look into connecting to MySQL via JDBC (see tutorial)
    If I find the time I can make a simple template for you to build off of

  • IPhone High Score Data File/Sort Oddities

    Hello all.
    I am working on an iPhone game which is nearly complete but I am having trouble with the following high score sort/write code. I am aiming to keep up to 10 scores, sorted from highest to lowest obviously.
    The code creates a new data file with the current score added as first entry if there is no existing data file (and this works), or it creates a data file with the current score as first entry if a data file exists but is empty for some reason (and this works as well), or it adds the current score to a data file of existing scores if it is within the top ten or there are less than ten entries (this is where it gets odd).
    If there is one existing score in the data file, the current score is added and sorted properly. If there are two scores in the data file, the application crashes BUT the data file shows the current score was correctly added and sorted to the existing scores. If there are three existing scores, the application crashes and the data file remains unchanged.
    I have been over the logic many times and tried many different variations of the logic structure to no avail. I suspect it is something simple but I've been staring at it too long to see. Any ideas?
    If there is a better way to display the code/formatting on the forum, please let me know. It doesn't look pretty this way and there must be a way to make it more readable here. I tried to manually format it some to help. The code follows (score variable is brought in from another class but works properly in my tests). At the end I have repeated an isolated snippet of the code where I think the problem occurs.
    *CODE START:*
    int i, ii;
    struct highscoreentry {
    NSString *name;
    int highScore;
    struct highscoreentry structArray(10);
    FILE *fin = fopen("highscore.dat", "rb");
    if (fin != NULL) { //if the data file exists proceed here
    for (i = 0; i < 10; i++) {
    if (fscanf(fin, "%s %d\n", structArray(i).name, &structArray(i).highScore) != EOF) { //if data exists for this iteration proceed
    ii = i; //ii will be the last entry of existing data
    for (i = ii; i > -1; i--) { //will begin at last entry and work up the list of scores to sort
    if (score > structArray(i).highScore) { //if current score is higher than recoded score, recorded score moves down 1 place
    structArray(i + 1) = structArray(i);
    structArray(i).name = (NSString *)"JESSE";
    structArray(i).highScore = score;
    if (i == ii && ii < 9) //if there are less than 10 entries we will add another for our new entry
    ii = ii + 1;
    else if (score < structArray(i).highScore && i == ii) { //if current score is less than last recorded score it becomes new last entry
    structArray(i + 1).name = (NSString *)"JESSE";
    structArray(i + 1).highScore = score;
    if (ii < 9)
    ii = ii + 1;
    fclose(fin);
    if (fin == NULL) { //if the data file does not exist prepare data for new file
    ii = 0; //will be used to limit write iterations to this single new entry
    structArray(0).name = (NSString *)"JESSE";
    structArray(0).highScore = score;
    FILE *fout;
    fout = fopen("highscore.dat", "wb"); //should create/rewrite data file from scratch
    for (i = 0; i <= ii; i++) {
    fprintf(fout, "%s %d\n", structArray(i).name, structArray(i).highScore);
    fclose(fout);
    *CODE END*
    As far as I can tell by commenting out different portions of the code, the problem appears to be somewhere in here:
    *CODE START:*
    if (fin != NULL) { //if the data file exists proceed here
    for (i = 0; i < 10; i++) {
    if (fscanf(fin, "%s %d\n", structArray(i).name, &structArray(i).highScore) != EOF) { //if data exists for this iteration proceed
    *CODE END*
    ...but it baffles me that this works with one structure in the data file, crashes with two structures in the data file but correctly processes/sorts them and writes the file properly, and crashes with three structures in the data file without doing any additional work.
    Jesse Widener
    www.artandstructure.com

    Actually I've found online material to be adequately, and sometimes more than adequately, elucidating in learning the language. When I decided to take a stab at this I spent about 40 hours of my spare time the first week reading 2 or 3 different "takes" on the C/C++/Objective C language in addition to Apple's docs on their implementation along with the iPhone SDK. As I mentioned, I've thus far found the language quite clear and concise. I began my application the second week and this is the first time in 7 weeks of coding where I've felt the need to ask assistance. Every other problem I've solved, leaving no errors, warnings or leaks in my software and accomplishing every task I've set to this point.
    I find reading several different "takes" on a subject helps fill out an understanding from different perspectives. In this case, one perspective might lead the reader to believe or misunderstand the full use/context of a particular syntax, while reading from multiple sources can show the same syntax used in different contexts, broadening the understanding of its use, and that understanding can be user further to interpolate uses in a variety of situations.
    I am new to C/C++/Objective C and the iPhone SDK, but I am not new to programming. It may have been some time (other than hand-coding my website the last few years) and my language experience may be limited to BASIC, HTML, PHP and Javascript, but from my view learning a new language is relatively easy once you know one...even if it is BASIC. The general logic structure remains the same. The overall software design concept remans essentially the same. Both are going to use variables, arrays, subroutines, memory allocation/management, input and output of data, runtime logic, etc. I am 80-90% sure I know exactly how I want to attack a coding problem every time...I just need to know how to "say it in C".
    I don't remember when I first started coding, but I know by age 7 I wrote a karaoke style "Happy Birthday" for my great aunt with music playing through a Commodore 16 via "beeps" figuring the particular vibrations per second of the speaker (the hertz values) and durations for each note in time and pitch perfectly along with "lyrics" printed to screen with the music. To me, learning C is like learning a new foreign language. I took 2 years of French in high school and had to study at it but aced it nonetheless. I then opted to take Spanish but after a semester I opted to stop because the pacing was too slow. Learning Spanish after learning French was a piece of cake. They are in the same general language family and the syntax construction is very similar. I only needed the raw data of the words to fit to the rules I already knew. I didn't need to learn the same rules a second time.
    The C/Objective C language seems no more complicated than it need be, which is to say it seems simple in doing what it needs to do and I am impressed with that simplicity thus far. I am also impressed with Apple's implementation with regard to the iPhone. Being able to provide music via 4-5 lines of code using AVAudioPlayer is transcendental compared to "beeping" every note monophonically.
    Apple's explanations are very clear and concise. It is just, sometimes their examples are sparse or too narrow in scope to get a rounded context. However, their docs are very good and there is a wealth of information here on the net. My biggest complaint with Apple's docs really stems from the fact they seem to want to shove Interface Builder at everything and provide the code to do so but leave the reader stranded if the reader would rather stay within XCode exclusively and do more programmatically rather than leave that much "behind the curtain" work to Interface Builder...but it is a minor complaint.
    On pointers...I do understand the use of pointers, perhaps not to the nth degree as I am just starting out, but the concept makes sense to me. I understand they are not "content" but a memory address location of the "content". I also understand why pointing to a location which is undefined or unprotected is damaging to whatever may be in that location already and to the data being pointed since it can be inadvertently overwritten my some other memory using item.
    {quote}No. The (i < 9) condition is critical. Writing to structArray[10] will crash, since structArray[9] is the end of the array. In practice such a crash might not happen right away, though. If our program's data allocation actually ended at the end of the array, the crash would be immediate. But what usually happens when we write past the end of an array is that the beginning of some other data is overwritten.{quote}
    I need to slap my forehead on this one. I know better than that. I don't know why I missed that. Too many late nights I suppose.
    {quote}(NSString*) is called a type cast in that context.{quote}
    Yes, which is why I used it to deal with the incompatible type error I thought I had at that point, but I shouldn't have assumed by appeasing the compiler I was necessarily solving the problem.
    {quote} The best I can do for now is to caution that an enquiring mind, like all virtues, can be taken too far. I think it's important to compromise and copy good models sometimes. This isn't just to avoid reinventing the wheel. Sometimes it's good to remember we only have a limited time on Earth.{quote}
    Agreed...and I don't expect to understand every nuance the first time around. I expect to at least understand how each successful line of code works in its context, but I imagine some processes will take a few times through before it "clicks" how it works in a greater context than its own, and I am all right with that. I also understand deadlines are deadlines whether they be software development or otherwise and a broad eye needs to be kept to remaining on the track forward.
    Anyway, off to my day job.
    Thank you again...I began reading up on NSDictionary and NSUserDefaults last night. Will post soon.
    Jesse Widener
    www.artandstructure.com

  • AS3 Air High Score Help

    Hello everyone, i just came here to ask how to add a high score feature in as3 for android and ios. I want it to display on the main menu of the game. Heres my main file (game.as). I am wondering how i would implement it into that? (as you can see i have tried but failed...) please point me in the right direction on this one I want it to display in a dynamic text field called "bestScore" in a movieclip called "HighScore" the instance name of HighScore is bestScore so idk lol. Im new to as3... My score is in a movieclip called "Score" and the dynamic text field is "scoreDisplay" and the instance name is "gameScore" If that helps. Heres my game.as:
    [as]
    package
              import flash.display.MovieClip;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.ui.Mouse;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.media.SoundChannel;
              import flash.net.SharedObject;
              public class Game extends MovieClip
                        static var ship:MovieClip;
                        static var healthMeter:HealthMeter;
                        static var score:Score;
                        static var highScore:HighScore;
                        static var enemyShipTimer:Timer;
                        static var gameOverMenu:GameOverMenu;
                        static var startMenu:StartMenu;
                        static var startButton:StartButton;
                        static var pauseButton:PauseButton;
                        static var playButton:PlayButton;
                        static var mainMenuButton:MainMenuButton;
                        public var currentValue:Number;
                        public var sharedObject:SharedObject;
                        public function Game()
                                  Key.initialize(stage);
                                  ship = new Ship();
                                  healthMeter = new HealthMeter();
                                  var score:Score = new Score();
                                  var highScore:HighScore = new HighScore();
                                  addChild(score);
                                  addChild(highScore);
                                  gameScore.visible = false;
                                  bestScore.visible = true;
                                  healthMeter.x = 2.5;
                                  healthMeter.y = 576;
                                  gameOverMenu = new GameOverMenu();
                                  gameOverMenu.x = 217;
                                  gameOverMenu.y = 244;
                                  addChild(gameOverMenu);
                                  gameOverMenu.visible = false;
                                  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
                                  startMenu = new StartMenu();
                                  mainMenuButton = new MainMenuButton();
                                  startButton = new StartButton();
                                  startMenu.x = 151;
                                  startMenu.y = 111;
                                  startButton.x = 93;
                                  startButton.y = 426;
                                  mainMenuButton.x = 656;
                                  mainMenuButton.y = 483;
                                  addChild(mainMenuButton);
                                  mainMenuButton.visible = false;
                                  stage.addChildAt(startMenu, 0);
                                  addChild(startButton);
                                  startMenu.visible = true;
                                  startButton.visible = true;
                                  startMenu.visible = true;
                                  startButton.addEventListener("mouseDown", newGame);
                                  mainMenuButton.addEventListener("mouseDown", mainMenu);
                                  pauseButton = new PauseButton();
                                  pauseButton.x = 896;
                                  pauseButton.y = 63;
                                  pauseButton.addEventListener("mouseDown", PauseGame);
                                  playButton = new PlayButton();
                                  playButton.x = 896;
                                  playButton.y = 63;
                                  addChild(playButton);
                                  playButton.visible = false;
                                  playButton.addEventListener("mouseDown", PlayGame);
                        static function gameOver()
                                  mainMenuButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  gameOverMenu.visible = true;
                                  enemyShipTimer.stop();
                                  for (var i in EnemyShip.list)
                                            EnemyShip.list[i].kill();
                                  ship.takeDamage(-ship.maxHealth);
                        function newGame(e:Event)
                                  addEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = false;
                                  gameScore.visible = true;
                                  addChild(pauseButton);
                                  addChild(healthMeter);
                                  addChild(mainMenuButton);
                                  enemyShipTimer = new Timer(750);
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  addChild(ship);
                                  healthMeter.visible = true;
                                  startMenu.visible = false;
                                  mainMenuButton.visible = false;
                                  startButton.visible = false;
                                  healthMeter.visible = true;
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                                  gameOverMenu.visible = false;
                                  ship.visible = true;
                                  ship.x = 367;
                                  ship.y = 542;
                                  enemyShipTimer.start();
                                  currentValue = 0;
                                  updateDisplay();
                        function mainMenu(e:Event)
                                  removeEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = true;
                                  gameScore.visible = false;
                                  removeChild(mainMenuButton);
                                  removeChild(ship);
                                  healthMeter.visible = false;
                                  startMenu.visible = true;
                                  mainMenuButton.visible = false;
                                  startButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  playButton.visible = false;
                                  ship.takeDamage(ship.maxHealth);
                                  gameOverMenu.visible = false;
                        function PauseGame(e:Event)
                                  enemyShipTimer.removeEventListener("timer", sendEnemy);
                                  stage.frameRate = 0;//
                                  pauseButton.visible = false;
                                  playButton.visible = true;
                        function PlayGame(e:Event)
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  stage.frameRate = 30;//
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                        public function Counter()
                                  reset();
                        function sendEnemy(e:Event)
                                  var enemy = new EnemyShip();
                                  stage.addChildAt(enemy, 0);
                                  addToValue(1);
                        function addToValue( amountToAdd:Number ):void
                                  currentValue = currentValue + amountToAdd;
                                  updateDisplay();
                        function setValue( amount:Number ):void
                                  currentValue = amount;
                                  updateDisplay();
                        function reset():void
                                  currentValue = 0;
                                  updateDisplay();
                        function updateDisplay():void
                                  gameScore.scoreDisplay.text = currentValue.toString();
                        function getFinalScore():Number
                                  return gameScore.currentValue;
                        public function GameOverScreen()
                                  sharedObject = SharedObject.getLocal("natdScores");
                        public function setFinalScore( scoreValue:Number ):void
                                  gameScore.text = scoreValue.toString();
                                  if (sharedObject.data.bestScore == null)
                                            sharedObject.data.bestScore = scoreValue;
                                  else if ( scoreValue > sharedObject.data.bestScore )
                                            sharedObject.data.bestScore = scoreValue;
                                  bestScore.text = sharedObject.data.bestScore.toString();
                                  sharedObject.flush();
    [/as]
    Thanks in advance
    -Ben

    hello again, i added that code to the updatedisplay function with the currentValue.toString(); because putting a number there would achieve nothing here, and it works, but it doesnt save the highest score. whatever score is the last score it puts it there, becoming like a last score than a high score feature. heres my game.as again with your help
    [as]
    package
              import flash.display.MovieClip;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.ui.Mouse;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.media.SoundChannel;
              import flash.net.SharedObject;
              import flash.text.TextField;
              public class Game extends MovieClip
                        static var ship:MovieClip;
                        static var healthMeter:HealthMeter;
                        static var score:Score;
                        static var highScore:HighScore;
                        static var enemyShipTimer:Timer;
                        static var gameOverMenu:GameOverMenu;
                        static var startMenu:StartMenu;
                        static var startButton:StartButton;
                        static var pauseButton:PauseButton;
                        static var playButton:PlayButton;
                        static var mainMenuButton:MainMenuButton;
                        public var currentValue:Number;
                        public var sharedObject:SharedObject;
                        public function Game()
                                  Key.initialize(stage);
                                  ship = new Ship();
                                  healthMeter = new HealthMeter();
                                  var score:Score = new Score();
                                  var highScore:HighScore = new HighScore();
                                  addChild(score);
                                  addChild(highScore);
                                  gameScore.visible = false;
                                  bestScore.visible = true;
                                  healthMeter.x = 2.5;
                                  healthMeter.y = 576;
                                  gameOverMenu = new GameOverMenu();
                                  gameOverMenu.x = 217;
                                  gameOverMenu.y = 244;
                                  addChild(gameOverMenu);
                                  gameOverMenu.visible = false;
                                  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
                                  startMenu = new StartMenu();
                                  mainMenuButton = new MainMenuButton();
                                  startButton = new StartButton();
                                  startMenu.x = 151;
                                  startMenu.y = 111;
                                  startButton.x = 93;
                                  startButton.y = 426;
                                  mainMenuButton.x = 656;
                                  mainMenuButton.y = 483;
                                  addChild(mainMenuButton);
                                  mainMenuButton.visible = false;
                                  stage.addChildAt(startMenu, 0);
                                  addChild(startButton);
                                  startMenu.visible = true;
                                  startButton.visible = true;
                                  startMenu.visible = true;
                                  startButton.addEventListener("mouseDown", newGame);
                                  mainMenuButton.addEventListener("mouseDown", mainMenu);
                                  pauseButton = new PauseButton();
                                  pauseButton.x = 896;
                                  pauseButton.y = 63;
                                  pauseButton.addEventListener("mouseDown", PauseGame);
                                  playButton = new PlayButton();
                                  playButton.x = 896;
                                  playButton.y = 63;
                                  addChild(playButton);
                                  playButton.visible = false;
                                  playButton.addEventListener("mouseDown", PlayGame);
                        static function gameOver()
                                  mainMenuButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  gameOverMenu.visible = true;
                                  enemyShipTimer.stop();
                                  for (var i in EnemyShip.list)
                                            EnemyShip.list[i].kill();
                                  ship.takeDamage(-ship.maxHealth);
                        function newGame(e:Event)
                                  addEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = false;
                                  gameScore.visible = true;
                                  addChild(pauseButton);
                                  addChild(healthMeter);
                                  addChild(mainMenuButton);
                                  enemyShipTimer = new Timer(750);
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  addChild(ship);
                                  healthMeter.visible = true;
                                  startMenu.visible = false;
                                  mainMenuButton.visible = false;
                                  startButton.visible = false;
                                  healthMeter.visible = true;
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                                  gameOverMenu.visible = false;
                                  ship.visible = true;
                                  ship.x = 367;
                                  ship.y = 542;
                                  enemyShipTimer.start();
                                  currentValue = 0;
                                  updateDisplay();
                        function mainMenu(e:Event)
                                  removeEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = true;
                                  gameScore.visible = false;
                                  removeChild(mainMenuButton);
                                  removeChild(ship);
                                  healthMeter.visible = false;
                                  startMenu.visible = true;
                                  mainMenuButton.visible = false;
                                  startButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  playButton.visible = false;
                                  ship.takeDamage(ship.maxHealth);
                                  gameOverMenu.visible = false;
                        function PauseGame(e:Event)
                                  enemyShipTimer.removeEventListener("timer", sendEnemy);
                                  stage.frameRate = 0;//
                                  pauseButton.visible = false;
                                  playButton.visible = true;
                        function PlayGame(e:Event)
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  stage.frameRate = 30;//
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                        public function Counter()
                                  reset();
                        function sendEnemy(e:Event)
                                  var enemy = new EnemyShip();
                                  stage.addChildAt(enemy, 0);
                                  addToValue(1);
                        function addToValue( amountToAdd:Number ):void
                                  currentValue = currentValue + amountToAdd;
                                  updateDisplay();
                        function setValue( amount:Number ):void
                                  currentValue = amount;
                                  updateDisplay();
                        function reset():void
                                  currentValue = 0;
                                  updateDisplay();
                        public function updateDisplay():void
                                  TextField(gameScore.getChildByName("scoreDisplay")).text = currentValue.toString();
                                  TextField(bestScore.getChildByName("bestScore")).text = currentValue.toString();
                        function getFinalScore()
                                  return gameScore.currentValue;
                        public function GameOverScreen()
                                  sharedObject = SharedObject.getLocal("natdScores");
                        public function setFinalScore( scoreValue:Number ):void
                                  gameScore.text = scoreValue.toString();
                                  if (sharedObject.data.bestScore == null)
                                            sharedObject.data.bestScore = scoreValue;
                                  else if ( scoreValue > sharedObject.data.bestScore )
                                            sharedObject.data.bestScore = scoreValue;
                                  bestScore.text = sharedObject.data.bestScore.toString();
                                  sharedObject.flush();
    [/as]

  • High Scores

    Hi can anyone help please -
    I'm currently making a game for an assignment, which is
    pretty much finished however I have to include a score recording
    system which will record name, score and number of hits for the top
    10 players. The scores should be held in an external text file . I
    was wondering if anyone could explain a simple way to do this, i
    know i should use getpref and setpref to create and load the text
    file, and also use some sort of list. If i use a property list i
    can have a property 'name' and its value 'score' but how would i
    add a third element, the hits. Alternatively if i use a linear
    list, one for each of name, hits and score, how would i link them
    and sort them so that the correct name hits and score display
    together. Also i should probably mention that the game currently
    has name, hits and score held in global variables.
    If anyone could point me in the right direction that would be
    great, I'd really like to understand how to get this working first
    instead of just the usual trial and error.
    thanks
    Mark

    The general tool for reading and writing text files is the
    fileIO xtra,
    implementing it involves some learning curve.
    The easy way to store user settings like high scores is the
    setPref,
    getPref functions which store text in a predefined location
    and works
    with shockwave, unlike fileIO xtra.
    The larger effort might be involved in getting the scores
    from the
    stored text version back to whatever variables scheme you
    store them in.
    value(somestring) converts a text representation of a number
    back to an
    integer or float.
    you can even store list variables as text
    x = [["bob", 123], ["Jim", 567], ["Sally", 778]]
    savePref "scoreFile", string(x)
    -- retrieved with
    x = value(getPref("scoreFile"))

  • How to manage high score file

    Hello,
    I have made i little game in CVI, in the end of the game user get a score base on the levels he passed and the level of difficulty.
    As this is a school assignment i have to have a score board. I've made score board using a table and i read arguments from a txt file.
    All I read is the name of the player and his score.
    The trouble that I'm having is to check the txt file and see if the new score of the user can be put in the score board.
    I need to known how I check if user's new score need to be put into the score txt file, and how to put it there.
    Thanks in advacne!

    Hello Slavik87!
    If I understand your question correctly, want to are asking is how to read the text file, retrieve the highest scores from it and update the file again.
    If you are asking about which functions to use, these are some functions you can use to perform the file operations:
    fopen, to open the file
    fputs, to write a string to the file
    fgets, to get a string from the file
    fseek, to navigate through the file
    fclose, to close the file
    Here are some suggestions about how you can manage the information in your text file:
    Insert each new entry (name, score) on a separate new row, optionally using separators:
    John Doe, 10
    Kelly Smith, 43
    Kevin Brown, 4
    After reading these lines from disk, you would have to store the entries in some data structures (e.g. lists, structures) for your application to manage.
    For optimization, you can also sort the rows based on the highest score, this way, when you want to retrieve the highest scores, these are already situated at the beginning of the file. However, when you update the rows, you would have to switch places of rows, when a person will have a higher score than the previous item(s).
    Best regards!
    - Johannes

  • HT4314 Temple Run 2, high score of 156 mil deleted from Game Center

    As the title describes, I last night got a high score of 156 million in Temple Run 2 and when I checked Game Center today, the game listed me as never having made a single run, and that I didn't have any score at all (my previous high score was 115 million which was on Game Center but is now also gone). I have played the game quite a bit and have completed all achievements except for the 10 million meter one.
    Does anyone have some thoughts on this?

    Yes, it's still listed within the app. It's only on Game Center that my scores are missing.

  • Whats your brickbreaker high score?

    What is everyone's brick breaker high score? 
    Please also list what OS your using.  
    My highscore is 9520 on 4.2 
    Message Edited by payroll on 04-03-2008 10:51 PM
    CEO/Editor In Cheif
    www.SmartphoneNation.com

    Can anyone tell me how to get this game back? I have the 8800

  • Making a High Score Table

    Is there a way to check if a cookie(holding the high scores)
    exists and then if it doesnt i can make a list...
    Also, would you advise using an ordinary list or a property
    list for the highscores and in what way would be best for sorting
    the list...
    thank you!!

    check out my posts here:
    http://director-online.com/forums/read.php?2,25525

  • How to save a high score?

    Hi, I almost finish a game, I get my score and just need to save it to the "highscore screen" movieclip. Basically all I want is to take my score to the high scores, which will be a list of maybe 5 scores for example, and when you get a higher score, replace the lower one with it. Anybody knows the code for that?
    Thanks in advance

    you don't need a button.
    just save the score (if it's a high one) when a game/level/whatever is complete, or even when the player's score is updated and qualifies.

  • I bought a new Iphone 4s and when I sync my apps over I lost all of my high scores. How can I get back my high scores as I do not want to start all over on some of the games

    I bought the new Iphone 4s. I backed up my old 3gs on Itunes store before trading in my old Iphone. I sync my new phone and I have all of my apps but non of the high scores. For example I played all of the angry birds and had three stars on all levels. Now I have the app on my Iphone but I am back no levels completed. How do I fix this problem. My Itunes store is on a PC running Windows 7

    Under the answer you want to mark as correct you should see a box that says Correct with a green symbol to the left and a box with Helpful with an orange star to the left. Click on the one you want.
    And thanks for thinking about that, it is appreciated.

  • How can you get back a lost high score after a partial sync?

    I was playing a Temple Run game, which I was currently getting a high score on, when I plugged it into my computer to charge. Since it was the first time I had plugged it in, the Mac asked me to do some stuff. After my iPod started to sync, everything was fine. I then had to leave, so I ejected it and left. It kept syncing until I was out of the wi-fi range and down the road. I go into Temple Run, and find my game I was playing gone. The coins weren't added, and the high score wasn't even updated. When I came home, I tried syncing it again, and the info still didn't come back. Is is possible to regain the data back? I just really want the 7 million high score back...

    Try restoring from backup.  If yu did not backup since you messed up, restoring from backup should get you back to when the backup was made. Got to iTunes>Preferences>Devices and check the box that says "Prevent iPod...syncing" otherwise when you connect, a backup will be made that does not contain the info you want.

  • Flash Game High Scores Board

    Hello everyone,
    I know this is a subject that gets covered a lot as i have found a ton of tutorials that show a million dfferent ways to create a high scores board on a flash game.  So i decided to go out on a limb and pick a tutorial out to try.  Well I have now tried 3 different ones and have yet to get a working high scores board with my game.
    http://www.flashkit.com/tutorials/Games/How_to_c-Nick_Kuh-771/index.php
    That is the link to the most recent attempts to creat my high scores board.  When i finished everything the way the tutorial said it seemed like everything would work and then it just didnt.  After spending oh about 40 plus hours trying to make a high scores board i am getting very frustrated.  My game is scripted in AS2 and i have access to mysql and can set up unlimited databases.
    Can anyone please help me by sending an easy to follow tutorial that will work with AS2?  I would just like any kind of help right now as I feel ALL of my valid ideas have been ehausted.  Thanks in advance to anyone that can help!
    kapelskic

    Okay not a problem.
    This is my code on the very first frame of the game that initializes the the highscores.php script
    command = "init";
    _root.loadVariables("highscores.php?"+int(Math.random()*100000), "POST");
    This is the code that I have on a submit button, next to the input text box where the user enters their name for the scoreboard.
    on (release) {
    if(name ne ""){
    command = "update";
    _root.loadVariables("highscores.php?"+int(Math.random()*100000), "POST");
    gotoAndStop ("highScores");
    In every place the code says _root. I have also tried this. and neither of them work.  I have also tried a million other things.  So far the game plays through, goes to the game over screen where it asks for a user name and tells them their score.  Then once they press submit the game goes to the highScores screen but the name and score are not there.  The high scores screen cosists of 2 dynamic text fields one named "players" and one named "scores".  I hope this helps because I spent another 5 or so hours after my initial posts trying more tutorials with still no luck.  (the problem i am having is that i am new to flash, however not to PHP)
    kapelskic

Maybe you are looking for

  • Amount in Local currency

    Hi,    When a document is getting posted during FI-Co reconciliation there is a minor difference of 0.01 being posted back to the vendor as a difference between the local currency 1&2(1265120.20-1265120.19).Why is this difference being posted back to

  • (need answers)oracle apps functional queries

    This is bhanu nice meeting you, recently i went to an interview there i 've faced the following queries i've answered the queries but i didn't satisfy with my brief explanations ,i need apt&elobarated answers/ reasons so in that regard i need your he

  • Photoshop CS6 crashes whenever I use font tool

    I've browsed the other discussion threads with the same problem, but I am very confused as I have limited computer knowledge. I've used the font tool on CS5 before and there was no problem, but now when I use CS6 it either crashes or it lags so much

  • I own Photoshop CS.  It will no longer activate by internet or phone.  Any suggestions?

    In June my computer crashed and when I got it back I had to reinstall Photoshop CS, activation was no longer supported by internet or phone so support provided me with the following link to download a free version of CS2: http://www.adobe.com/downloa

  • Webservice call limitations with the & character?

    Hi all, I'm trying to call a webservice from my flex application and in the url it ends with "/webservices?ver=2.1&wsdl" The error is "The reference to entity "wsdl" must end with the ';' delimiter" After some tests I found if I replace the & with ?