Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circle does not have same properties as Actor e.g. actor.pos, actor.position #49

Open
kimlaberinto opened this issue Aug 3, 2021 · 2 comments

Comments

@kimlaberinto
Copy link

Based on the docs, I got the impression that Circle should have the same properties as Actor. So I ran into an problem where my code runs on actors using a.pos, but then it didn't work with Circles e.g. c.pos was "nothing".

Circle has the same API/properties as Actor.
Game objects on-screen are represented as Actors which have several associated attributes. Using Actors, you can change position, change the image and check for collisions. However, not all moving parts need to be Actors as those without a specific image can be defined as a Circle or a Rect, which have the same associated attributes (apart from image). Actors are usually the primary game objects that you move around.

GameZero.jl also includes basic geometric shapes. Rects, Circles and Lines can be used to do everything an Actor can, having the same attributes (apart from image).

This might also apply to Rect, Triangle, and Line as well.

Possible solutions:

  • Update the docs
  • Possibly create an API for how to interact with game object-like things, like Actor, Circle, etc., allowing one to set and get position, and other properties.
@aviks
Copy link
Owner

aviks commented Aug 5, 2021

Hmnn.. yes. The set of properties for a Circle can be seen here :

GameZero.jl/src/screen.jl

Lines 158 to 164 in 57abb0d

getPos(::Val{:center}, s::Circle, u, v) = (u, v)
getPos(::Val{:top}, s::Circle, v) = (s.x, v-s.r)
getPos(::Val{:bottom}, s::Circle, v) = (s.x, v+s.r)
getPos(::Val{:left}, s::Circle, u) = (u-s.r, s.y)
getPos(::Val{:right}, s::Circle, u) = (u+s.r, s.y)
getPos(::Val{:centerx}, s::Circle, u) = (u, s.y)
getPos(::Val{:centery}, s::Circle, v) = (s.x, v)
. This is an inconsistency that should probably be fixed.

there's a question about what pos for a circle should return. It could be the centre, or it could be the topright of the enclosing rect. I think one could argue it both ways -- best geometric meaning, or consistency with Actors.

@dionisos2
Copy link

I think consistency is more important here, people should be able to do some for loop without having to worry if they get a circle or an actor.
There are the other properties to get the center.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants