Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / DBC - Need some help on a routine for a card game

Author
Message
gearce
18
Years of Service
User Offline
Joined: 18th Dec 2006
Location: ex SCOTLAND, now MELBOURNE, Australia
Posted: 10th Apr 2009 03:20
I have the basis for a card game (matching pairs) I am writing whereby, once a match has been made, the cards are removed from the play area.

However, I need some help with a routine so that, once the cards have been removed from the playing area, they cannot be reselected.

Any help would be much appreciated.

Also, I have a flashing text routine and would be interested in any variation.




Thanks
gearce
(GRC)

LANG MEY YER LUM REEK

You must be the change you wish to see in the world
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Apr 2009 05:48
Haven't seen you around for a while
I would make an array that stores all the cards dealt on the table and whether these cards have been paired.

totally blind coding there so fingers crossed

can't read?
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 10th Apr 2009 06:27
btw, to hide old text u dont need a box, just use SET TEXT OPAQUE, then ur background color (color after , in INK command) will become a filled box behind the text, hiding nething behind it

There are only 10 kinds of people in the world, those who understand binary and those who dont
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Apr 2009 06:34
errm just ignore my code theres a million errors in it
got it working but too tired to edit

can't read?
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Apr 2009 11:09
Quote: "btw, to hide old text u dont need a box, just use SET TEXT OPAQUE, then ur background color (color after , in INK command) will become a filled box behind the text, hiding nething behind it"


That works, usually, though, I find it best to just use sync and cls in the loop so that you can just redraw everything like so:



Note that if you put the cls and the sync in a different order, you WILL get nothing but a black screen. Why? Because it clears the screen, then displays it, rather than displaying it then clearing it.

I would agree with obese, though, as far as your question goes.

An array like this:

DIM Field(XCards,Ycards)

where XCards and Ycards are the total number of cards horizontally and vertically, respectively. Then, when a card is selected, it is set from 0 to 1. If it is paired, set it to 2 (or you could do 1, but overlap can make bug testing problematic sometimes). So, when clicking, you just check if the card being clicked (referenced in the array by its "coordinates") is 0, then select it and set its value to 1. Once both cards are selected, if they are the same card, set the value to 2.

Make sense?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 10th Apr 2009 16:48
with cls is from wat ive been told, it forces a sync of some kind, slowing the program down a good bit if you put it in a loop

There are only 10 kinds of people in the world, those who understand binary and those who dont
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Apr 2009 22:23
CLS doesn't force a sync in DBC. I think it does in Pro though.

Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 10th Apr 2009 23:07
o, well ok then

There are only 10 kinds of people in the world, those who understand binary and those who dont
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Apr 2009 03:15
@gearce
Quote: "Also, I have a flashing text routine and would be interested in any variation"


This uses a function that switches the text between 2 colors. You set the time in milliseconds and you position the text with x and y.

This is one case where the static nature of local function variables is very useful (for keeping track of the value of tim and toggle.)



Enjoy your day.
gearce
18
Years of Service
User Offline
Joined: 18th Dec 2006
Location: ex SCOTLAND, now MELBOURNE, Australia
Posted: 11th Apr 2009 08:59
Thanks for your input chaps.

Much appreciated


gearce
(GRC)

LANG MEY YER LUM REEK

You must be the change you wish to see in the world

Login to post a reply

Server time is: 2025-08-08 20:42:33
Your offset time is: 2025-08-08 20:42:33