Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14007

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
need help with a point system code Posted by player1245 on 24 Dec 2006 at 7:42 PM
in ne one know how to do this or have done this i would appreciate the help if you can!
thanx
Report
Re: need help with a point system code Posted by Phat Nat on 28 Dec 2006 at 6:46 PM
: in ne one know how to do this or have done this i would appreciate the help if you can!
: thanx
:

Point System? You mean a "Point of Sale" or a Central Server or??? Also, are you using Pascal for DOS or Windows?

Report
Re: need help with a point system code Posted by player1245 on 30 Dec 2006 at 9:41 PM
: : in ne one know how to do this or have done this i would appreciate the help if you can!
: : thanx
: :
:
: Point System? You mean a "Point of Sale" or a Central Server or??? Also, are you using Pascal for DOS or Windows?
:
:
pascal like a game that would reward points when you win and subtraced when u lose
Report
Re: need help with a point system code Posted by Phat Nat on 31 Dec 2006 at 1:28 AM
: : : in ne one know how to do this or have done this i would appreciate the help if you can!
: : : thanx
: : :
: :
: : Point System? You mean a "Point of Sale" or a Central Server or??? Also, are you using Pascal for DOS or Windows?
: :
: :
: pascal like a game that would reward points when you win and subtraced when u lose
:

You would just use a variable to hold the point data. If you are looking to have the score continue on when a game is loaded at a different time, write the score into a file and load that file when the game is first opened.

Here's an example of gaining and losing points by pressing 'W' & 'L'. The program stores the points into a file in the C:\ directory called 'SCORES.DAT'.

USES Crt, Dos;
VAR
   Score : LongInt;

PROCEDURE Win;
Begin
     Inc(Score);
End;

PROCEDURE Lose;
Begin
     If Score > 0 Then Dec(Score);
End;

PROCEDURE LoadScore;
VAR T : Text;
Begin
     Assign(T,'C:\SCORE.DAT'); 
     {$I-} Reset(T); {$I+}
     If IOResult <> 0 Then Exit;
     ReadLn(T,Score);
     Close(T);
End;

PROCEDURE SaveScore;
VAR T : Text;
Begin
     Assign(T,'C:\SCORE.DAT'); Rewrite(T);
     WriteLn(T,Score);
     Close(T);
End;

VAR
   Key : Char;

Begin
     LoadScore;
     Repeat
           Key := Upcase(Readkey);
           Case Key Of
             'L' : Lose;
             'W' : Win;
           End;
     Until Key = #27;
     SaveScore;
End.


Hope this answers your question
Phat Nat

Report
Re: need help with a point system code Posted by player1245 on 1 Jan 2007 at 2:46 PM
: : : : in ne one know how to do this or have done this i would appreciate the help if you can!
: : : : thanx
: : : :
: : :
: : : Point System? You mean a "Point of Sale" or a Central Server or??? Also, are you using Pascal for DOS or Windows?
: : :
: : :
: : pascal like a game that would reward points when you win and subtraced when u lose
: :
:
: You would just use a variable to hold the point data. If you are looking to have the score continue on when a game is loaded at a different time, write the score into a file and load that file when the game is first opened.
:
: Here's an example of gaining and losing points by pressing 'W' & 'L'. The program stores the points into a file in the C:\ directory called 'SCORES.DAT'.
:
:
: USES Crt, Dos;
: VAR
:    Score : LongInt;
: 
: PROCEDURE Win;
: Begin
:      Inc(Score);
: End;
: 
: PROCEDURE Lose;
: Begin
:      If Score > 0 Then Dec(Score);
: End;
: 
: PROCEDURE LoadScore;
: VAR T : Text;
: Begin
:      Assign(T,'C:\SCORE.DAT'); 
:      {$I-} Reset(T); {$I+}
:      If IOResult <> 0 Then Exit;
:      ReadLn(T,Score);
:      Close(T);
: End;
: 
: PROCEDURE SaveScore;
: VAR T : Text;
: Begin
:      Assign(T,'C:\SCORE.DAT'); Rewrite(T);
:      WriteLn(T,Score);
:      Close(T);
: End;
: 
: VAR
:    Key : Char;
: 
: Begin
:      LoadScore;
:      Repeat
:            Key := Upcase(Readkey);
:            Case Key Of
:              'L' : Lose;
:              'W' : Win;
:            End;
:      Until Key = #27;
:      SaveScore;
: End.
: 

:
: Hope this answers your question
: Phat Nat
:
:
thanks that helped alot



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.