Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project Zavi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mihkelhain
Project Zavi
Commits
e2ea07a0
Unverified
Commit
e2ea07a0
authored
5 months ago
by
Mihkel Hain
Browse files
Options
Downloads
Patches
Plain Diff
Toweri panemine töötab on vaja lihtsalt teha tulistamine ja tegelikkud spawnimis meetodid :)
parent
db643ce8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
__pycache__/turret.cpython-312.pyc
+0
-0
0 additions, 0 deletions
__pycache__/turret.cpython-312.pyc
main.py
+18
-6
18 additions, 6 deletions
main.py
with
18 additions
and
6 deletions
__pycache__/turret.cpython-312.pyc
+
0
−
0
View file @
e2ea07a0
No preview for this file type
This diff is collapsed.
Click to expand it.
main.py
+
18
−
6
View file @
e2ea07a0
...
...
@@ -34,7 +34,7 @@ window.fill(BLACK)
#map
map_image
=
pg
.
image
.
load
(
'
IMG/testmap2.png
'
).
convert_alpha
()
#Cursor turret
cursor_turret
=
pg
.
image
.
load
(
'
IMG/t
estmap2
.png
'
).
convert_alpha
()
cursor_turret
=
pg
.
image
.
load
(
'
IMG/t
owers_walls_blank
.png
'
).
convert_alpha
()
#World creation
world
=
World
(
map_image
)
...
...
@@ -52,6 +52,20 @@ waypoints = [
(
1685
,
220
),
]
def
turret_spawn
(
mouse_pos
):
collision
=
False
if
mouse_pos
[
0
]
<
1920
and
mouse_pos
[
1
]
<
1080
:
temp_turret
=
Turret
(
cursor_turret
,
mouse_pos
)
collision
=
any
(
temp_turret
.
rect
.
colliderect
(
sprite
.
rect
)
for
sprite
in
turret_group
)
if
not
collision
:
turret_group
.
add
(
temp_turret
)
#MOUSE TESTING
mouseSquare
=
pg
.
Rect
(
0
,
0
,
100
,
100
)
running
=
True
while
running
:
for
event
in
pg
.
event
.
get
():
...
...
@@ -64,17 +78,15 @@ while running:
#Mouse click
if
event
.
type
==
pg
.
MOUSEBUTTONDOWN
and
event
.
button
==
1
:
mouse_pos
=
pg
.
mouse
.
get_pos
()
#GameArea check
if
mouse_pos
[
0
]
<
c
.
SCREEN_WIDTH
and
mouse_pos
[
1
]
<
c
.
SCREEN_HEIGHT
:
turret
=
Turret
(
cursor_turret
,
mouse_pos
)
turret_group
.
add
(
turret
)
turret_spawn
(
mouse_pos
)
# TEST
pg
.
draw
.
circle
(
window
,
GREEN
,
(
1920
/
2
,
1080
/
2
),
400
)
world
.
draw
(
window
)
#Ai paths
pg
.
draw
.
lines
(
window
,
"
white
"
,
False
,
waypoints
)
turret_group
.
draw
(
window
)
mouseSquare
.
center
=
pg
.
mouse
.
get_pos
()
pg
.
draw
.
rect
(
window
,
(
255
,
0
,
0
),
mouseSquare
,
6
,
1
)
pg
.
display
.
update
()
pg
.
quit
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment