News:

Function Finder  Find all the functions within source code files

Main Menu

My Current Project - Tiny FrogWare Euchre

Started by TinyFrogWare, January 07, 2009, 05:19:39 PM

Previous topic - Next topic

TinyFrogWare

 This is just a couple of screenshots from my latest project, a Euchre card game. Without going into the actual rules of Euchre, it is a game with 4 players, with the players pairing up to make two teams. The object of the game is to win tricks. In the game you as the player will be teamed up with the computer player directly across from you and the remaining two computer players form the other team.

I currently have the logic and new game setup and the ability to deal a new hand correctly. The first screenshot shows the cards being dealt at the start of a new game, to determine the initial dealer. The first player to be dealt a Jack of any suit is the dealer to start the game. The second screenshot simply shows 5 cards being dealt to each of the players, with the human players cards showing faceup.

Although it may not look like much from the screenies, alot of work goes into something that appears at first easy, like a card game. But that's far from the truth as coding card games require just as much thought and work as arcade type games. I was initially going to rewrite my two solitaire games in PB but I've been wanting to write this one for a while now and decided it would be best to start from scratch anyway to get comfortable with PB.

  In any case, just wanted to share and let everyone know that I'm putting my copy of PB to use. Absolutely love the language and have a ton of ideas and games to write with it. :) I'll update this thread as I progress further along.

  I'm currently coding this in PB 1.64c but really want to use PBFX but ran into some issues with the images being distorted when they were rotated under PBFX which I'll post some example code in another thread in the appropriate forum illustrating the problem.

Thanks,

  Tony.

micky4fun

Hi TinyFrogWare

From the pics the card game looks good , i must admit i have never heard of Euchre , but i have played trumps many of a time , which is a trick winning game as you well may know .
I know that card games must be pretty complicated to program , making sure the same card does not come out twice if using one deck and so on if using 2 or more decks , the the problem of determing the winning hands ,
as it happens in a game or 2 time of mine im looking for a simple program method of picking a random mumber between say 1 and 50 doing this say 6 times without the same number coming out twice , i wonder if you can help me with this? , and help would be great.

i have not tried PBFX yet as i have gone along with Kevins thoughts that if you are still getting to grips with PB 1.64c then PBFX maybe a little to hard to master , but the program does look good , no problem for you though as i can see you are well up on all this , i must go along with you that PB is a great language to use.
ok TinyFrogWare good luck with this project , look forward to updates

mick :)

TinyFrogWare

Hey Mick,

  Thanks for your message. I love trick type card games and especially Euchre. Hopefully you will give it a try when it's finished as I think you would enjoy it. Keeping track of the cards is definitely a challenge and then you have the AI logic to deal with, which is always a problem no matter what style of game you're writing. And Euchre ups the challenge since you play with a computer team mate and have to make sure that the computer doesn't trump his own partner, etc. A challenge to program, but fun nontheless.  :) If you like, check out my site in my sig and give my two solitaire games a try. Unfortunately I wrote them before discovering PB but I plan on rewriting them using PB as I have a ton of ideas to improve them with all that PB has to offer.

  I'm pretty comfortable with PB, but only because of my experience with programming in general. I'm happy with PB but I do see that PBFX is even better....if that's possible which is why I want to use it for all my work. Anyway, I digress.

  Here's a sample program that shows how I shuffle a deck using random numbers. I commented the code pretty heavily, but if you have questions, just ask. :) It basically shuffles a 52 element array 10 times to ensure a good distribution without the same number coming up. I hope it helps and is something you can use.

  BTW, keep up the great work. You really underestimate your ability Mick. I'm looking forward to seeing your fruity game progress.

  Anyway, take care and enjoy the code. :)


; PROJECT : RandNum
; AUTHOR  : Tony Jones
; CREATED : 1/7/2009
; EDITED  : 1/7/2009
; ---------------------------------------------------------------------

// Require variable declarations
EXPLICIT

// An array for a deck of cards.
DIM Deck(52)

// Loop Counter
GLOBAL Count

// Call the routine to shuffle the deck.
ShuffleDeck()

// Now print out the first 26 values in the Deck array.
FOR Count=0 TO 25
PRINT Deck(Count)
NEXT Count

// Wait for a key press.
PRINT "Press a key to continue."

// Show the output
SYNC

// Wait for a keypress.
WAITKEY

// Flush any keys.
FLUSHKEYS

// Clear the screen to black.
CLS RGB(0,0,0)

// Now print out the last 26 values in the Deck array.
FOR Count=26 TO 51
PRINT Deck(Count)
NEXT Count

// Wait for a key press and exit
PRINT "Press a key to exit."

// Show the output
SYNC

// Wait for a keypress
WAITKEY

// Exit the program.
END

// Shuffles an array of cards using the RND function.
FUNCTION ShuffleDeck()

LOCAL Counter,Counter2,RandNum,Temp

// Initialize the deck
// Arrays are 0 based so 0-51 gives us 52 cards
FOR Counter=0 TO 51
Deck(Counter)=Counter
NEXT Counter

// Now shuffle the cards
// This routine basically loops 10 times, shuffling all 52 cards
// each time to ensure that we get the best shuffled deck possible
// each time.
FOR Counter=0 TO 9
FOR Counter2=0 TO 51
// Generate a random number from 0 to 51 inclusive
RandNum=RND(51)
// Save the current card into a temp variable.
Temp=Deck(Counter2)
// Now get the card based on the RandNum from above
// and move it to a different location in the deck. This is
// where the actual card shuffle happens.
Deck(Counter2)=Deck(RandNum)
// Finally place the card that is in the Temp variable
// in the location specified by the RandNum from above.
Deck(RandNum)=Temp
NEXT Counter2
NEXT Counter

ENDFUNCTION


 

Juha Kämäräinen

Looking good Tony. :)

I thought it was poker not Euchre. Havent heard of it neither.
Im not much of Coder.. Since PB is my first try, but i know something about art.
I dont know what is the card size in pixels, but if its not of the 2x ratio it might cause some scaling...
Like 39pixels wide 119pixels tall image.

I dont really know, just a wild guess.. Kevin will answer i think.

Wanna try creating the cards with 3D textured face?.. Card is simple enough for PB 3D power



Check out my comic - Bujercon 1

TinyFrogWare

#4
Thanks Falcor_

  It seems like I'm just the opposite.....I can code pretty good, but my art skills aren't quite as good as I would like. The cards themselves are 71x96, so that could be the issue. It would be no problem though to use images that are bigger/smaller, etc. since I use a constant in my code to define the size of the card, so it would just be a matter of changing two lines to use cards of different sizes. I'll experiment with the size and see how that works under PBFX, otherwise I'll hack together a quick example if that doesn't solve it.

  As for the cards themselves, I definitely want to spice them up and not just have them look like everyone elses. That's also the reason for using PB, since it gives me the power to do all these neat things. If you have any tips on designing some 3D textured cards I would love to hear them. I wouldn't even need a full deck, since Euchre uses only 24 cards Ace through Nine of each of the 4 suits and then the 5 card from each suit which is used to keep the score for each of the teams.
Thanks,

  Tony.

reno

Quote
really want to use PBFX but ran into some issues with the images being distorted when they were rotated under PBFX

I didn't notice bugs in this situation. Did you check this with an auto-middle-handle and an image sprite with a power of 2 ?
More games ? Go to my website :)
http://www.thereeteam.com/

TinyFrogWare

Quote from: reno on January 08, 2009, 08:00:56 AM
I didn't notice bugs in this situation. Did you check this with an auto-middle-handle and an image sprite with a power of 2 ?

I do have auto middle handle, but as you and Falcor_ suggested, I think the problem is because my images are 71x96 and thus not a power of 2. I'll make a test run later today to confirm that.

Thanks,

  Tony.

micky4fun

Hey TinyFrogWare

Fantastic , many thanks for posting program for me , just what im looking for , with this i can adjust random number for how many i need then pick how many out of that random number i want , thanks again great stuff

i will look at your card games on your site tomorrow at work , ive been tapping away all day today as it was my day off work , hours fly by , but code is slow , lots of trial and error , but getting along ok at moment.

hope you get your sprite problem sorted out , with help from other members

all the best mick :)

TinyFrogWare

Hey Mick,

  Glad to help out and that you can use the code. Looking forward to seeing your next project. :)

Take care,

  Tony.

kevin

QuoteI'm currently coding this in PB 1.64c but really want to use PBFX but ran into some issues with the images being distorted when they were rotated under PBFX which I'll post some example code in another thread in the appropriate forum illustrating the problem.

   It's possible the texture size, also have you turned Filtering OFF ?   SpriteFilter ThisSprite,OFF   That will certainly blur the finer detail of such images.

TinyFrogWare

Quote from: kevin on January 08, 2009, 09:40:37 PM
   It's possible the texture size, also have you turned Filtering OFF ?   SpriteFilter ThisSprite,OFF   That will certainly blur the finer detail of such images.

I tried turning filtering off, but the images were still distorted. I really think it's the texture themselves that are the problem. The card back sprites display just fine, it's the front of the cards that get distorted. I'm going to experiment with different sizes and even come up with some entirely different images to use and see if that makes a difference. I'm thinking it will. :)

Juha Kämäräinen

Quote from: TinyFrogWare on January 09, 2009, 02:16:56 AM
Quote from: kevin on January 08, 2009, 09:40:37 PM
   It's possible the texture size, also have you turned Filtering OFF ?   SpriteFilter ThisSprite,OFF   That will certainly blur the finer detail of such images.

I tried turning filtering off, but the images were still distorted. I really think it's the texture themselves that are the problem. The card back sprites display just fine, it's the front of the cards that get distorted. I'm going to experiment with different sizes and even come up with some entirely different images to use and see if that makes a difference. I'm thinking it will. :)

Im out of ideas. Are the both card sides applied the same way?

Replace the art to the back side of the card.. just reverse the art
Then you know if its a code bug or art bug. Thats the end of my knowledge!
Check out my comic - Bujercon 1