|
4 registered members (JimSimons, TipmyPip, 3run, 1 invisible),
15,917
guests, and 1
spider. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
1 of my highscore field didnt refresh after updating
#216614
07/17/08 20:58
07/17/08 20:58
|
Joined: Jun 2008
Posts: 91
Coisox
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2008
Posts: 91
|
Please download this small code (but long to post here). [DOWNLOAD] When I enter new record and save into .txt file, everything is ok except 1 of the field didn't refresh. If I quit and reload the game, the highscore is up to date. I tried something like this but still no luck: 0. Display Highscore Using Panel <-- here is the problem1. Game load 2. Load highscore.txt 3. Prompt for new record 4. Bubble sort 5. Save into highscore.txt 6. Load highscore.txt <-- I hope this can solve my problem but still not ok
|
|
|
Re: 1 of my highscore field didnt refresh after updating
[Re: Coisox]
#216641
07/18/08 01:32
07/18/08 01:32
|
Joined: Aug 2005
Posts: 1,230
MichaelGale
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,230
|
I tried something like this: 0. Helping others <-- here is the problem1. Open the thread 2. Read the post 3. Search for code that can be fixed <-- This could help, but it's not there
Your friendly mod is at your service.
|
|
|
Re: 1 of my highscore field didnt refresh after updating
[Re: Coisox]
#216717
07/18/08 12:45
07/18/08 12:45
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,032
Croatia
|
he tried to say that your question is odd and that we cant help you with only that kind of explanation. give us more details and part of the code where is the error.
Ubi bene, ibi Patria.
|
|
|
Re: 1 of my highscore field didnt refresh after updating
[Re: croman]
#216730
07/18/08 14:01
07/18/08 14:01
|
Joined: Jun 2008
Posts: 91
Coisox
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2008
Posts: 91
|
The code is too long. So I have to put a download link (on my 1st post) to my code. Ok, here's my code which is very ugly. I'm not sure which part is the error but must has something to do with how I use pointer (this is my 1st time using pointer). It's better for you to download the code and open using ur compiler:
#include <acknex.h>
#include <default.c>
var GameLevel = 9;
var GameElapsed = 0;
FONT* fontHighScore = "Arial#20b";
STRING* PlayerName = "#40";
STRING* HOF_Name_00 = "Anonymous";
STRING* HOF_Name_01 = "Anonymous";
STRING* HOF_Name_02 = "Anonymous";
var HOF_Level[3];
var HOF_Elapsed[3];
PANEL* HallOfFame =
{
layer = 3;
digits (50, 50, HOF_Name_00, fontHighScore, 0, 0);
digits (50, 70, HOF_Name_01, fontHighScore, 0, 0);
digits (50, 90, HOF_Name_02, fontHighScore, 0, 0);
digits (400, 50, "%03.0f", fontHighScore, 1, HOF_Level[0]);
digits (400, 70, "%03.0f", fontHighScore, 1, HOF_Level[1]);
digits (400, 90, "%03.0f", fontHighScore, 1, HOF_Level[2]);
digits (500, 50, "%06.0f secs", fontHighScore, 1, HOF_Elapsed[0]);
digits (500, 70, "%06.0f secs", fontHighScore, 1, HOF_Elapsed[1]);
digits (500, 90, "%06.0f secs", fontHighScore, 1, HOF_Elapsed[2]);
flags = VISIBLE;
}
TEXT* InputName =
{
layer = 4;
pos_x = 50;
pos_y = 500;
font = fontHighScore;
string (PlayerName);
flags = VISIBLE;
}
function HOFRead()
{
var filehandle;
filehandle = file_open_read("hs_name.txt");
file_str_read(filehandle,HOF_Name_00);
file_str_read(filehandle,HOF_Name_01);
file_str_read(filehandle,HOF_Name_02);
file_close(filehandle);
filehandle = file_open_read("hs_level.txt");
var temp0; for (temp0=0; temp0<3; temp0++) HOF_Level[temp0] = file_var_read(filehandle);
file_close(filehandle);
filehandle = file_open_read("hs_elapsed.txt");
var temp0; for (temp0=0; temp0<3; temp0++) HOF_Elapsed[temp0] = file_var_read(filehandle);
file_close(filehandle);
}
function HOFWrite()
{
var filehandle;
filehandle = file_open_write("hs_name.txt");
file_str_write(filehandle,HOF_Name_00);
file_str_write(filehandle,",");
file_str_write(filehandle,HOF_Name_01);
file_str_write(filehandle,",");
file_str_write(filehandle,HOF_Name_02);
file_close(filehandle);
filehandle = file_open_write("hs_level.txt");
var temp0; for (temp0=0; temp0<3; temp0++) file_var_write(filehandle,HOF_Level[temp0]);
file_close(filehandle);
filehandle = file_open_write("hs_elapsed.txt");
var temp0; for (temp0=0; temp0<3; temp0++) file_var_write(filehandle,HOF_Elapsed[temp0]);
file_close(filehandle);
}
function HOFUpdate()
{
// bubble sort
//=============================================================
STRING* tempName;
var tempLevel;
var tempElapsed;
var temp0;
var pass;
for(pass=0; pass<3; pass++)
{
for (temp0=2; temp0>0; temp0--)
{
if (HOF_Level[temp0] > HOF_Level[temp0-1] || (HOF_Level[temp0] == HOF_Level[temp0-1] && HOF_Elapsed[temp0] < HOF_Elapsed[temp0-1]) )
{
tempLevel = HOF_Level[temp0-1];
tempElapsed = HOF_Elapsed[temp0-1];
switch (temp0)
{
case 1:
tempName = HOF_Name_00;
HOF_Name_00 = HOF_Name_01;
HOF_Name_01 = tempName;
break;
case 2:
tempName = HOF_Name_01;
HOF_Name_01 = HOF_Name_02;
HOF_Name_02 = tempName;
break;
}
HOF_Level[temp0-1] = HOF_Level[temp0];
HOF_Elapsed[temp0-1] = HOF_Elapsed[temp0];
HOF_Level[temp0] = tempLevel;
HOF_Elapsed[temp0] = tempElapsed;
}
}
}
HOFWrite();
}
function HOFEnterNewRecord()
{
HOF_Elapsed[2] = GameElapsed;
result = inkey(PlayerName); // wait until [enter] pressed]
HOF_Name_02 = PlayerName;
HOF_Level[2] = GameLevel;
HOFUpdate();
}
function HOFCheckQualify()
{
if (GameLevel > HOF_Level[2] || (GameLevel == HOF_Level[2] && GameElapsed < HOF_Elapsed[2])) HOFEnterNewRecord();
}
function main()
{
video_mode = 8;
video_window(nullvector,nullvector,1,NULL);
vec_set(screen_color,vector(128,128,128));
HOFRead();
wait(-2);
GameElapsed = 999;
HOFCheckQualify();
}
|
|
|
|