Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help me on my card game plox <3
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Otaku1211




PostPosted: Sat Jan 21, 2012 3:30 pm   Post subject: Help me on my card game plox <3

What is it you are trying to achieve?
Trying to finish this card game by sunday night :/ i'm not very good at turing and only in grade 10, this game is called 66 and for those who dont know what it is basically you just need to get 66 points before the other player. You play with 20 cards (aces, kings, queens, jacks, 10s). Ace=11points, 10=10points, King=4,queen=3,jack=2. so you play a card and the player 2 plays one whoever has the higher card gets both cards and the points. Ace>10>King>Queen>Jack is the order of the card then the suit order is the same; spade>hearts>clubs>diamonds.


What is the problem you are having?
I dont know how to get the gameplay part


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


    var WelcomeTo : array 1 .. 10 of string := init ("W", "e", "l", "c", "o", "m", "e", " ", "T", "o")
    var exitinstructions := 0
    var PlayRow : int := 0
    var PlayColumn : int := 0
    var PlayCounter : int := 0
    var PlayCounter2 : int := 0
    var ReplayRow : int := 0
    var ReplayColumn : int := 0
    var ReplayCounter : int := 0
    var ReplayCounter2 : int := 0
    var Replay : int := 0
    var playbutton : int := 0
    var CardCounter : string
    var CardCounter2 : string
    var CardBack : int := 0

    %play and instructions buttons
    setscreen ("Graphics")
    colorback (black)
    loop
        Draw.Text (WelcomeTo (1), maxx div 2 - 100, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (2), maxx div 2 - 65, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (3), maxx div 2 - 45, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (4), maxx div 2 - 35, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (5), maxx div 2 - 15, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (6), maxx div 2 + 10, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (7), maxx div 2 + 45, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (8), maxx div 2 + 60, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (9), maxx div 2 + 80, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (100)
        Draw.Text (WelcomeTo (10), maxx div 2 + 95, maxy div 2, Font.New ("ComicSans:30:bold"), brightred)
        delay (250)
        locate (40, 35) %Run window must be set to max row 40

        delay (100)
        %play and instructions buttons
        for text : 1 .. 25
            Draw.Text ("66 (Schnapsen)", maxx div 2 - 175, maxy div 2 - 100, Font.New ("ComicSans:40:bold"), Rand.Int (1, maxcolour))
            delay (200)
        end for
        Draw.Text ("66 (Schnapsen", maxx div 2 - 175, maxy div 2 - 100, Font.New ("ComicSans:40:bold"), black)
        colourback (white)
        put "By: Anon"
        drawbox (100, 140, 274, 200, black)
        Draw.Text ("Play", 140, 160, Font.New ("ComicSans:30:bold"), brightred)
        drawbox (350, 140, 654, 200, black)
        Draw.Text ("Instructions", 390, 160, Font.New ("ComicSans:30:bold"), brightred)
        exitinstructions := 0
        loop
            if Mouse.ButtonMoved ("down") then
                Mouse.ButtonWait ("down", PlayRow, PlayColumn, PlayCounter, PlayCounter2)
                if PlayRow >= 350 and PlayRow <= 654 and PlayColumn >= 140 and PlayColumn <= 200 then
                    cls
                    put "1. If you have not so, please drag the media file out to the dexktop and re-run"
                    put "this program"
                    put ""
                    put "2. Press 'Play' to start the game"
                    put ""
                    put "3. Cards will be dealt to both players"
                    put ""
                    put "4. You must get 66 points before the computer to win points"
                    put ""
                    put "5. Scores are not recorded"
                    put ""
                    put "6. This is a point-trick game"
                    put ""
                    put "7. If the winner's opponent has taken 33+ points, winner gets 1 point; "
                    put " If winner's opponent has taken 1-32 points, winner gets 2 points; "
                    put " If the winner's opponents has taken 0 points, winner gets 3 points "
                    put ""
                    put "8. Once you have 7 points, you win"
                    drawbox (350, 140, 564, 200, black)
                    Draw.Text ("Back", 390, 160, Font.New ("ComicSans:30:bold"), brightred)
                    loop
                        if Mouse.ButtonMoved ("down") then
                            Mouse.ButtonWait ("down", PlayRow, PlayColumn, PlayCounter, PlayCounter2)
                            if PlayRow >= 350 and PlayRow <= 564 and PlayColumn >= 140 and PlayColumn <= 200 then
                                exitinstructions := 1
                                exit
                            end if
                        end if
                    end loop
                elsif PlayRow >= 100 and PlayRow <= 274 and PlayColumn >= 140 and PlayColumn <= 200 then
                    playbutton := 1
                    exit
                end if
            end if
            if exitinstructions = 1 then
                exit
            end if
        end loop
        cls
        if playbutton = 1 then
            exit
        end if
    end loop

   
    %DEALING CARDS(FINAL)

    var DeckCheck : array 1 .. 20 of boolean
    var RandomCard : int := 0
    var CardPic : int := 0
    var CardPicture : string
    %Player One Card Number
    var PlayerOneCardOneCardNumber : int := 0
    var PlayerOneCardTwoCardNumber : int := 0
    var PlayerOneCardThreeCardNumber : int := 0
    var PlayerOneCardFourCardNumber : int := 0
    var PlayerOneCardFiveCardNumber : int := 0
    var PlayerOneCardSixCardNumber : int := 0
    %Player One Card Picture
    var PlayerOneCardOnePicture : string
    var PlayerOneCardTwoPicture : string
    var PlayerOneCardThreePicture : string
    var PlayerOneCardFourPicture : string
    var PlayerOneCardFivePicture : string
    var PlayerOneCardSixPicture : string
    %Player One Card Number
    var PlayerTwoCardOneCardNumber : int := 0
    var PlayerTwoCardTwoCardNumber : int := 0
    var PlayerTwoCardThreeCardNumber : int := 0
    var PlayerTwoCardFourCardNumber : int := 0
    var PlayerTwoCardFiveCardNumber : int := 0
    var PlayerTwoCardSixCardNumber : int := 0
    %Player One Card Picture
    var PlayerTwoCardOnePicture : string
    var PlayerTwoCardTwoPicture : string
    var PlayerTwoCardThreePicture : string
    var PlayerTwoCardFourPicture : string
    var PlayerTwoCardFivePicture : string
    var PlayerTwoCardSixPicture : string
    %------------------------------------
    %Deck Restore
    for DeckRestore : 1 .. 20
        DeckCheck (DeckRestore) := true
    end for
    %Dealing Cards
    for count : 1 .. 12
        loop
            CardPic := 0
            RandomCard := Rand.Int (1, 20)
            exit when DeckCheck (RandomCard) = true
        end loop
        DeckCheck (RandomCard) := false
        loop
            if RandomCard > 5 then
                RandomCard := RandomCard - 5
                CardPic := CardPic + 1
            end if
            exit when RandomCard < 6
        end loop
        if CardPic = 0 then
            CardPicture := "Diamond"
        elsif CardPic = 1 then
            CardPicture := "Clubs"
        elsif CardPic = 2 then
            CardPicture := "Heart"
        elsif CardPic = 3 then
            CardPicture := "Spade"
        end if
        if count = 1 then
            %Player One Card One
            PlayerOneCardOneCardNumber := RandomCard
            PlayerOneCardOnePicture := CardPicture
        elsif count = 2 then
            %Player One Card Two
            PlayerOneCardTwoCardNumber := RandomCard
            PlayerOneCardTwoPicture := CardPicture
        elsif count = 3 then
            %Player One Card Three
            PlayerOneCardThreeCardNumber := RandomCard
            PlayerOneCardThreePicture := CardPicture
        elsif count = 4 then
            %Player One Card Four
            PlayerOneCardFourCardNumber := RandomCard
            PlayerOneCardFourPicture := CardPicture
        elsif count = 5 then
            %Player One Card Five
            PlayerOneCardFiveCardNumber := RandomCard
            PlayerOneCardFivePicture := CardPicture
        elsif count = 6 then
            %Player One Card Six
            PlayerOneCardSixCardNumber := RandomCard
            PlayerOneCardSixPicture := CardPicture
            %-----------------------------------------------------------------------
        elsif count = 7 then
            %Player Two Card One
            PlayerTwoCardOneCardNumber := RandomCard
            PlayerTwoCardOnePicture := CardPicture
        elsif count = 8 then
            %Player Two Card Two
            PlayerTwoCardTwoCardNumber := RandomCard
            PlayerTwoCardTwoPicture := CardPicture
        elsif count = 9 then
            %Player Two Card Three
            PlayerTwoCardThreeCardNumber := RandomCard
            PlayerTwoCardThreePicture := CardPicture
        elsif count = 10 then
            %Player Two Card Four
            PlayerTwoCardFourCardNumber := RandomCard
            PlayerTwoCardFourPicture := CardPicture
        elsif count = 11 then
            %Player Two Card Five
            PlayerTwoCardFiveCardNumber := RandomCard
            PlayerTwoCardFivePicture := CardPicture
        elsif count = 12 then
            %Player Two Card Six
            PlayerTwoCardSixCardNumber := RandomCard
            PlayerTwoCardSixPicture := CardPicture
        end if
    end for
    put "Player One Cards"
    put PlayerOneCardOneCardNumber, " of ", PlayerOneCardOnePicture
    put PlayerOneCardTwoCardNumber, " of ", PlayerOneCardTwoPicture
    put PlayerOneCardThreeCardNumber, " of ", PlayerOneCardThreePicture
    put PlayerOneCardFourCardNumber, " of ", PlayerOneCardFourPicture
    put PlayerOneCardFiveCardNumber, " of ", PlayerOneCardFivePicture
    put PlayerOneCardSixCardNumber, " of ", PlayerOneCardSixPicture


    put "Player Two Cards"
    put PlayerTwoCardOneCardNumber, " of ", PlayerTwoCardOnePicture
    put PlayerTwoCardTwoCardNumber, " of ", PlayerTwoCardTwoPicture
    put PlayerTwoCardThreeCardNumber, " of ", PlayerTwoCardThreePicture
    put PlayerTwoCardFourCardNumber, " of ", PlayerTwoCardFourPicture
    put PlayerTwoCardFiveCardNumber, " of ", PlayerTwoCardFivePicture
    put PlayerTwoCardSixCardNumber, " of ", PlayerTwoCardSixPicture

    %Gameplay
   
    %Drawing a Card
   
    procedure draw
        var DrawCardNumber : int := 0
        var DrawCardPicture : string

        for DeckRestore : 1 .. 20
            DeckCheck (DeckRestore) := true
        end for

        CardPic := 0
        loop
            RandomCard := Rand.Int (1, 20)
            exit when DeckCheck (RandomCard) = true
        end loop
        DeckCheck (RandomCard) := false
        loop
            if RandomCard > 5 then
                RandomCard := RandomCard - 5
                CardPic := CardPic + 1
            end if
            exit when RandomCard < 6
        end loop
        if CardPic = 0 then
            CardPicture := "Diamond"
        elsif CardPic = 1 then
            CardPicture := "Clubs"
        elsif CardPic = 2 then
            CardPicture := "Heart"
        elsif CardPic = 3 then
            CardPicture := "Spade"
        end if

        DrawCardNumber := RandomCard
        DrawCardPicture := CardPicture

        put "You have drawn the ", DrawCardNumber, " of ", DrawCardPicture

    end draw

    %play again
    Draw.Text ("Play again?", 260, 560, Font.New ("ComicSans:30:bold"), brightred)
    drawbox (100, 140, 274, 200, black)
    Draw.Text ("Yes", 140, 160, Font.New ("ComicSans:30:bold"), brightred)
    drawbox (400, 140, 554, 200, black)
    Draw.Text ("No", 450, 160, Font.New ("ComicSans:30:bold"), brightred)
    loop
        if Mouse.ButtonMoved ("down") then
            Mouse.ButtonWait ("down", ReplayRow, ReplayColumn, ReplayCounter, ReplayCounter2)
            if ReplayRow >= 100 and ReplayRow <= 274 and ReplayColumn >= 140 and ReplayColumn <= 200 then
                Replay := 1
                exit
            elsif ReplayRow >= 400 and ReplayRow <= 554 and ReplayColumn >= 140 and ReplayColumn <= 200 then
                cls
                exit
            end if
        end if
    end loop
    cls
    exit when Replay = 0
end loop
cls
drawfillbox (0, 0, maxx, maxy, white)



Please specify what version of Turing you are using
4.1.1a
Sponsor
Sponsor
Sponsor
sponsor
Alex C.




PostPosted: Sat Jan 21, 2012 3:37 pm   Post subject: RE:Help me on my card game plox <3

oh hi, it's a double post Razz

um why didn't you post on your old one, it would pop in the same place...

anyways, try randint for the opponents cards (randint: 1 ..total cards in hand) and once you get the players card...

if opponent card > player card
opponent points+= opponent card + player card

vice versa for player

if opponent card= player card
if opponent suite> player suite... yeah you should get it now Razz
Otaku1211




PostPosted: Sat Jan 21, 2012 3:57 pm   Post subject: RE:Help me on my card game plox <3

:c i didnt know i could repost on that one :/ lol im still very new to this so sorryy!! D:

and thank you soo much!! it really helped me Very Happy but now it says there's a problem with my procedure :/ like it says "may only be declared at a program, module or monitor level
Alex C.




PostPosted: Sat Jan 21, 2012 4:24 pm   Post subject: RE:Help me on my card game plox <3

um don't put the procedure in aloop, it will glitch out...

a programs format should be soemthing like this:

1) All your varaibles
2) Processes and stuff
3) your main program
Otaku1211




PostPosted: Sat Jan 21, 2012 4:35 pm   Post subject: RE:Help me on my card game plox <3

okay thanks man, really helping out Smile uh last question (hopefully)

so if i want to make player one hand do i use array?

so like

var hand1: array 1..6 of ... (and so)
if i do use array, how do i put

(these are the player on cards)
put "Player One Cards"
put PlayerOneCardOneCardNumber, " of ", PlayerOneCardOnePicture
put PlayerOneCardTwoCardNumber, " of ", PlayerOneCardTwoPicture
put PlayerOneCardThreeCardNumber, " of ", PlayerOneCardThreePicture
put PlayerOneCardFourCardNumber, " of ", PlayerOneCardFourPicture
put PlayerOneCardFiveCardNumber, " of ", PlayerOneCardFivePicture
put PlayerOneCardSixCardNumber, " of ", PlayerOneCardSixPicture

into it?

or if i don't use arrays, what do i use? :c
Alex C.




PostPosted: Sat Jan 21, 2012 5:36 pm   Post subject: RE:Help me on my card game plox <3

well 20 cards in total means that 10 cards per player right?

well there would be an array of 20 for the deck (which you would declare card names and suites and such) and 10 per player.

randint could decide the value for the players hands suppsedly (player1card:= jackhearts)

hopefully this helps
Otaku1211




PostPosted: Sat Jan 21, 2012 8:48 pm   Post subject: RE:Help me on my card game plox <3

yeah i've got how to do it now thanks alex! Very Happy last question then i think i should be set

so for the array when i do this:
var cards : flexible array 1 .. 20 of string := init ("ace of hearts", "ace of spades", "ace of diamonds",
"ace of clubs", "king of hearts", "king of spades", "king of diamonds", "king of clubs",
"queen of hearts", "queen of spades", "queen of diamonds", "queen of clubs",
"jack of hearts", "jack of spades", "jack of diamonds", "jack of clubs",
"ten of hearts", "ten of spades", "ten of diamonds", "ten of clubs",)

i get the array of cards and i then this:
randint (random, 1, 20)

to get a random number and i've coded it so it responds do the array, but after i get the number and which card it is, is there a way to take it out of the array?
Alex C.




PostPosted: Sat Jan 21, 2012 10:09 pm   Post subject: Re: Help me on my card game plox <3

...you could reset it to no value ( := 0 or another value ) and put something in your code that completely ignores that card if it has that card in a players hand i guesss... : Thinking Praying
Sponsor
Sponsor
Sponsor
sponsor
Otaku1211




PostPosted: Sun Jan 22, 2012 5:55 pm   Post subject: Re: Help me on my card game plox <3

Ok so i did a little work but i'm kind of stuck again now

when i play a card and then draw another card I need the draw card to replace the card used :/ please help me!! it's due tomorrow ):

I attached my new code, please help me!



HelpmePlox.t
 Description:

Download
 Filename:  HelpmePlox.t
 Filesize:  47.55 KB
 Downloaded:  72 Time(s)

Alex C.




PostPosted: Sun Jan 22, 2012 6:45 pm   Post subject: RE:Help me on my card game plox <3

nice so far Very Happy,

first off, whats the locate (40,35) for? it sorta screws it up cause of the window size

also oddly, when player 1 won around against 2p, he won no points (p1=13 and p2 card= 1)

finally, idiot proof the program (if card= 7 put you don't have that card)
Otaku1211




PostPosted: Sun Jan 22, 2012 7:11 pm   Post subject: RE:Help me on my card game plox <3

well the (40,35) is where I put my name like by:_____ ______ and yeah i'm not done the point system yet

I still need to find a way to replace the card the player uses with the card the player draws :/

and good idea for the idiot proof part Very Happy thanks!
Alex C.




PostPosted: Sun Jan 22, 2012 7:48 pm   Post subject: RE:Help me on my card game plox <3

... try a rand.int within a loop to check random cards until it chooses one that hasn't been played yet
Otaku1211




PostPosted: Sun Jan 22, 2012 8:01 pm   Post subject: RE:Help me on my card game plox <3

no i mean like i draw a card then when both players are done their turn, i cls then retype the new hand for both players with the card played last turn replaced with the new card which they drew but i can't get that into code :/
Alex C.




PostPosted: Sun Jan 22, 2012 8:17 pm   Post subject: Re: Help me on my card game plox <3

Eh for blablabl
if cardused (blah)= true
card (blah):= new card
end for

...try something like that Thinking
Otaku1211




PostPosted: Sun Jan 22, 2012 10:11 pm   Post subject: RE:Help me on my card game plox <3

Woot I got it to work, but used a different way, but yours helped me think of the new way Very Happy SO THANK YOU VERY MUCH ALEX! Very Happy I'm almost done now!

just got to fix up a few bugs and add a few more parts then i can go sleep! Very Happy thank you so much for your assistance alex! really helped me out on this project!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: