Skip to content

Bug? Actor width and height are writeable #362

@Mambouna

Description

@Mambouna

Currently, there is no support for changing the dimensions of an actor via the height and width attributes (although multiple proposals and some PRs exist for this).

In spite of this, both attributes can freely be changed, without this impacting the drawn picture or any other functionality as far as I can tell.

Until actual functionality is put in place to make changing actors dimensions possible, I think this should be treated as a bug. One of my students has already stumbled over this and thought he was making some mistake when changing the values did nothing.

I propose making width and height read only attributes (via properties) until a full solution is implemented for scaling.

Minimal reproduction example with a visual aid for the variable values:

WIDTH, HEIGHT = 500, 500
a = Actor("alien", (250, 250))
r = Rect((1, 1), (1, 1))

def update():
    if keyboard.q:
        a.width -= 10
        print(a.width)
    elif keyboard.e:
        a.width += 10
        print(a.width)

    if keyboard.r:
        a.height += 10
        print(a.height)
    elif keyboard.f:
        a.height -= 10
        print(a.height)

    r.x = a.topleft[0]
    r.y = a.topleft[1]
    r.width = a.width
    r.height = a.height

def draw():
    screen.clear()
    a.draw()
    screen.draw.rect(r, "red")

I'll make a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions