@@TokyoEdTech Love your vids dude. Not 100% sure if you know C but it would be cool if you made a series on something lower level (C/C++). Because I use C to make games and its actually way simpler than most people think it is (with SDL at least its simple).
I have a problem but it is not related to this video, i wan'na ask how can i move my character move upward. Can you please tell me with a simplest code, btw great videos. :)
Hi, I dont know if you will respond but my cards, in the end, does align in a row, but the top left and bottom right symbol and numbers stacks onto of each other on the middle card. It also clears in the middle when It usually reaches the middle card out of the 5. Any ideas?
#Border def rendering(self, x, y, pen): #DRAW BORDER pen.penup() pen.goto(x, y) pen.color('blue') pen.goto(x- 50, y +75) pen.begin_fill() pen.pendown() pen.goto(x +50, y+75) # I fixed the attribute error but indenting the def print_card and makeing the card.print_card lower pen.goto(x+50, y-75) pen.goto(x-50, y-75) pen.goto(x-50, y +75) pen.penup() pen.end_fill() #Draw suit in mid pen.color('white') pen.goto(x-18, y-30) pen.write(self.symbols[self.suit], False, font=("Courrier New", 48 , 'normal')) #Draw top left number pen.goto(-40, y+40) pen.write(self.name, False, font=("Courrier New", 18 , 'normal')) pen.goto(-40, y+22) pen.write(self.symbols[self.suit], False, font=("Courrier New", 18 , 'normal')) #Draw bottom right number pen.goto(+30, y-55) pen.write(self.name, False, font=("Courrier New", 18 , 'normal')) pen.goto(+30, y-75) pen.write(self.symbols[self.suit], False, font=("Courrier New", 18 , 'normal'))
#prints the A thing in terminal and is interchangable to the actual card #card = Card('A','S') #card.print_card() #card.rendering(0, 0, pen) class Deck(): def __init__(self): self.cards = [] names = ('A', 'K', 'Q', 'J', 'T', "9", '8', '7', '6', '5', '4', '3', '2') suits = ('D', 'C', 'H', 'S') for name in names: for suit in suits: card = Card(name, suit) self.cards.append(card) def reset_cards(self): self.cards = [] names = ('A', 'K', 'Q', 'J', 'T', "9", '8', '7', '6', '5', '4', '3', '2') suits = ('D', 'C', 'H', 'S') for name in names: for suit in suits: card = Card(name, suit) self.cards.append(card) self.shuffle() #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| def shuffle(self): random.shuffle(self.cards) def get_card(self): card = self.cards.pop() return card #Create deck deck = Deck() #pop a card off #Shuffle deck deck.shuffle() start_x = -250 for x in range(5): card = deck.get_card() card.rendering(start_x + x * 125, 0, pen) #time.sleep(0) #pen.clear() #Render 10 cards in a row wn.mainloop() #for card in deck.cards: #card.print_card() #card.rendering(0, 0, pen) Since I couldn't figure out why this was happening, I worked ahead a bit, so that's why theres the def reset_cards. Sorry for not sending the code earlier
Enjoy your video except I have one problem. When I run the program, instead of the spade symbol, it prints out "\u2660". I have spent hours comparing your code to what I typed and it is all the same. What could be the problem? Thanks.
5:19 are you aware of __repr__ as a way to allow you to simply call print() with any object? thats the more “pythonic” way, and I’d say it looks better...
If that's what works best for you, then go for it. However, I think you'll find that using goto will make it easier to port this to a different rendering system such as pygame.
Hey. Can you make a begginer python series? I am sure many new pyhton coders (like me) will be interested
Here ya go: ruclips.net/video/rxSyXBq9zq0/видео.html
@@TokyoEdTech woah thanks a lot
Thanks for the video! I'm also here for my OOP. Wish I had found your vids earlier.
Better late than never!
Thank you so much! Will try it out. You make coding and programming so much fun!
Thanks - I try!
This was such a great video . Really helped me with my OOP.
Thanks - glad to hear it! Keep on codin'!
I wish more people saw this ;(
Thanks - me too!
@@TokyoEdTech Love your vids dude. Not 100% sure if you know C but it would be cool if you made a series on something lower level (C/C++). Because I use C to make games and its actually way simpler than most people think it is (with SDL at least its simple).
@@aryanahire2337 Thanks! I'm not very good at C. It's cool you can use SDL to make games with C.. Do you have any recommended resources?
@@TokyoEdTech ruclips.net/video/JPAyj85tJ5E/видео.html this is all i have, it doesn't go TOO in depth, but it shows how C isn't that complex.
Awesome, Could've added the "click to flip" feature.. coz I'm trying it now!!
Good luck!
Love the video, also the existential moment of reflecting life at 18:13 dw theres always a next time:)
Thanks - good to reflect before it is too late!
I have a problem but it is not related to this video, i wan'na ask how can i move my character move upward. Can you please tell me with a simplest code, btw great videos. :)
I have a series of videos on object motion - they should answer your question: ruclips.net/video/qN4tjmVQjXI/видео.html
Great video as usual :D
Thanks, Mishka!
@@TokyoEdTech :)
Hi, I dont know if you will respond but my cards, in the end, does align in a row, but the top left and bottom right symbol and numbers stacks onto of each other on the middle card. It also clears in the middle when It usually reaches the middle card out of the 5. Any ideas?
Hiya, I'd need to see the code to be able to help.
@@TokyoEdTech I really appreciate the help, thankyou.
import turtle
import time
import random
wn = turtle.Screen()
wn.bgcolor('black')
wn.setup(600,600)
wn.title("Deck of cards")
pen = turtle.Turtle()
#pen.speed(0.5)
pen.hideturtle()
#Create classes
class Card():
def __init__(self, name, suit):
self.name = name
self.suit = suit
self.symbols = {'D':'♦','C':'♣','H':'♥','S':'♠'}
def print_card(self):
print(f"{self.name}{self.symbols[self.suit]}")
#Border
def rendering(self, x, y, pen):
#DRAW BORDER
pen.penup()
pen.goto(x, y)
pen.color('blue')
pen.goto(x- 50, y +75)
pen.begin_fill()
pen.pendown()
pen.goto(x +50, y+75) # I fixed the attribute error but indenting the def print_card and makeing the card.print_card lower
pen.goto(x+50, y-75)
pen.goto(x-50, y-75)
pen.goto(x-50, y +75)
pen.penup()
pen.end_fill()
#Draw suit in mid
pen.color('white')
pen.goto(x-18, y-30)
pen.write(self.symbols[self.suit], False, font=("Courrier New", 48 , 'normal'))
#Draw top left number
pen.goto(-40, y+40)
pen.write(self.name, False, font=("Courrier New", 18 , 'normal'))
pen.goto(-40, y+22)
pen.write(self.symbols[self.suit], False, font=("Courrier New", 18 , 'normal'))
#Draw bottom right number
pen.goto(+30, y-55)
pen.write(self.name, False, font=("Courrier New", 18 , 'normal'))
pen.goto(+30, y-75)
pen.write(self.symbols[self.suit], False, font=("Courrier New", 18 , 'normal'))
#prints the A thing in terminal and is interchangable to the actual card
#card = Card('A','S')
#card.print_card()
#card.rendering(0, 0, pen)
class Deck():
def __init__(self):
self.cards = []
names = ('A', 'K', 'Q', 'J', 'T', "9", '8', '7', '6', '5', '4', '3', '2')
suits = ('D', 'C', 'H', 'S')
for name in names:
for suit in suits:
card = Card(name, suit)
self.cards.append(card)
def reset_cards(self):
self.cards = []
names = ('A', 'K', 'Q', 'J', 'T', "9", '8', '7', '6', '5', '4', '3', '2')
suits = ('D', 'C', 'H', 'S')
for name in names:
for suit in suits:
card = Card(name, suit)
self.cards.append(card)
self.shuffle()
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def shuffle(self):
random.shuffle(self.cards)
def get_card(self):
card = self.cards.pop()
return card
#Create deck
deck = Deck() #pop a card off
#Shuffle deck
deck.shuffle()
start_x = -250
for x in range(5):
card = deck.get_card()
card.rendering(start_x + x * 125, 0, pen)
#time.sleep(0)
#pen.clear()
#Render 10 cards in a row
wn.mainloop()
#for card in deck.cards:
#card.print_card()
#card.rendering(0, 0, pen)
Since I couldn't figure out why this was happening, I worked ahead a bit, so that's why theres the def reset_cards.
Sorry for not sending the code earlier
Excellent!! Thank you so much once again.
No worries!
Enjoy your video except I have one problem. When I run the program, instead of the spade symbol, it prints out "\u2660". I have spent hours comparing your code to what I typed and it is all the same. What could be the problem? Thanks.
That's odd. My best guess is that whatever font you are using doesn't have the symbol for some reason..
@@TokyoEdTech i'm not gonna make it without errors
what color syntax are you using? I like it.
Hiya - it is called Bespin.
5:19 are you aware of __repr__ as a way to allow you to simply call print() with any object? thats the more “pythonic” way, and I’d say it looks better...
Yep. Thanks for the suggestion. I don't use it with my students though.
what about pen.forward() and pen.right() instead of pen.goto() ? For me they look more natural.
If that's what works best for you, then go for it. However, I think you'll find that using goto will make it easier to port this to a different rendering system such as pygame.
So, you used random( ) function... 🤔😏✅
Randomly, yes!
@@TokyoEdTech
I thought so!
Can u make ludo game
Multiplayer ludo gamr
Probably not, although I do want to make a board game someday.