Card game for ISU (HELP)
Author |
Message |
Otaku1211
|
Posted: Thu Jan 19, 2012 5:11 pm Post subject: Card game for ISU (HELP) |
|
|
What is it you are trying to achieve?
I'm trying to create the game 66 or Schnapsen :/ I'm sure most people don't know about it, but I hope that those who do can help?
What is the problem you are having?
Well I don't know how to deal the cards, like I have a code and I have saved a pic to represent the card but it gives me an error :/ I just did the parts that I knew, and just threw it all together , so it's kind of all over the place.. but does anyone know how to deal the cards and improve my draw card? (it works fine for like 4-5 draws then it starts needing the user to input "draw" or "Draw" multiple times >_> and it's due next monday, so if a quick explaination or maybe an example code is possible please tell me!
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
loop
%Game Variables
var AD : int := 11
var AH : int := 11
var ACl : int := 11
var AS : int := 11
var TD : int := 10
var TH : int := 10
var TC : int := 10
var TS : int := 10
var KD : int := 4
var KH : int := 4
var KC : int := 4
var KS : int := 4
var QD : int := 3
var QH : int := 3
var QC : int := 3
var QS : int := 3
var JD : int := 2
var JH : int := 2
var JC : int := 2
var JS : int := 2
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
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"), green)
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"), green)
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"), green)
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"), green)
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"), green)
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 Deck : array 1 .. 20 of int
var DeckCheck : array 1 .. 20 of boolean
var RandomCard : int := 0
var CardPic : int := 0
var CardPic1 : string
var CardNumber : int := 0
var DrawCard : string
var Card : string
%Shuffling Deck
for DeckRestore : 1 .. 20
Deck (DeckRestore ) := DeckRestore
DeckCheck (DeckRestore ) := true
end for
%Player variables
var PlayerCardOne : int := 0
var PlayerCardTwo : int := 0
var PlayerCardThree : int := 0
var PlayerCardFour : int := 0
var PlayerCardFive : int := 0
var PlayerCardSix : int := 0
var P_CardOneNumber : int := 0
var P_CardTwoNumber : int := 0
var P_CardThreeNumber : int := 0
var P_CardFourNumber : int := 0
var P_CardFiveNumber : int := 0
var P_CardSixNumber : int := 0
%P2 CPU variables
var PlayerTwoCardOne : int := 0
var PlayerTwoCardTwo : int := 0
var PlayerTwoCardThree : int := 0
var PlayerTwoCardFour : int := 0
var PlayerTwoCardFive : int := 0
var PlayerTwoCardSix : int := 0
var P2_CardOneNumber : int := 0
var P2_CardTwoNumber : int := 0
var P2_CardThreeNumber : int := 0
var P2_CardFourNumber : int := 0
var P2_CardFiveNumber : int := 0
var P2_CardSixNumber : int := 0
%Winning
var Player2Won : int := 0
var Player1Won : int := 0
setscreen ("graphics:1000;600")
%CardBack
CardBack := Pic.FileNew ("back-blue-75-2.bmp")
CardBack := Pic.Scale (CardBack, 100, 150)
%Shuffling Deck
for DeckRestore : 1 .. 20
Deck (DeckRestore ) := DeckRestore
DeckCheck (DeckRestore ) := true
end for
%Dealing First Set of Cards
for Count : 1 .. 12
loop
RandomCard := Rand.Int (1, 20)
exit when DeckCheck (RandomCard ) = true
end loop
DeckCheck (RandomCard ) := false
CardCounter2 := natstr (RandomCard )
CardCounter := CardCounter2 + ".jpg"
if Count = 1 then
PlayerCardOne := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P_CardOneNumber := RandomCard
elsif Count = 2 then
PlayerCardTwo := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P_CardTwoNumber := RandomCard
elsif Count = 3 then
PlayerCardThree := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P_CardThreeNumber := RandomCard
elsif Count = 4 then
PlayerCardFour := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P_CardFourNumber := RandomCard
elsif Count = 5 then
PlayerTwoCardOne := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P2_CardOneNumber := RandomCard
elsif Count = 6 then
PlayerTwoCardTwo := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P2_CardTwoNumber := RandomCard
elsif Count = 7 then
PlayerTwoCardThree := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P2_CardThreeNumber := RandomCard
elsif Count = 8 then
PlayerTwoCardFour := Pic.FileNew (CardCounter )
loop
if RandomCard > 13 then
RandomCard := RandomCard - 13
CardPic := CardPic + 1
end if
exit when RandomCard < 14
end loop
if RandomCard = 10 then
RandomCard := - 10
elsif RandomCard = 11 or RandomCard = 12 then
RandomCard := 0
end if
P2_CardFourNumber := RandomCard
end if
end for
%Show Player One Cards
PlayerCardOne := Pic.Scale (PlayerCardOne, 100, 150)
Pic.Draw (PlayerCardOne, 200, 50, picCopy)
PlayerCardTwo := Pic.Scale (PlayerCardTwo, 100, 150)
Pic.Draw (PlayerCardTwo, 350, 50, picCopy)
PlayerCardThree := Pic.Scale (PlayerCardThree, 100, 150)
Pic.Draw (PlayerCardThree, 500, 50, picCopy)
PlayerCardFour := Pic.Scale (PlayerCardFour, 100, 150)
Pic.Draw (PlayerCardFour, 650, 50, picCopy)
%Show Player Two Cards
PlayerTwoCardOne := Pic.Scale (PlayerTwoCardOne, 100, 150)
Pic.Draw (PlayerTwoCardOne, 200, maxy - 170, picCopy)
PlayerTwoCardTwo := Pic.Scale (PlayerTwoCardTwo, 100, 150)
Pic.Draw (PlayerTwoCardTwo, 350, maxy - 170, picCopy)
PlayerTwoCardThree := Pic.Scale (PlayerTwoCardThree, 100, 150)
Pic.Draw (PlayerTwoCardThree, 500, maxy - 170, picCopy)
PlayerTwoCardFour := Pic.Scale (PlayerTwoCardFour, 100, 150)
Pic.Draw (PlayerTwoCardFour, 650, maxy - 170, picCopy)
%Hide Cards For Player One
Pic.Draw (CardBack, 200, 50, picCopy)
Pic.Draw (CardBack, 350, 50, picCopy)
Pic.Draw (CardBack, 500, 50, picCopy)
Pic.Draw (CardBack, 650, 50, picCopy)
%Hide Cards For Player Two
Pic.Draw (CardBack, 200, maxy - 170, picCopy)
Pic.Draw (CardBack, 350, maxy - 170, picCopy)
Pic.Draw (CardBack, 500, maxy - 170, picCopy)
Pic.Draw (CardBack, 650, maxy - 170, picCopy)
%Drawing a Card
loop
CardPic := 0
put "Enter 'Draw' To draw"
get DrawCard
if DrawCard = "Draw" or DrawCard = "draw" then
%Creating Random DrawCards
RandomCard := Rand.Int (1, 20)
if DeckCheck (RandomCard ) = true then
DeckCheck (RandomCard ) := false
put RandomCard
loop
if RandomCard > 5 then
RandomCard := RandomCard - 5
CardPic := CardPic + 1
end if
exit when RandomCard < 6
end loop
CardNumber := RandomCard
if CardNumber = 0 then
Card := "Ace"
elsif CardNumber = 1 then
Card := "Jack"
elsif CardNumber = 2 then
Card := "Queen"
elsif CardNumber = 3 then
Card := "King"
elsif CardNumber = 4 then
Card := "10"
end if
%Card Picture
if CardPic = 0 then
CardPic1 := "Diamond"
elsif CardPic = 1 then
CardPic1 := "Club"
elsif CardPic = 2 then
CardPic1 := "Heart"
elsif CardPic = 3 then
CardPic1 := "Spade"
end if
put "You have drawn the card: ", Card, " of ", CardPic1
put "--------------------------------------------------"
end if
end if
end loop
%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

|
|
 |
Alex C.
|
|
|
|
 |
Tony

|
Posted: Thu Jan 19, 2012 10:00 pm Post subject: Re: Card game for ISU (HELP) |
|
|
Otaku1211 @ Thu Jan 19, 2012 5:11 pm wrote: (it works fine for like 4-5 draws then it starts needing the user to input "draw" or "Draw" multiple times >_>
code: |
loop
CardPic := 0
put "Enter 'Draw' To draw"
get DrawCard
if DrawCard = "Draw" or DrawCard = "draw" then
%Creating Random DrawCards
RandomCard := Rand.Int (1, 20)
if DeckCheck (RandomCard) = true then
|
I'm sure that when you play with real cards, when you want to draw, you just grab a single card from the top, and that's it.
It seems silly to code it in a way where after a "draw", a player picks a random card from a different deck, then searches the first deck to see if the same card had been taken or not. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
Beastinonyou

|
Posted: Fri Jan 20, 2012 8:37 am Post subject: Re: Card game for ISU (HELP) |
|
|
I would also, highly recommend looking into using arrays |
|
|
|
|
 |
Alex C.
|
Posted: Fri Jan 20, 2012 8:52 am Post subject: RE:Card game for ISU (HELP) |
|
|
oh he knows how to use arrays, i just don't know why he isn't using them :/ |
|
|
|
|
 |
Velocity

|
Posted: Wed Jan 25, 2012 12:39 am Post subject: RE:Card game for ISU (HELP) |
|
|
he knows how to use init arrays, not normal ones. |
|
|
|
|
 |
Dreadnought
|
Posted: Wed Jan 25, 2012 1:07 am Post subject: Re: Card game for ISU (HELP) |
|
|
There is no such thing as an "init array". "init" is short for initialization, it allows you to give an initial value, know at compile time, to a array. Other than the initial value of the array there is no difference.
I believe what velocity means is that the only array used is static. It may as well be declared as a constant since its values do not change.
What I suggest to Otaku1211 is to read up about for loops and arrays and try to see how they can be used in unison to easily do repetitive tasks.
Here's a tutorial on for loops.
Here's a tutorial on arrays.
And here's a link to the Turing Walkthrough, a great compilation of tutorials for Turing. |
|
|
|
|
 |
|
|