Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
P
PythoCup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bold Hearts
PythoCup
Commits
9d3496ce
Commit
9d3496ce
authored
Sep 11, 2017
by
gem2578
Committed by
Marcus M. Scheunemann
Nov 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Object Type is now a enum
parent
2f9e85f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
model/cup_object.py
model/cup_object.py
+4
-4
model/object_type.py
model/object_type.py
+6
-0
sprite/player.py
sprite/player.py
+6
-5
No files found.
model/cup_object.py
View file @
9d3496ce
...
...
@@ -3,13 +3,13 @@ from model.side import Side
class
CupObject
():
def
__init__
(
self
,
type
,
pos
,
side
=
None
):
self
.
type
=
type
def
__init__
(
self
,
obj_
type
,
pos
,
side
=
None
):
self
.
type
=
obj_
type
self
.
pos
=
Vector2
(
pos
)
self
.
side
=
side
def
__repr__
(
self
):
if
self
.
side
is
not
None
:
return
self
.
type
+
self
.
side
.
value
return
self
.
type
.
value
+
" "
+
self
.
side
.
value
else
:
return
self
.
type
return
self
.
type
.
value
model/object_type.py
0 → 100644
View file @
9d3496ce
from
enum
import
Enum
class
ObjectType
(
Enum
):
BALL
=
"Ball"
GOAL
=
"Goal"
PLAYER
=
"Player"
sprite/player.py
View file @
9d3496ce
import
pygame
import
sprite.round_sprite
as
rs
from
model.side
import
Side
from
model.object_type
import
ObjectType
from
model.cup_object
import
CupObject
class
Player
(
rs
.
Round
):
...
...
@@ -50,12 +51,12 @@ class Brain():
self
.
side
=
side
def
setup
(
self
,
goals
):
self
.
self_goal
=
CupObject
(
"goal"
,
goals
.
get
(
self
.
side
).
rect
.
center
,
self
.
side
)
self
.
self_goal
=
CupObject
(
ObjectType
.
GOAL
,
goals
.
get
(
self
.
side
).
rect
.
center
,
self
.
side
)
other_side
=
self
.
side
.
other
()
self
.
other_goal
=
CupObject
(
"goal"
,
goals
.
get
(
other_side
).
rect
.
center
,
Side
.
other
(
other_side
))
self
.
other_goal
=
CupObject
(
ObjectType
.
GOAL
,
goals
.
get
(
other_side
).
rect
.
center
,
Side
.
other
(
other_side
))
def
pre_action
(
self
,
body
):
self
.
ball
=
CupObject
(
"ball"
,
body
.
ball
.
rect
().
center
)
self
.
ball
=
CupObject
(
ObjectType
.
BALL
,
body
.
ball
.
rect
().
center
)
self
.
pos
=
pygame
.
math
.
Vector2
(
body
.
rect
.
center
)
body
.
can_kick
=
self
.
pos
.
distance_to
(
self
.
ball
.
pos
)
<
30
self
.
can_kick
=
body
.
can_kick
...
...
@@ -64,11 +65,11 @@ class Brain():
self
.
self_team
=
[]
for
player
in
body
.
self_team
:
if
(
player
!=
body
):
self
.
self_team
.
append
(
CupObject
(
"player"
,
player
.
rect
.
center
,
self
.
side
))
self
.
self_team
.
append
(
CupObject
(
ObjectType
.
PLAYER
,
player
.
rect
.
center
,
self
.
side
))
self
.
other_team
=
[]
for
player
in
body
.
other_team
:
self
.
other_team
.
append
(
CupObject
(
"player"
,
player
.
rect
.
center
,
self
.
side
.
other
()))
self
.
other_team
.
append
(
CupObject
(
ObjectType
.
PLAYER
,
player
.
rect
.
center
,
self
.
side
.
other
()))
def
sorted_object
(
self
):
objects
=
[
self
.
ball
,
self
.
self_goal
,
self
.
other_goal
]
+
self
.
self_team
+
self
.
other_team
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment