[Pygame] aligning a hand of cards

[Pygame] aligning a hand of cards

Postby metulburr » Fri Apr 11, 2014 10:45 pm

I cant for the life of me figure out why the cards are not drawn out (well as cards are laid out in front of you in any card game)...such as the first card to the far left, the second card drawn out farther to the right but overlapping the far left card, etc. etc. The modification to the hand cards x and y position are in testing.Testing.update_hand()
Code: Select all
    def update_hand(self):
        x = 0
        for card in self.hand:
            print(x)
            card.rect.y = self.screen_rect.bottom - card.surf.get_height()
            if card.selected:
                card.rect.y -= self.card_bufferY
            card.rect.x = x
            x += self.card_bufferX


The repo:
https://github.com/metulburr/Boom

My thought process is x is 0,100,200 etc. throughout the loop, and gets set to card.rect.x, so i am not sure why sometimes the first card x value is set at 100, and sometimes 200, when the first card should be set at 0? The cards are laid out different each time too and not sure why.

EDIT:
self.cards being set int tools.States.set_cards()
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1507
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Return to Game Development

Who is online

Users browsing this forum: No registered users and 3 guests