Skip to content
Snippets Groups Projects
Unverified Commit 61e31544 authored by Mihkel Hain's avatar Mihkel Hain
Browse files

Initial Test Merge (PS: not working as of yet)

parents eec3490c fcb6545d
No related branches found
No related tags found
No related merge requests found
File added
IMG/testmap2.png

1.46 MiB

IMG/towers_walls_blank.png

3.77 KiB

......@@ -15,8 +15,9 @@
########################################################################
import pygame as pg
import time
import time, math
from world import World
from turret import Turret
from gui import GUI
def main():
......@@ -31,6 +32,20 @@ def main():
dt = 1/1000
time_now = time.time()
#MOUSE TESTING
mouseSquare = pg.Rect(0,0,100,100)
#Groups
turret_group = pg.sprite.Group()
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)
# Main game loop
running = True
......@@ -61,8 +76,6 @@ def main():
# Start the round with the space key
if event.key == pg.K_SPACE and not world.round_active:
world.request_to_start_round = True
# Game state updates
if world.round_active:
# Spawn enemies at the correct time
......@@ -81,11 +94,15 @@ def main():
world.round_active = True
world.round_start_time = time.time()
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
mouse_pos = pg.mouse.get_pos()
turret_spawn(mouse_pos)
# Drawing
world.draw()
world.draw
#Box for collision tower purposes
mouseSquare.center = pg.mouse.get_pos()
pg.draw.rect(world.window, (255, 0, 0), mouseSquare, 6, 1)
# Debug drawing, comment out if not needed.
#world.draw_debug()
......@@ -97,4 +114,4 @@ def main():
pg.quit()
if __name__ == "__main__":
main()
\ No newline at end of file
main()
import pygame as pg
class Turret(pg.sprite.Sprite):
def __init__(self,image,pos):
pg.sprite.Sprite.__init__(self)
self.image = image
self.rect = self.image.get_rect()
self.rect.center = pos
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment