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 / card game help needed 2

Author
Message
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 27th Mar 2009 02:50 Edited at: 31st Mar 2009 03:20
here is where i'm at and its not very far at all.

load bitmap "cards.bmp",1
b=0
c=1
for a=0 to 12
get image c,0,b,75,(b+100)
b=b+101
c=c+1
next a
x=1:y=1:x2=76:y2=1:x3=151:y3=1:x4=201:y4=1
x5=251:y5=1:x6=301:y6=1:x7=351:y7=1:x8=401:y8=1
x9=1:y9=101:x10=51:y10=101:x11=101:y11=101:x12=151:y12=101
do
sprite 1,x,y,1:sprite 2,x2,y2,2:sprite 3,x3,y3,3:sprite 4,x4,y4,4
sprite 5,x5,y5,5:sprite 6,x6,y6,6:sprite 7,x7,y7,7:sprite 8,x8,y8,8
sprite 9,x9,y9,9:sprite 10,x10,y10,10:sprite 11,x11,y11,11:sprite 12,x12,y12,12
loop

I dont understand anything anybody says because im in highschool and ive had dark basic for a month so i need some really simple info on how to use sprites to make a game where you choose ,some how, a card then choose another and if they match then the cards disaper and if not they flip back over.
sry about my spelling and grammar.
and plz keep it really simple.

im new at this
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 27th Mar 2009 06:52
Ok, here it would be possible to "code blind".

The graphics (sprites) really are just extra.

So, if you set up an array, you can keep track of the playing field.

If you don't understand arrays, here is my explanation that I gave to some others and it helped them out:
Quote: "
Arrays are essentially variables that can hold more than a single number. They are referenced through a coordinate like numbers.

A good way to think of arrays are like filing cabinets. First you have the variable name, which is the unit itself. It can be, just like a variable, an integer, a float (containing decimals), or a string (words). The number of drawers is the first number (so dim checkdata(3) would have 3 drawers). From there, you can sub-divide each drawer with folders, for arrays, it would simply be the next number, signifying how many "folders" for each drawer.

So:
dim apples(3,2) would, to keep up the analogy, a filing cabinet with 3 drawers, and 2 folders in them (just to throw this out there, you CAN use and store data to apples(3,0) but that should only be used if it makes the code easier to read (don't go out of your way if you don't have to).

Now, since this is a computer, you can subdivide every drawer infinitely (to a point, but you will probably run out of memory before you hit the extents) as well as every folder. Inside each folder, though, is a piece of paper, which simply has a number or string (depending on the type) printed on it. This is what the value of that folder is.
"


So, if you have a 5x5 card field, you could use:

DIM playing_field(5,5)

Then, for the third card in the first row, you could store the card number by:

playing_field(3,1)=8

So that way, you choose 2 cards and then compare their number (so if card (3,1) and (2,5) are chosen, you reference playing_field(3,1) and playing_field(2,5) respectively).

Make sense?

Also, 2 important things about forum etiquette

1. Don't post your age...EVER. Yes, we are all cool people here, but it is STILL NEVER a good idea to post your age online. You can say, I am new to programming, or still in High school, but no age.

2. Enclose your code in code brackets. Just highlight it and click the code button. It will look like:




And 1 point about code tidyness (don't know if you already know this since the forums don't preserve spacing):

If you indent your code, it makes it easier for us to read, and easier for you to catch mistakes as you make them.

So, it could look like:





Now for some general comments about your code (you didn't do anything wrong, but it could be done better).

x=1:y=1:x2=76:y2=1:x3=151:y3=1:x4=201:y4=1
x5=251:y5=1:x6=301:y6=1:x7=351:y7=1:x8=401:y8=1
x9=1:y9=101:x10=51:y10=101:x11=101:y11=101:x12=151:y12=101


This section, one statement: use arrays. Using 2 arrays you could do:
Dim X(12)
Dim Y(12)

Not sure what it is for, though, so you could use a single array if it is for a playing field and just multi-dimention it like so:

DIM field(12,12) where the first number will represent the width in cards and the second is the height in cards.

And Finally:

sprite 1,x,y,1:sprite 2,x2,y2,2:sprite 3,x3,y3,3:sprite 4,x4,y4,4
sprite 5,x5,y5,5:sprite 6,x6,y6,6:sprite 7,x7,y7,7:sprite 8,x8,y8,8
sprite 9,x9,y9,9:sprite 10,x10,y10,10:sprite 11,x11,y11,11:sprite 12,x12,y12,12
loop

I usually try to stay away from multiple lines of code on one line like this. It just makes it harder to track bugs. If I were to tell you that you made a mistake on the second line, how would you know which one it was? You would have to check 4 commands to find the typo. Whereas if you put them on their own line it is easier to track.

Here is a cool thing though: you can do all of this in 3 lines if you use the X(12) and Y(12) arrays. Don't believe me? Check it out:




Hope this helps. Let me know if I can clear anything up!

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Mar 2009 15:38
"I'm only 15"
Age is no substitute for experience. You're not really supposed to put your age on the forums.

Why did you start a new thread? Did my card formulas help at all? Now I see you don't need a standard deck of playing cards but it's good to learn that kind of thinking anyway.

The Universe has been erased by a mod because it was larger
than 240x80 pixels.
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 28th Mar 2009 03:54
thanks, that helped alot.(sorry about that i was just trying to get the point across that i need detailed answers.)

im new at this
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 28th Mar 2009 04:14
do you have to use sprites at all?(should i use sprites)y/n?

im new at this
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 28th Mar 2009 04:37
"This section, one statement: use arrays. Using 2 arrays you could do:
Dim X(12)
Dim Y(12)"
how would you set the values to all the x's and y's?

im new at this
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 30th Mar 2009 18:51


im new at this
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Mar 2009 22:26
Quote: ""This section, one statement: use arrays. Using 2 arrays you could do:
Dim X(12)
Dim Y(12)"
how would you set the values to all the x's and y's?
"


Anything. Hard code it in, data statements, an outside file that is opened and the values are read in. Easiest would probably just be a subroutine called after its creation that just lists X(1)=... and so on, but keep it in a subroutine so that it is out of the way.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Mar 2009 03:40
@razer
you can edit your post by clicking the blue "Edit Post" on the bar underneath your avatar. Saves space on the thread if you add to your posts instead of double-posting before anyone has replied to you.

can't read?
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 8th Apr 2009 05:46
thanks to your guys help i finished hers my code>


im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Apr 2009 06:47
NICE! Great Work! thats pretty fun!

New Site! Check it out \/

Login to post a reply

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