Cards DS

If you are considering making a game, post your thoughts for community critique before you start.

Cards DS

Postby Nobody » June 2nd, 2011, 7:16 pm

Basically, the game will operate like a deck of cards. Someone can make or find some sprites for all 52 cards of a normal deck and make them into objects and stuff. Then we could make controllers that control different types of card games like speed, solitaire, hearts, go fish, rummy, trash, tonk, bs, ers, and so on. We could use arrays to keep track of who has which cards, and which cards are where. Does this sound like a nice little project, and would anyone be interested in this project?
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby YoshiInAVoid » June 2nd, 2011, 7:46 pm

Games like this are possible, but the logic for the DS to play against you uses very comlicated math. If your using 4.9 I could try and find the source for this:
http://www.dsgamemaker.com/forum/viewto ... =57&t=6328
I know I have it somewhere...

But anyway, heres the sprites:
Image

See where you can get with them.

Good luck.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby Nobody » June 3rd, 2011, 1:48 am

Ok, i'll attempt something with this, and thanks for the sprites. Okay, my first question has to deal with the card array. Okay let's say that we draw a random card from all the cards that i own, how would i do this in such a way that it searches for a random card i have? I know i can set to select a card at random easily, but i was wondering if there was an easier way if it picks a card i don't have, to set it to another random card without having to say like "If card[23] is equal to false (if i don't have that card), then set CardSelector to random (look for another card)." with that, i'm thinking it will cause problems and may take a while for the DS to finally pick a card you have. Any suggestions? To start out with i might just try something easy like black jack.

Also, do you have any poker chip sprites? They go with cards and i can make an in game currency using them.

EDIT: Ok with a little free time i got to work on this project a little bit. I put in some simple code that does math to check which card number/name, suit, color, and value. Basically all it is, is a card reader. It's not much code at all to read, most of the code is just outputting text. The math functions help save loads of time and space so i don't have to tell it what card it is for each and every 52 cards in a deck one by one. Tap the card to pick a random card. Tap the up button to scroll to the next card in order, and press down to move down the cards in order. Let me know what you think so far.
Attachments
card reader.dsgm
card reader nds
(129.01 KiB) Downloaded 45 times
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby YoshiInAVoid » June 3rd, 2011, 3:27 pm

I don't have DSGM5, please provide me a compiled nds file. But from what you say you have accived, it sounds brilliant! Keep it up!

As for your help. You will need a malloc. I would also reccommend structs if you are happy and confident to use them. So to declare a struct with a malloc in:

typedef struct {
u8 Amount;
int *Card;
} CardStruct;
CardStruct Hand = {
(Put how many cards you start with),
(int*)malloc(sizeof(int)Hand.Amount)
};

This means that you will be able to have Hand.Card[Number] and be able to call any Number from 0 to whatever amount it, but remember to keep updating the size of the malloc Card by using:

Set Variable Hand.Card = (int*)malloc(sizeof(int)Hand.Amount)

In a step event.

Now this means that, if you pick up a card, you can have this code:

Set Variable Hand.Amount to Hand.Amount+1

And then:

Set Variable Hand.Card[Hand.Amount-1] to PA_RandMinMax(Your chosen parameters)

This will add another slot in what seems like an array, and is basically the same thing, but is handled differently by the DS, and is called a malloc, then it will find the new slot it has just added, we use -1 because don't forget that the first slot is actually numbered at 0, and it will set it to a random card.

I hope this will help you! And good luck. I am happy to help you, and hope that this game you are making turns out ok.

As for the sprites, no I can't make them sorry, those cards I sent you where made by someone else on the old forum, I belive it was metallkakarot's brother, but I can't remember his user name, it's something like AmazingGaming or something, I belive.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby Nobody » June 3rd, 2011, 3:42 pm

Ok thanks. I'll try the above out later after i implement some easier stuff first and build up. Also, i meant to upload the NDS file, but i guess i uploaded the wrong thing on accident. :oops:

Since you can't see the code because you don't use DSGM 5.12, do you want me to upload the code here?
Attachments
card reader.nds
card reader
(521.06 KiB) Downloaded 41 times
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby YoshiInAVoid » June 3rd, 2011, 3:50 pm

Ok, so I tried out your demo and it's pretty sweet I must say. Your off to a cracking start!

Yeah, so, bugs so far:

-When you boot it, the defult value is always 4 of hearts.

That is all. Fixes so far:

-Make the defult value PA_RandMinMax

That is all.

No I do not see the need in viewing your code just yet, but if you do have any problems implementing structs then I'll install version 5 just for you. I've been meaning to for a while now, with over 500 posts on a forum about a particular version of a software, I feel bad about not even having it installed. It means that most of my posts are just arguing with people, or just rubbish that no one wants to read, human generated SPAM if you will.

Yes, that explains everything, I'm a spam bot, generated to SPAM the DSGM forum! It all makes sence!
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby Nobody » June 3rd, 2011, 3:58 pm

Ok, i'll fix that. It's not an error like you said, but there was just no code to do it. I'll implement it now. As far as structs, i've used them for the first time working on "The Living Dead' when trying to do a save system. So i think i might understand how to do it, but i'm not sure if the save system worked in "The Living Dead" because it wouldn't play on my DS and then i took it out and it still wouldn't play. Could you try rewording the struct though. Like on the first line name the variable, on the second line name the struct, and then the next lines name the struct subdivisions. This would be more clearly to understand for me
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby Nobody » June 3rd, 2011, 8:44 pm

I need your help background scrolling yoshi. I just never works right for me anymore
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby YoshiInAVoid » June 3rd, 2011, 10:36 pm

Isn't thier an action for it?

Just declare two variables, X and Y, you could use bitshifts with them if you wanted. And scroll to them. You got it working in the living dead, so I fail to see your problem. Compile error, or does it glitch up, or not work well, or not scroll at all? Are you scrolling the right layer? Etc. PM me the source or post it here if your happy to.

Also, why do you need scrolling for a card game?

Oh and about structs, I don't understand what you mean, add in blank lines so as to be spaced out more, and clearer, and comment on it, is that what you mean?

Well here is how to declare a struct, a typedef as it's just easier and simpler:

typedef struct {
Variables;
} Name of struct;

So for variables first we put the type, EG: int, u8, s8, u16, s16, char and so on. Then the name, EG: Health, well you get the point. And the name of the struct, this can be anything, but no spaces, it can't start with a number and so on. I always like putting "Struct" at the end, so I know it's the struct, but you don't have to. So, heres that example again:

typedef struct {
u8 Amount;
int *Card;
} CardStruct;

This means, everything that is set to CardStruct will have an Amount variable attached to it, and malloc integer called "Card".

Now you need to add something that will actually use the struct, for instance the players hand will need the things in the struct we just declared:

CardStruct Hand;

So now, everything in CardStruct has been assigned to a new thing called "Hand", so Hand will have the Amount and Card variables within it, EG: Hand.Amount and Hand.Card.

But, that is not all. This trick Cilein taught me, big thanks to him. We can now assign defult values to all the varaibles that Hand holds. To do this, before the semi colon, we put an "=", and then these little things "{" and "}", this is also how you add in defult values to Arrays, if you have ever used them. We seperate the values with a comma, and we put the values in order that they are declared, EG:

CardStruct Hand = {
5,
(int*)malloc(sizeof(int)5)
};

I like to let each thing have it's own line as it's neeter, but it will work all on one line. So basically is will give Hand.Amount a starting value of 5, and then Hand.Card will have the size of 5, it's different because it's a malloc, I will get to those later in another post.


So I hope this explanation helps, not just Nobody, but anyone else who needed help with this.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby Nobody » June 4th, 2011, 4:17 am

As of scrolling, it glitches out. It's puts black spots on the background when scrolling. It's for extra effect in rooms so it isn't just a dull background. Here's the code:
Code: Select all
If Variable,scrollx;==;0
Start Block
Set Variable,scrolly;191
End Block
If Variable,scrollx;==;255
Start Block
Set Variable,scrollx;0
End Block
Set Variable,scrollx;scrollx + 1
Set Variable,scrolly;scrolly - 1

As for the struct i meant put it in a fashion like this.
Struct Name: Card_Sctruct
Struct parts: Card_One, Card_Card_Two, Cards_In_Hand
Variable: Cards

EDIT: I'll be on a cruise starting in like 8 hours i'll be heading there. It's a week long, and internet is expensive on them, so don't expect to see me showing up this coming week.
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby YoshiInAVoid » June 4th, 2011, 9:27 am

Backgrounds must be multiples of 256 both ways, so something like 512X512 should work, but if its 512X384 it will NOT work.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby Nobody » June 4th, 2011, 1:15 pm

It's a standard 256 by 192. Is that a problem?
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby YoshiInAVoid » June 4th, 2011, 1:44 pm

Yes indeed it is a problem, if you want to scroll it up and down, you must have the background's Y a multiple of 256, so just expand the size to 256.

If your trying to scroll a background up and down that is 192, what do you expect it should scroll to, all that you have in the background, has already been shown, there is no more data for it to read.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby Nobody » June 12th, 2011, 2:52 am

I'm back everyone, and for the record I had fun :) . And for the background scrolling, i kinda figured. I tried it while i was gone on vacation and it worked. I didn't read your post before i left, but it seemed likely that the 192 pixel size was the problem since every time i scrolled a background bigger than 192 it worked correctly, and when i didn't i didn't scroll correctly. As far as progress on the game, i made some more minor adjustments to the card reader and put it in the game. To give it some actual gameplay i started out buy implementing some simple card games which didn't take long except for the third one i added because i kept on screwing up something, anyways it should be working fine but i'm making some more tweaks right now. Anyways, I need help on two things. One, how to do a matching game because i can't get it to work right. Second, i need help with doing the AI for keeping track of the cards, because i don't get what you were saying above.
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby Nobody » June 12th, 2011, 4:31 am

I decided to post what i did manage to do on the game with the little free time i did. It's nothing much, just an interactive deck that could be more interactive, and three simple card games(some with different difficulties).

The first is which card, where you guess what kind of card will the next one be, sorta like "what number am i thinking off". The second game is high or low, your basic higher of lower game where guess if the next card will be higher or lower then than previous card value (Ace is highest). Last but not least the last game I installed was black jack. It should be fully functional and work properly, except for the computer when it comes to one scenario. Aces automatically change value according to your situation, but when it comes to the computer if it uses the ace as an 11 and go over and doesn't change until it already declares a winner. I'll try to fix this later, but it works for the player but not the computer, so it works in your favor. The computer tends to bust a lot too when I play, so maybe i might make the AI a little more conservative and or riskier like an actual person by using more variables to decide if he hits or not. I'm not sure if this is true, but last time I play black jack with my friends i think the said if you get both black jacks then you automatically win. I'm not sure if this is true, so could someone let me know and then i can add it if so.

As far as glitching goes when first loading a room or when reloading a room(you reload a room when you tell it to play again) it might declare winners already and call the game over. I'm not sure what's gong on with problem, but i'll try to fix this. Let me know what you think, and tell me what kind of card games would you like to see on it.
Attachments
Cards DS.nds
Version 1.0 (Latest)
(749.06 KiB) Downloaded 44 times
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby pomdave » June 23rd, 2011, 12:53 pm

Hi guys,

forgive me for butting in your thread...

Being a complete DSGM noob I like to learn by example so I took the card reader.dsgm that nobody posted earlier, coz it is a card based game that I am trying to achieve (don't worry all the sprites and stuff will be changed when/if I finish)

So I copied your single card deck object and made a second instance, so now I have a pair of decks randomly choosing cards on click.

I am now trying to get my head round how to setup a dealing routine, i.e. (randomly) dividing one deck of cards between two, rather than the current situation I have which is two full deck of cards that choose a random card each.

Do you know if there are any examples of this kind of logic anywhere that I can look at to see how it works.

Thanks heaps
pomdave
 
Posts: 33
Joined: June 23rd, 2011, 7:50 am
Location: Australia

Re: Cards DS

Postby Nobody » June 24th, 2011, 12:21 am

I don't think there is an example of this Out there yet, because if I would have found it I would have added more complex card games. I have a theory that should work but I haven't tested and am not sure how well it will work. I don't know code so I know no good way about this
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082 (latest project!)
The Living Dead - viewtopic.php?f=13&t=1582
Mario Craft - viewtopic.php?f=8&t=1736 (Most Popular!)
Spawn Zombies - viewtopic.php?f=13&t=3444 (Newest)
User avatar
Nobody
 
Posts: 1945
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: Cards DS

Postby pomdave » June 27th, 2011, 2:59 am

Hi again,

Well I got a shuffle and deal working ... in a fashion

But it seems to get variables mixed up and therefore loses track of cards in hand and cards left.

The logic looks corrrect (to me) and after it messes up the variable it continues the loop correctly increasing the wrong value in the "cards in hand" variable.

Like YoshiInAVoid suggested to Nobody earlier I tried to use Structs and Malloc, but could not work these out at all, DSGM 5.12 experienced several crashes when declaring Structures via the gui, I finally seemed to get one to workand I could not work out how/where to do the malloc malarkey.

I like the idea of a struct with a malloc in it, it makes sense (and is tidier) to have a predefined requirement for a hand but I couldn't get one to work.


As YoshiInAVoid doesn't have dsgm 5.12 here the chunk from the compile folder that seems to be going wrong:
Code: Select all
void deal_handsTouchNewPress_Event(u8 DAppliesTo) {
  PA_ClearTextBg(1);
  int dealing = 0;
  Draw_Text(1, 6, 17, "dealing: ");
  Draw_Text(1, 6, 18, "cards in hand 1: ");
  Draw_Text(1, 6, 19, "cards in hand 2: ");
  Draw_Text(1, 6, 21, "Cards in deck: ");
  hand1val = 0;
  hand2val = 0;
  for (dealing = 1; dealing <= 7; dealing++) {
    hand_1[dealing] = deck[deck_val];
    deck_val = deck_val-1;
    hand1val = hand1val +1;
    PA_OutputText(1, 9, dealing, "     ");
    PA_OutputText(1, 9, dealing, "%d", hand_1[dealing]);
    hand_2[dealing] = deck[deck_val];
    deck_val = deck_val-1;
    hand2val = hand2val +1;
    PA_OutputText(1, 13, dealing, "     ");
    PA_OutputText(1, 13, dealing, "%d", hand_2[dealing]);
    PA_OutputText(1, 1, 17, "     ");
    PA_OutputText(1, 1, 17, "%d", dealing);
    PA_OutputText(1, 1, 18, "     ");
    PA_OutputText(1, 1, 18, "%d", hand1val);
    PA_OutputText(1, 1, 19, "     ");
    PA_OutputText(1, 1, 19, "%d", hand2val);
    PA_OutputText(1, 1, 21, "     ");
    PA_OutputText(1, 1, 21, "%d", deck_val);
    for (DSGML = 0; DSGML <= (0.5 * 60); DSGML++) {
    PA_WaitForVBL();
    }
  }
    for (DSGML = 0; DSGML <= (3 * 60); DSGML++) {
  PA_WaitForVBL();
  }
  Goto_Next_Room();
}


Thanks, any pointers would be very much appreciated.
Attachments
card reader.dsgm
(131.95 KiB) Downloaded 35 times
card reader.nds
(576.06 KiB) Downloaded 41 times
pomdave
 
Posts: 33
Joined: June 23rd, 2011, 7:50 am
Location: Australia

Re: Cards DS

Postby YoshiInAVoid » June 27th, 2011, 4:29 pm

Goto_Next_Room(); Might not work in a void. Try removing it.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: Cards DS

Postby pomdave » June 27th, 2011, 9:55 pm

Hi

I tried removing goto next room but still the same.

It breaks before it gets to that step

It seems during/after the first iteration of the Loop
it makes hand1val = hand2[1] or deck[deck_val] as they are equal at that point in time
and then the next 6 iterations of the Loop it behaves as expected and increments hand1val by 1
the code is exactly the same for hand2val but it does not experience the same problem???

You can see this by running the NDS file

There are two action objects the red dot (shuffle) and the deck of cards (deal)
hand1val = the first card in hand 2 (top screen, first number, second column) + 6
hand1val should = 7 (hand1val =hand1val+1 looped 7 times)

How can this be?
How can I debug/step through
pomdave
 
Posts: 33
Joined: June 23rd, 2011, 7:50 am
Location: Australia


Return to Game Design & Ideas

Who is online

Users browsing this forum: No registered users and 0 guests