Recent

Author Topic: NEED URGENT HELP  (Read 6184 times)

olly_greenwood

  • Newbie
  • Posts: 4
NEED URGENT HELP
« on: April 26, 2016, 01:18:18 pm »
Can anyone help me create a program please. Below are the requirements for the program, i am completely stuck!!!

1. There are 2 players.
2. Each player enters their name and they take turns to play.
3. A card from a pack of playing cards is randomly chosen and displayed.
4. Player 1 has to guess if the next card to be displayed will be higher or lower than the previous card.
5. If Player 1 guesses correctly then the next card is randomly chosen and displayed.
6. If Player 1 guesses incorrectly the game moves over to Player 2.
7. The winner is the first player who reaches 5 cards by correctly guessing 4 times.
8. The winner is displayed.
9. The Player will be able to access an onscreen help system for assistance and game instruction.
 

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: NEED URGENT HELP
« Reply #1 on: April 26, 2016, 01:54:59 pm »
A deck of cards is represented as a Set in Object Pascal.

olly_greenwood

  • Newbie
  • Posts: 4
Re: NEED URGENT HELP
« Reply #2 on: April 26, 2016, 01:57:34 pm »
Im such an amateur at Lazarus, so that means nothing to me lol 

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: NEED URGENT HELP
« Reply #3 on: April 26, 2016, 02:01:42 pm »
Most forum people will only point out mistakes in what you have, not make it for you. Show what you have and explain where you are stuck.

olly_greenwood

  • Newbie
  • Posts: 4
Re: NEED URGENT HELP
« Reply #4 on: April 26, 2016, 02:03:28 pm »
So far i have this:

program PlayYourCardsRight;
uses crt,sysutils;
var Suit:array[1..4] of string;
Card:array[1..13] of string;

{--Array--}
procedure initialise;
begin
  Suit[1]:='Hearts';
  Suit[2]:='Diamonds';
  Suit[3]:='Spades';
  Suit[4]:='Clubs';
  Card[1]:='2';
  Card[2]:='3';
  Card[3]:='4';
  Card[4]:='5';
  Card[5]:='6';
  Card[6]:='7';
  Card[7]:='8';
  Card[8]:='9';
  Card[9]:='10';
  Card[10]:='Jack';
  Card[11]:='Queen';
  Card[12]:='King';
  Card[13]:='Ace';
  end;
  {---Display Menu---}
Procedure DisplayMenu (var Choice:Integer);
begin
  clrscr;
  Writeln;
  Repeat
        Writeln (' |---------------------------------|');
        Writeln (' |      Play Your Cards Right      |');
        Writeln (' |---------------------------------|');
        Writeln (' |                                 |');
        Writeln (' | 1: Play                         |');
        Writeln (' |                                 |');
        Writeln (' | 2: How to play?                 |');
        Writeln (' |                                 |');
        Writeln (' | 0: Quit                         |');
        Writeln (' |                                 |');
        Writeln (' |---------------------------------|');
        Readln(Choice);
  Until Choice<3;
end;
 {--Play--}
procedure Play;
begin
  clrscr;
  writeln ('What is Player 1s name?');
  readln
end;
 {--How to play--}
procedure HowtoPlay;
begin
  clrscr;
  writeln ('First of all you need to');
  end;       

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: NEED URGENT HELP
« Reply #5 on: April 26, 2016, 05:50:51 pm »
Most forum people will only point out mistakes in what you have, not make it for you. Show what you have and explain where you are stuck.
I'm fine with providing a full solution, but only after a donation to the community has been made.

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: NEED URGENT HELP
« Reply #6 on: April 26, 2016, 07:22:54 pm »
Alternatively to skalogryz suggestion, here is a draft of a basic game code structure if you interested to learn:

Code: Pascal  [Select][+][-]
  1. //...
  2. //...
  3.  
  4. var
  5.   Score: Integer;
  6.   isQuit: Boolean;
  7.  
  8. begin
  9.  
  10.   // Initialize variables
  11.   Score := 0;
  12.   isQuit := False;
  13.  
  14.   ShowIntroMenu;
  15.   case MenuItemSelected of
  16.     1: // ...
  17.     2: // ...
  18.     3: isQuit := True;
  19.   end;
  20.  
  21.   // Main loop
  22.   while not(isQuit) then begin
  23.     UpdateScreen;
  24.     GetUserInput;
  25.     CalculateMovement;
  26.     CalculateScore;
  27.     if (ExitClicked) or (ExitKeyPressed) then isQuit := True;
  28.     if (Score <= 0) then isQuit := True;
  29.   end;
  30.  
  31.   ShowEndingScreen;
  32.  
  33. end.

Don't simply copy/paste the code. It won't work. It just gives you the idea how to write game. Try to expand each section one-by-one, and you'll get a full working game.

Note:
You may want to add a big loop and move the main_loop into it, so there will be a main menu that will be show up to player when he/she end the game but not quit the program. Doing so is more challenging, I suggest do it only after the basic is working correctly.
« Last Edit: April 26, 2016, 07:40:27 pm by Handoko »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: NEED URGENT HELP
« Reply #7 on: April 26, 2016, 08:06:08 pm »

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: NEED URGENT HELP
« Reply #8 on: April 27, 2016, 04:51:48 am »
Yes, it's a good example of game looping with menu.

Windsurfer

  • Sr. Member
  • ****
  • Posts: 368
    • Windsurfer
Re: NEED URGENT HELP
« Reply #9 on: April 27, 2016, 10:21:45 am »
www.tutorialspoint.com is a great resource - thanks.

olly_greenwood

  • Newbie
  • Posts: 4
Re: NEED URGENT HELP
« Reply #10 on: April 28, 2016, 10:54:00 am »
Most forum people will only point out mistakes in what you have, not make it for you. Show what you have and explain where you are stuck.
I'm fine with providing a full solution, but only after a donation to the community has been made.
I will make a donation

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: NEED URGENT HELP
« Reply #11 on: April 28, 2016, 04:46:55 pm »
ahh... another economy student...
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: NEED URGENT HELP
« Reply #12 on: April 28, 2016, 07:17:29 pm »
I will make a donation
...but the donation comes first.

Here's win32 executable
PM me, if you're still interested.

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: NEED URGENT HELP
« Reply #13 on: April 28, 2016, 08:15:31 pm »
Great! It also works on my Linux. I mean using Wine of course.

 

TinyPortal © 2005-2018