Reputation: 81
Im trying to make a card game and for some reason i keep on getting got an unexpected keyword argument 'calculate_hit_box' error everytime i run my code
import arcade
# Screen title and size
SCREEN_WIDTH = 1024
SCREEN_HEIGHT = 768
SCREEN_TITLE = "Bahraini Deal"
# Constants for sizing
CARD_SCALE = 0.6
# How big are the cards?
CARD_WIDTH = 140 * CARD_SCALE
CARD_HEIGHT = 190 * CARD_SCALE
# How big is the mat we'll place the card on?
MAT_PERCENT_OVERSIZE = 1.25
MAT_HEIGHT = int(CARD_HEIGHT * MAT_PERCENT_OVERSIZE)
MAT_WIDTH = int(CARD_WIDTH * MAT_PERCENT_OVERSIZE)
# How much space do we leave as a gap between the mats?
# Done as a percent of the mat size.
VERTICAL_MARGIN_PERCENT = 0.10
HORIZONTAL_MARGIN_PERCENT = 0.10
# The Y of the bottom row (2 piles)
BOTTOM_Y = MAT_HEIGHT / 2 + MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
# The X of where to start putting things on the left side
START_X = MAT_WIDTH / 2 + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
# Card constants
CARDS_NAMES = ["City_Center_1" , "Clock_Roundabout_1", "Extra_Play_1", "Its_Friday_1","Just_Say_No_1", "Pay_Me_Rent_BlackGray_1", "Pay_Me_Rent_BrownBlue_1","Pay_Me_Rent_GreenPurple_1",
"Pay_Me_Rent_PinkOrange_1","Pay_Me_Rent_RedYellow_1","Pay_Me_Rent_Mix_1", "Shake_Pockets_1", "Social_Housing_1",
"Two_More_Cards_1","World_Trade_Center_1", "Zallaq_Sofitel_1"]
CARDS_VALUE = {"City_Center_1" : 4, "Clock_Roundabout_1" : 3, "Extra_Play_1" : 2, "Its_Friday_1":2,"Just_Say_No_1":4, "Pay_Me_Rent_BlackGray_1":1, "Pay_Me_Rent_BrownBlue_1":1,"Pay_Me_Rent_GreenPurple_1":1,
"Pay_Me_Rent_PinkOrange_1":1,"Pay_Me_Rent_RedYellow_1":1,"Pay_Me_Rent_Mix_1":3, "Shake_Pockets_1":3, "Social_Housing_1":2,
"Two_More_Cards_1":1,"World_Trade_Center_1":4, "Zallaq_Sofitel_1":5}
class Card(arcade.Sprite):
""" Card sprite """
def __init__(self, name, scale=1):
""" Card constructor """
# Attributes for suit and value
self.name = name
# Image to use for the sprite when face up
self.image_file_name = f":CardsFinal:images/{self.name}.png"
# Call the parent
super().__init__(self.image_file_name, scale,calculate_hit_box=False)
class MyGame(arcade.Window):
""" Main application class. """
def __init__(self):
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
self.card_list = None
arcade.set_background_color(arcade.color.FRENCH_SKY_BLUE)
def setup(self):
""" Set up the game here. Call this function to restart the game. """
self.card_list = arcade.SpriteList()
# Create every card
for card_name in CARDS_NAMES:
for card_value in CARDS_VALUE:
card = Card(card_name, card_value, CARD_SCALE)
card.position = START_X, BOTTOM_Y
self.card_list.append(card)
def on_draw(self):
""" Render the screen. """
# Clear the screen
arcade.start_render()
# Draw the cards
self.card_list.draw()
def on_mouse_press(self, x, y, button, key_modifiers):
""" Called when the user presses a mouse button. """
pass
def on_mouse_release(self, x: float, y: float, button: int,
modifiers: int):
""" Called when the user presses a mouse button. """
pass
def on_mouse_motion(self, x: float, y: float, dx: float, dy: float):
""" User moves mouse """
pass
def main():
""" Main method """
window = MyGame()
window.setup()
arcade.run()
if __name__ == "__main__":
main()
I've tried multiple ways to fix the problem but while fixing it i end up messing it up more and more every time, its clear that the issue is with the calculate_hit_box but what i dont get is why? every soultion i try ends up mesing it up more and more
Upvotes: 1
Views: 644
Reputation: 8270
Remove calculate_hit_box=False
from here:
super().__init__(self.image_file_name, scale,calculate_hit_box=False)
Seems that there is an error in "Solitaire" tutorial. I've created an issue for arcade
lib.
Upvotes: 1
Reputation: 33
From looking at the arcade.Sprite source code, it doesn't look like calculate_hit_box
is one of Sprite
's __init__
parameters:
class Sprite:
def __init__(self,
filename: str = None,
scale: float = 1,
image_x: float = 0, image_y: float = 0,
image_width: float = 0, image_height: float = 0,
center_x: float = 0, center_y: float = 0,
repeat_count_x: int = 1, repeat_count_y: int = 1,
flipped_horizontally: bool = False,
flipped_vertically: bool = False,
flipped_diagonally: bool = False,
mirrored: bool = None,
hit_box_algorithm: str = "Simple",
hit_box_detail: float = 4.5):
# ...
Maybe it used to be in an older version of Arcade, which would explain the confusion if you're following an old tutorial.
Upvotes: 1