Results 1 to 10 of 15

Thread: Glitch on my game

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Thanks User137 and Will for your time , and i knew there was the function inc() but forgot bout it D:

  2. #2
    After changing Inc in your code to Income the game seems to work for me. I belive there is a bug in your game thou. Everytime I increased my security one of the prisoners escaped. I tried tracking this bug but had no luck. The reason for this is that your code is badly organized. Or atleast it sems to me likeway.
    So here are some recomendations for beter code organization.
    1. When creatung procedures, functions etc. try to use selfexplanatory names and not etc and etc1.
    2. Try to avoid writing same code in multiple parts of your program. You can do this by moving parts of code wich repeat several times into procedures. This wil make your code more readable and wil save you some time for not needint to type same code multiple types.
    3. When using if conditional clauses you can check for multiple parameters if needed. Below is part of your code where you are checking the value for rnd1 and if it is either 1 or 2 you then cal virtualy the same code.
    Code:
    if (rnd1 = 1) then
    begin
        clrscr;
        turn := turn + 1;
        etc1;
        repeat
            write(pris,
              ' prisoners are hungry. Feed them? (Y/N): ');
            readln(key);
            key := upcase(key);
        until (key = 'Y') or (key = 'N');    if (key = 'N') then
        begin
            stats := stats - 2;
            writeln('--------------------------------------');
            writeln('The prisoners are not satisfied for today!');
            writeln('Unsatisfied prisoners count: ', stats);
        end;
        if (key = 'Y') then
        begin
            stats := stats + 2;
            writeln('--------------------------------------');
            writeln('Good job! the prisoners are fullfiled for today!');
            bank := bank - 150;
            writeln('-150 cash');
            writeln('Satisfied prisoners count: ', stats);
            bank := bank + income;
            etc;
        end;
    end;
    if (rnd1 = 2) then
    begin
        turn := turn + 1;
        clrscr;
        etc1;
        repeat
            write(pris - 1,
              ' prisoner is hungry. Feed him? (Y/N): ');
            readln(key);
            key := upcase(key);
        until (key = 'Y') or (key = 'N');
        if (key = 'N') then
        begin
            stats := stats - 1;
            writeln('--------------------------------------');
            writeln('The prisoner is not satisfied for today!');
            writeln('Unsatisfied prisoners count: ', stats);
        end;
        if (key = 'Y') then
        begin
            stats := stats + 1;
            writeln('--------------------------------------');
            writeln('Good job! the prisoners are fullfiled for today!');
            bank := bank - 100;
            writeln('-100 cash');
            writeln('Satisfied prisoners count: ', stats);
            bank := bank + income;
            etc;
        end;
    end;
    This could be fixed by using one if clause and checking for two parameters like this:
    Code:
    if (rnd1 = 1) or (rnd1 = 2) then
    begin
        clrscr;
        turn := turn + 1;
        etc1;
        repeat
            write(pris,
              ' prisoners are hungry. Feed them? (Y/N): ');
            readln(key);
            key := upcase(key);
        until (key = 'Y') or (key = 'N');
        if (key = 'N') then
        begin
            stats := stats - 2;
            writeln('--------------------------------------');
            writeln('The prisoners are not satisfied for today!');
            writeln('Unsatisfied prisoners count: ', stats);
        end;
        if (key = 'Y') then
        begin
            stats := stats + 2;
            writeln('--------------------------------------');
            writeln('Good job! the prisoners are fullfiled for today!');
            bank := bank - 150;
            writeln('-150 cash');
            writeln('Satisfied prisoners count: ', stats);
            bank := bank + income;
            etc;
        end;
    end;
    EDIT:
    @Will
    The code button is only available in Advanced mode for posting reply and not for quick reply mode. Could this be changed?

    @smexhy
    You can acces advanced post mode first by clicking reply inder the post and then on Go Advanced button below the text box.
    Last edited by SilverWarior; 07-04-2012 at 08:32 AM.

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Quote Originally Posted by SilverWarior View Post
    The code button is only available in Advanced mode for posting reply and not for quick reply mode. Could this be changed?
    Sadly no, but then again, I think that was the point of the difference between quick reply and advanced. at least all you need to do is square bracket the word "code".

    It may be possible to set yuorself to always Go Advanced. I can't be sure unless I look it up myself though.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4
    After searching a bit I found a thread that say it is posible to add aditional buttons to quick reply. So since this is a programer forum I think having CODE button would be useful.
    The lik to a thread: https://www.vbulletin.com/forum/show...ighlight=quick

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •