Compare commits
12 Commits
6a584a4cab
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89c5dcc6d1 | ||
|
|
ae750f236d | ||
|
|
3f2b519820 | ||
|
|
9dc0b6289f | ||
|
|
923f476303 | ||
|
|
31a695f099 | ||
|
|
b6590d33b8 | ||
|
|
6742e4585d | ||
|
|
0065c3c033 | ||
|
|
31384e03df | ||
|
|
e87c7fed02 | ||
|
|
ee9625bbff |
2
.gitignore
vendored
@@ -1,4 +1,6 @@
|
|||||||
.venv/
|
.venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
test.spec
|
test.spec
|
||||||
log.txt
|
log.txt
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
import interface
|
||||||
#Statics
|
#Statics
|
||||||
spawned_enemys = list()
|
spawned_enemys = list()
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class GameObject(object):
|
|||||||
self.image = image
|
self.image = image
|
||||||
self.rect:pygame.Rect
|
self.rect:pygame.Rect
|
||||||
self.objects.append(self)
|
self.objects.append(self)
|
||||||
self.keymap = {"up":False, "down":False, "left":False, "right":False}
|
|
||||||
|
|
||||||
def get_objectinfo(self):
|
def get_objectinfo(self):
|
||||||
print(F"Gameobject-Info: \n",
|
print(F"Gameobject-Info: \n",
|
||||||
@@ -25,9 +25,9 @@ class GameObject(object):
|
|||||||
|
|
||||||
def render(self, screen:pygame.Surface):
|
def render(self, screen:pygame.Surface):
|
||||||
if(self.image is not None):
|
if(self.image is not None):
|
||||||
self.rect = screen.blit(self.image, (self.pos_x, self.pos_y))
|
self.rect = screen.blit(self.image, (self.pos_x, self.pos_y, self.width, self.height))
|
||||||
else:
|
else:
|
||||||
print("Kein Image hinterlegt!")
|
self.rect = pygame.draw.rect(screen, (255,0,0), (self.pos_x, self.pos_y, self.width, self.height))
|
||||||
return
|
return
|
||||||
|
|
||||||
def setpos(self, pos_x, pos_y):
|
def setpos(self, pos_x, pos_y):
|
||||||
@@ -38,15 +38,24 @@ class GameObject(object):
|
|||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
#Remove objectpoint on delete from static
|
||||||
|
if(len(self.objects) > 0):
|
||||||
|
print(F"Remove: {self}")
|
||||||
|
self.objects.remove(self)
|
||||||
|
|
||||||
class Player(GameObject):
|
class Player(GameObject):
|
||||||
def __init__(self, name, screen, pos_x, pos_y, width, height, image=None) -> None:
|
def __init__(self, name, screen, pos_x, pos_y, width, height, image=None) -> None:
|
||||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||||
self._speed = 10
|
self._speed = 8
|
||||||
self.screen = screen
|
self.screen:pygame.Surface = screen
|
||||||
self.points = 0
|
self.points = 0
|
||||||
self._health = 100
|
self._health = 100
|
||||||
self.lifes = 2
|
self.lifes = 2
|
||||||
self.kills = 0
|
self.kills = 0
|
||||||
|
#self._healthbar = pygame.rect.Rect((15, self.screen.get_size()[1]-50, 100, 20))
|
||||||
|
self.healthbar = interface.Healthbar(screen, "Player1", 25, screen.get_size()[1]-80, 300, 10, self.get_health())
|
||||||
|
self.keymap = {"up":False, "down":False, "left":False, "right":False}
|
||||||
|
|
||||||
def handle_input(self, event:pygame.event.EventType):
|
def handle_input(self, event:pygame.event.EventType):
|
||||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT):
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT):
|
||||||
@@ -64,7 +73,17 @@ class Player(GameObject):
|
|||||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE):
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE):
|
||||||
#Fiiirrreee in the hole
|
#Fiiirrreee in the hole
|
||||||
#print("Feuer!")
|
#print("Feuer!")
|
||||||
self.fire(self.screen)
|
self.fire(self.screen)
|
||||||
|
|
||||||
|
def get_health(self):
|
||||||
|
return self._health
|
||||||
|
|
||||||
|
def get_damage(self, damage:int):
|
||||||
|
|
||||||
|
if((self._health - damage) <= 0):
|
||||||
|
self._health = 0
|
||||||
|
else:
|
||||||
|
self._health -= damage
|
||||||
|
|
||||||
def move(self, x=0, y=0):
|
def move(self, x=0, y=0):
|
||||||
if x != 0:
|
if x != 0:
|
||||||
@@ -73,15 +92,21 @@ class Player(GameObject):
|
|||||||
self.pos_y += y
|
self.pos_y += y
|
||||||
|
|
||||||
def move(self, direction):
|
def move(self, direction):
|
||||||
if(direction == "left"):
|
if(direction == "left"):
|
||||||
self.pos_x -= self._speed
|
self.pos_x -= self._speed
|
||||||
|
|
||||||
if(direction == "right"):
|
if(direction == "right"):
|
||||||
self.pos_x += self._speed
|
self.pos_x += self._speed
|
||||||
|
|
||||||
def fire(self, screen):
|
def update_interface(self):
|
||||||
shot = Projectile(self.name, self.pos_x+(self.width/2),self.pos_y-self.height,5,10, screen)
|
self.healthbar.update(self._health)
|
||||||
|
self.healthbar.render(self.screen)
|
||||||
|
|
||||||
|
def fire(self, screen):
|
||||||
|
projectile_width = 6
|
||||||
|
projectile_height = 10
|
||||||
|
shot = Projectile(self.name, self.pos_x+(self.width/2)-(projectile_width/2), self.pos_y-projectile_height, projectile_width, projectile_height, screen, 8)
|
||||||
|
#Maybe change this by another subroutine in Projectiles class
|
||||||
def firecontrol(self, screen):
|
def firecontrol(self, screen):
|
||||||
if(len(Projectile.shots) > 0):
|
if(len(Projectile.shots) > 0):
|
||||||
for objects in Projectile.shots:
|
for objects in Projectile.shots:
|
||||||
@@ -91,18 +116,18 @@ class Player(GameObject):
|
|||||||
if(key == "Player"or key == "Player2"):
|
if(key == "Player"or key == "Player2"):
|
||||||
object.animate("UP")
|
object.animate("UP")
|
||||||
#print("Playerschuss!")
|
#print("Playerschuss!")
|
||||||
|
|
||||||
if(key == "Enemy"):
|
if(key == "Enemy"):
|
||||||
#print(object.pos_x, " ", object.pos_y)
|
#print(object.pos_x, " ", object.pos_y)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_health(self):
|
def get_health(self):
|
||||||
return self._health
|
return self._health
|
||||||
|
|
||||||
|
|
||||||
class Player2(Player):
|
class Player2(Player):
|
||||||
def __init__(self, name, screen, pos_x, pos_y, width, height, image=None) -> None:
|
def __init__(self, name, screen, pos_x, pos_y, width, height, image=None) -> None:
|
||||||
super().__init__(name, screen, pos_x, pos_y, width, height, image)
|
super().__init__(name, screen, pos_x, pos_y, width, height, image)
|
||||||
|
self.healthbar = interface.Healthbar(screen, "Player1", screen.get_size()[0]-320, screen.get_size()[1]-80, 300, 10, self.get_health())
|
||||||
def handle_input(self, event:pygame.event.EventType):
|
def handle_input(self, event:pygame.event.EventType):
|
||||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_a):
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_a):
|
||||||
self.keymap["left"] = True
|
self.keymap["left"] = True
|
||||||
@@ -136,14 +161,13 @@ class Enemy(GameObject):
|
|||||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.movespeed = 10
|
self.movespeed = 10
|
||||||
|
self._target_x = 0
|
||||||
|
self._target_y = 0
|
||||||
self.weapon:Weapons = None
|
self.weapon:Weapons = None
|
||||||
|
|
||||||
def fire(self, screen):
|
def fire(self, screen):
|
||||||
#print("Schieße!!!!")
|
|
||||||
#shot = Projectile("Enemy", self.pos_x+(self.width/2),self.pos_y+self.height,5,10, screen, 2)
|
|
||||||
self.weapon.fire()
|
self.weapon.fire()
|
||||||
|
|
||||||
|
|
||||||
def firecontrol(self, screen):
|
def firecontrol(self, screen):
|
||||||
if(len(Projectile.shots) > 0):
|
if(len(Projectile.shots) > 0):
|
||||||
for objects in Projectile.shots:
|
for objects in Projectile.shots:
|
||||||
@@ -156,8 +180,10 @@ class Enemy(GameObject):
|
|||||||
def move(self, x=0, y=0):
|
def move(self, x=0, y=0):
|
||||||
if(x != 0):
|
if(x != 0):
|
||||||
self.pos_x += x
|
self.pos_x += x
|
||||||
|
self.weapon.pos_x = self.pos_x+(self.width/2)
|
||||||
if(y != 0):
|
if(y != 0):
|
||||||
self.pos_y += y
|
self.pos_y += y
|
||||||
|
|
||||||
|
|
||||||
def give_weapon(self, weapon):
|
def give_weapon(self, weapon):
|
||||||
self.weapon = weapon
|
self.weapon = weapon
|
||||||
@@ -201,6 +227,7 @@ class Weapons(GameObject):
|
|||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.sprite = ""
|
self.sprite = ""
|
||||||
self.mountingpos = list()
|
self.mountingpos = list()
|
||||||
|
self.soundfile = ""
|
||||||
|
|
||||||
def fire(self):
|
def fire(self):
|
||||||
print(F"Feuere: {self.name}")
|
print(F"Feuere: {self.name}")
|
||||||
@@ -208,7 +235,19 @@ class Weapons(GameObject):
|
|||||||
class Item(GameObject):
|
class Item(GameObject):
|
||||||
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||||
|
self.speed = 2
|
||||||
|
|
||||||
|
def move(self, x:int, y:int):
|
||||||
|
self.pos_x += x
|
||||||
|
self.pos_y += y
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
class item_extra_life(Item):
|
class item_extra_life(Item):
|
||||||
|
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||||
|
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||||
|
self.speed = 10
|
||||||
|
|
||||||
|
class barricade1(GameObject):
|
||||||
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
|
||||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||||
2
Utils.py
@@ -17,6 +17,6 @@ def load_image(filename, colorkey=None):
|
|||||||
if colorkey is not None:
|
if colorkey is not None:
|
||||||
if colorkey is -1:
|
if colorkey is -1:
|
||||||
colorkey = image.get_at((0,0))
|
colorkey = image.get_at((0,0))
|
||||||
image.set_colorkey(colorkey, pygame.RLEACCEL)
|
image.set_colorkey(colorkey)
|
||||||
|
|
||||||
return image
|
return image
|
||||||
7
animations.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class animation(object):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def flyin(self, object):
|
||||||
|
pass
|
||||||
|
|
||||||
52
game.py
@@ -1,18 +1,68 @@
|
|||||||
############################################################
|
############################################################
|
||||||
## Implements all Gamemechanics here! ##
|
## Implement all Gamemechanics here! ##
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
import GameObject
|
import GameObject
|
||||||
|
import animations
|
||||||
from levels import *
|
from levels import *
|
||||||
import pygame
|
import pygame
|
||||||
import logger
|
import logger
|
||||||
|
import random
|
||||||
|
import copy
|
||||||
|
|
||||||
#Leveldefinitions
|
#Leveldefinitions
|
||||||
levels_list.append(first_level("First Level", (500,500), 10, 2))
|
levels_list.append(first_level("First Level", (500,500), 10, 2))
|
||||||
|
|
||||||
|
|
||||||
|
items = [
|
||||||
|
GameObject.item_extra_life("Extra-Life", 0, 0, 30, 30, None)
|
||||||
|
]
|
||||||
|
|
||||||
|
enemys_spawned = list()
|
||||||
|
items_spawned = list()
|
||||||
|
|
||||||
#Override
|
#Override
|
||||||
def loadlevels():
|
def loadlevels():
|
||||||
for level in levels_list:
|
for level in levels_list:
|
||||||
|
if(type(level) == "level"):
|
||||||
|
print("LEVEL")
|
||||||
print(level)
|
print(level)
|
||||||
|
pass
|
||||||
|
|
||||||
|
def item_handler(screen:pygame.Surface):
|
||||||
|
|
||||||
|
spawn_chance = random.randint(0, 1000)
|
||||||
|
#print(spawn_chance)
|
||||||
|
if(spawn_chance == 0):
|
||||||
|
#print("Spawne item")
|
||||||
|
spawn_item_random(screen)
|
||||||
|
|
||||||
|
for item in items_spawned:
|
||||||
|
item:GameObject.Item
|
||||||
|
print(item)
|
||||||
|
|
||||||
|
if(item.pos_y >= screen.get_size()[1]):
|
||||||
|
items_spawned.remove(item)
|
||||||
|
item.move(0, item.speed)
|
||||||
|
item.render(screen)
|
||||||
|
|
||||||
|
def handle_playerinput(players):
|
||||||
|
for player in players():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def spawn_item_random(screen:pygame.Surface):
|
||||||
|
|
||||||
|
items_spawned.append(copy.deepcopy(items[0]))
|
||||||
|
print("Spawn")
|
||||||
|
pass
|
||||||
|
|
||||||
|
def spawn_enemys(type:object, count:int):
|
||||||
|
for i in range(count):
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run(screen:pygame.Surface):
|
||||||
|
screen = screen
|
||||||
|
item_handler(screen)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
38
interface.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class UIelement(object):
|
||||||
|
def __init__(self, screen, name, posx, posy) -> None:
|
||||||
|
self.screen = screen
|
||||||
|
self.name = name
|
||||||
|
self.posx = posx
|
||||||
|
self.posy = posy
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Healthbar(UIelement):
|
||||||
|
def __init__(self, screen, name, posx, posy, width, height,playerhealth) -> None:
|
||||||
|
super().__init__(screen, name, posx, posy)
|
||||||
|
self.width = width
|
||||||
|
self.height = height
|
||||||
|
self.max_width = width
|
||||||
|
self.max_health = playerhealth
|
||||||
|
self.health = playerhealth
|
||||||
|
|
||||||
|
def update(self, playerheatlh):
|
||||||
|
grundwert = self.max_health
|
||||||
|
prozentwert = playerheatlh
|
||||||
|
prozent = (playerheatlh/grundwert)
|
||||||
|
#print(prozent)
|
||||||
|
#print(prozentwert)
|
||||||
|
#print(playerheatlh)
|
||||||
|
|
||||||
|
#Update until playerhealth not zero
|
||||||
|
if(self.health > 0):
|
||||||
|
res = self.max_width*prozent
|
||||||
|
self.health = res
|
||||||
|
elif self.health < 0:
|
||||||
|
self.health = 0
|
||||||
|
|
||||||
|
def render(self, screen):
|
||||||
|
pygame.draw.rect(screen, (255,0,0), (self.posx, self.posy, self.health, self.height))
|
||||||
|
pass
|
||||||
@@ -10,6 +10,9 @@ class level(object):
|
|||||||
self.num_enemys = num_enemys
|
self.num_enemys = num_enemys
|
||||||
self.spawn_waves = spawn_waves
|
self.spawn_waves = spawn_waves
|
||||||
self._completed = False
|
self._completed = False
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class first_level(level):
|
class first_level(level):
|
||||||
def __init__(self, name, size: tuple, num_enemys, spawn_waves) -> None:
|
def __init__(self, name, size: tuple, num_enemys, spawn_waves) -> None:
|
||||||
|
|||||||
3
readme.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
TODOS:
|
||||||
|
|
||||||
|
-Add ballistics calculation over time not pixel x framerate
|
||||||
6
requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
altgraph==0.17.4
|
||||||
|
packaging==24.1
|
||||||
|
pygame==2.6.0
|
||||||
|
pyinstaller==6.10.0
|
||||||
|
pyinstaller-hooks-contrib==2024.8
|
||||||
|
setuptools==72.2.0
|
||||||
56
sprites/Zeichnung.svg
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="500"
|
||||||
|
height="500"
|
||||||
|
viewBox="0 0 132.29166 132.29167"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||||
|
sodipodi:docname="Zeichnung.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:zoom="4.1478114"
|
||||||
|
inkscape:cx="106.32113"
|
||||||
|
inkscape:cy="96.436399"
|
||||||
|
inkscape:window-width="2560"
|
||||||
|
inkscape:window-height="1368"
|
||||||
|
inkscape:window-x="2560"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs1" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Ebene 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="fill:#ff00ff;stroke-width:0.251734"
|
||||||
|
id="rect1"
|
||||||
|
width="132.29167"
|
||||||
|
height="132.29167"
|
||||||
|
x="0"
|
||||||
|
y="0" />
|
||||||
|
<rect
|
||||||
|
style="fill:#241c1c;stroke-width:0.130533"
|
||||||
|
id="rect2"
|
||||||
|
width="7.9375"
|
||||||
|
height="7.9375"
|
||||||
|
x="0"
|
||||||
|
y="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
56
sprites/backgorund1.svg
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="500"
|
||||||
|
height="500"
|
||||||
|
viewBox="0 0 132.29166 132.29167"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||||
|
sodipodi:docname="backgorund1.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:zoom="4.1478114"
|
||||||
|
inkscape:cx="106.32113"
|
||||||
|
inkscape:cy="96.436399"
|
||||||
|
inkscape:window-width="2560"
|
||||||
|
inkscape:window-height="1368"
|
||||||
|
inkscape:window-x="2560"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs1" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Ebene 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="fill:#ff00ff;stroke-width:0.251734"
|
||||||
|
id="rect1"
|
||||||
|
width="132.29167"
|
||||||
|
height="132.29167"
|
||||||
|
x="0"
|
||||||
|
y="0" />
|
||||||
|
<rect
|
||||||
|
style="fill:#241c1c;stroke-width:0.130533"
|
||||||
|
id="rect2"
|
||||||
|
width="7.9375"
|
||||||
|
height="7.9375"
|
||||||
|
x="0"
|
||||||
|
y="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
BIN
sprites/enemy_1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
75
sprites/enemy_1.svg
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="60"
|
||||||
|
height="60"
|
||||||
|
viewBox="0 0 15.874998 15.874998"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||||
|
sodipodi:docname="enemy_1.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:zoom="5.8658912"
|
||||||
|
inkscape:cx="66.145107"
|
||||||
|
inkscape:cy="36.823049"
|
||||||
|
inkscape:window-width="2560"
|
||||||
|
inkscape:window-height="1368"
|
||||||
|
inkscape:window-x="2560"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs1">
|
||||||
|
<inkscape:path-effect
|
||||||
|
effect="bspline"
|
||||||
|
id="path-effect10"
|
||||||
|
is_visible="true"
|
||||||
|
lpeversion="1.3"
|
||||||
|
weight="33.333333"
|
||||||
|
steps="2"
|
||||||
|
helper_size="0"
|
||||||
|
apply_no_weight="true"
|
||||||
|
apply_with_weight="true"
|
||||||
|
only_selected="false"
|
||||||
|
uniform="false" />
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
inkscape:label="Ebene 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<path
|
||||||
|
style="fill:#44a900;stroke-width:0.264583"
|
||||||
|
d="m -23.680329,-16.283045 c 0,0 31.3031395,20.4327406 31.3031395,20.4327406"
|
||||||
|
id="path10"
|
||||||
|
inkscape:path-effect="#path-effect10"
|
||||||
|
inkscape:original-d="M -23.680329,-16.283045 7.6228105,4.1496956" />
|
||||||
|
<ellipse
|
||||||
|
style="fill:#b3b3b3;stroke-width:0.335313"
|
||||||
|
id="path11"
|
||||||
|
cx="7.8524895"
|
||||||
|
cy="7.7682891"
|
||||||
|
rx="3.9080892"
|
||||||
|
ry="4.1147518" />
|
||||||
|
<ellipse
|
||||||
|
style="fill:#b3b3b3;stroke-width:0.3716"
|
||||||
|
id="path12"
|
||||||
|
cx="7.937499"
|
||||||
|
cy="9.6954823"
|
||||||
|
rx="7.937499"
|
||||||
|
ry="3.6149874" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.1 KiB |
411
sprites/just_fun.svg
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
sprites/spaceship_1.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
406
sprites/spaceship_1.svg
Normal file
|
After Width: | Height: | Size: 281 KiB |
BIN
sprites/spaceship_1_transp.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
291
test.py
@@ -1,8 +1,8 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import game
|
import game
|
||||||
import levels
|
|
||||||
import logger
|
import logger
|
||||||
import weapons
|
import weapons
|
||||||
|
import interface
|
||||||
import GameObject
|
import GameObject
|
||||||
import Utils
|
import Utils
|
||||||
import time
|
import time
|
||||||
@@ -14,14 +14,12 @@ pygame.init()
|
|||||||
pygame.display.set_caption("TESTFENSTER")
|
pygame.display.set_caption("TESTFENSTER")
|
||||||
pygame.mouse.set_visible(True)
|
pygame.mouse.set_visible(True)
|
||||||
|
|
||||||
RENDERING_SIZE = (1024,768)
|
RENDERING_SIZE = (1280,720)
|
||||||
WINDOWED_DEF_SIZE = (1024,768)
|
WINDOWED_DEF_SIZE = (1280,720)
|
||||||
#pygame.key.set_repeat(1, 30)
|
#pygame.key.set_repeat(1, 30)
|
||||||
window = pygame.display.set_mode((2440,1200), pygame.FULLSCREEN)
|
window = pygame.display.set_mode((RENDERING_SIZE))
|
||||||
screen = pygame.Surface(RENDERING_SIZE)
|
screen = pygame.Surface(RENDERING_SIZE)
|
||||||
|
|
||||||
#screen = pygame.display.set_mode((1024,768)) #TODO Add fullscreen mode
|
|
||||||
|
|
||||||
log = logger.log("log.txt")
|
log = logger.log("log.txt")
|
||||||
|
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
@@ -37,6 +35,8 @@ log.writeln("Loading images...")
|
|||||||
|
|
||||||
image_enemy = Utils.load_image("Rastergrafik.png")
|
image_enemy = Utils.load_image("Rastergrafik.png")
|
||||||
testimage = Utils.load_image("Rastergrafik.png")
|
testimage = Utils.load_image("Rastergrafik.png")
|
||||||
|
enemy1 = Utils.load_image("sprites/enemy_1.png")
|
||||||
|
spaceship = Utils.load_image("sprites/spaceship_1_transp.png", (255,0,255))
|
||||||
|
|
||||||
log.writeln("Setup fonts...")
|
log.writeln("Setup fonts...")
|
||||||
font1 = pygame.font.Font("/usr/share/fonts/TTF/Inconsolata-UltraExpandedExtraBold.ttf", 30)
|
font1 = pygame.font.Font("/usr/share/fonts/TTF/Inconsolata-UltraExpandedExtraBold.ttf", 30)
|
||||||
@@ -49,8 +49,14 @@ log.writeln(F"Git-Hash: {short_hash}")
|
|||||||
|
|
||||||
#testimage.set_colorkey((255,0,255), pygame.RLEACCELOK)
|
#testimage.set_colorkey((255,0,255), pygame.RLEACCELOK)
|
||||||
|
|
||||||
player1 = GameObject.Player("Player", screen,(screen.get_size()[0]/2)-17, screen.get_size()[1]-100, 35, 35, testimage)
|
players = [
|
||||||
player2 = GameObject.Player2("Player2", screen,(screen.get_size()[0]/2)-17, screen.get_size()[1]-100, 35, 35, testimage)
|
GameObject.Player("Player", screen,(screen.get_size()[0]/2)-17, screen.get_size()[1]-175, 60, 60, spaceship),
|
||||||
|
GameObject.Player2("Player2", screen,(screen.get_size()[0]/2)-17, screen.get_size()[1]-175, 60, 60, spaceship)
|
||||||
|
]
|
||||||
|
|
||||||
|
player1 = GameObject.Player("Player", screen,(screen.get_size()[0]/2)-17, screen.get_size()[1]-175, 60, 60, spaceship)
|
||||||
|
player2 = GameObject.Player2("Player2", screen,(screen.get_size()[0]/2)-17, screen.get_size()[1]-175, 60, 60, spaceship)
|
||||||
|
|
||||||
|
|
||||||
game.loadlevels()
|
game.loadlevels()
|
||||||
|
|
||||||
@@ -59,25 +65,33 @@ spawned_enemys = list()
|
|||||||
i = 0
|
i = 0
|
||||||
startpos_x = 50
|
startpos_x = 50
|
||||||
startpos_y = 30
|
startpos_y = 30
|
||||||
for enemys in range(1):
|
for enemys in range(80):
|
||||||
tmp_weapon = weapons.Laserblaster("Laserblaster", startpos_x, startpos_y, 5, 10, screen, testimage)
|
tmp_weapon = weapons.Laserblaster("Laserblaster", startpos_x, startpos_y+60, 5, 10, 30, 1, 0, screen, testimage)
|
||||||
tmp = GameObject.Enemy(F"Enemy-{i}", startpos_x,startpos_y,35,35, screen, testimage)
|
tmp = GameObject.Enemy(F"Enemy-{i}", startpos_x,startpos_y,60,60, screen, enemy1)
|
||||||
tmp.give_weapon(tmp_weapon)
|
tmp.give_weapon(tmp_weapon)
|
||||||
if(startpos_x >= (screen.get_size()[0]-150)):
|
if(startpos_x >= (screen.get_size()[0]-150)):
|
||||||
startpos_y += 50
|
startpos_y += 50
|
||||||
startpos_x = 0
|
startpos_x = 0
|
||||||
print(tmp.get_weapon())
|
print(tmp.get_weapon())
|
||||||
spawned_enemys.append(tmp)
|
spawned_enemys.append(tmp)
|
||||||
startpos_x += 50
|
startpos_x += (tmp.width+15)
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
startpos_x = 500
|
||||||
|
startpos_y = 500
|
||||||
|
tmp_weapon = weapons.Laserblaster("Laserblaster", startpos_x, startpos_y+60, 5, 10, 30, 1, 0, screen, testimage)
|
||||||
|
e1 = GameObject.Enemy(F"Enemy-{i}", startpos_x,startpos_y,60,60, screen, enemy1)
|
||||||
|
e1.give_weapon(tmp_weapon)
|
||||||
|
|
||||||
gamestate = True
|
gamestate = True
|
||||||
frametime =0
|
|
||||||
milliseconds = pygame.time.get_ticks()
|
milliseconds = pygame.time.get_ticks()
|
||||||
|
tmp_time = pygame.time.get_ticks()/1000
|
||||||
|
|
||||||
seconds = milliseconds/1000
|
seconds = milliseconds/1000
|
||||||
|
|
||||||
|
tmp_seconds = 0
|
||||||
|
|
||||||
while(gamestate):
|
while(gamestate):
|
||||||
screen.fill((8,31,61))
|
screen.fill((8,31,61))
|
||||||
|
|
||||||
@@ -86,27 +100,135 @@ while(gamestate):
|
|||||||
del log
|
del log
|
||||||
gamestate = False
|
gamestate = False
|
||||||
if(event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
|
||||||
|
pygame.display.set_mode((RENDERING_SIZE))
|
||||||
gamestate = False
|
gamestate = False
|
||||||
player1.handle_input(event)
|
#Push F10 for fullscreen-mode
|
||||||
player2.handle_input(event)
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_F10):
|
||||||
|
pygame.display.set_mode(RENDERING_SIZE, pygame.FULLSCREEN)
|
||||||
|
#Push F9 for window-mode
|
||||||
|
if(event.type == pygame.KEYDOWN and event.key == pygame.K_F9):
|
||||||
|
pygame.display.set_mode((RENDERING_SIZE))
|
||||||
|
|
||||||
|
for player in players:
|
||||||
|
player:GameObject.Player
|
||||||
|
player.handle_input(event)
|
||||||
|
|
||||||
|
for player in players:
|
||||||
|
player:GameObject.Player
|
||||||
|
if(player.keymap["left"] == True and player.pos_x > 0):
|
||||||
|
player.move("left")
|
||||||
|
#print("links")
|
||||||
|
if(player.keymap["right"] == True and player.pos_x <= (screen.get_size()[0]-player.width)):
|
||||||
|
player.move("right")
|
||||||
|
|
||||||
if(player1.keymap["left"] == True and player1.pos_x > 0):
|
player.update_interface()
|
||||||
player1.move("left")
|
player.render(screen)
|
||||||
#print("links")
|
|
||||||
if(player1.keymap["right"] == True and player1.pos_x <= (screen.get_size()[0]-player1.width)):
|
|
||||||
player1.move("right")
|
|
||||||
#print("rechts")
|
|
||||||
|
|
||||||
if(player2.keymap["left"] == True and player2.pos_x > 0):
|
game.run(screen)
|
||||||
player2.move("left")
|
|
||||||
#print("links")
|
|
||||||
if(player2.keymap["right"] == True and player2.pos_x <= (screen.get_size()[0]-player2.width)):
|
|
||||||
player2.move("right")
|
|
||||||
#print("rechts")
|
|
||||||
|
|
||||||
#image = screen.blit(testimage, (pos_x, pos_y))
|
player1.firecontrol(screen)
|
||||||
|
player2.firecontrol(screen)
|
||||||
|
|
||||||
mouse_pos = pygame.mouse.get_pos()
|
for key, obj in enumerate(GameObject.GameObject.objects):
|
||||||
|
print(key, obj)
|
||||||
|
|
||||||
|
|
||||||
|
#TODO If Playerposition are on the same x-axis then gamble hit by 50% chance
|
||||||
|
|
||||||
|
for projectiles in GameObject.Projectile.shots:
|
||||||
|
projectiles:dict
|
||||||
|
for key, projectile in projectiles.items():
|
||||||
|
projectile:GameObject.Projectile
|
||||||
|
#Check if player hits an enemy delete it
|
||||||
|
for enemy in spawned_enemys:
|
||||||
|
enemy:GameObject.Enemy
|
||||||
|
if(pygame.Rect.colliderect(projectile.rect, enemy.rect)):
|
||||||
|
#Check if only a playerhit despawn enemys
|
||||||
|
if(projectile.name == "Player" or projectile.name == "Player2"):
|
||||||
|
if len(players) == 2:
|
||||||
|
players[0].points += 10
|
||||||
|
players[1].points += 10
|
||||||
|
else:
|
||||||
|
players[0].points += 10
|
||||||
|
|
||||||
|
index = spawned_enemys.index(enemy)
|
||||||
|
del spawned_enemys[index]
|
||||||
|
index = GameObject.Projectile.shots.index(projectiles)
|
||||||
|
del GameObject.Projectile.shots[index]
|
||||||
|
index = GameObject.GameObject.objects.index(projectile)
|
||||||
|
#Report playerkills by player
|
||||||
|
if(projectile.name == "Player"):
|
||||||
|
players[0].kills += 1
|
||||||
|
|
||||||
|
if(projectile.name == "Player2"):
|
||||||
|
players[1].kills += 1
|
||||||
|
|
||||||
|
#TODO Buggy pygame colliderect is true until projectile passed the hole playrect
|
||||||
|
# Life decrease only once!
|
||||||
|
for player in players:
|
||||||
|
player:GameObject.Player
|
||||||
|
if(pygame.Rect.colliderect(projectile.rect, player.rect)):
|
||||||
|
#print("Game-Over")
|
||||||
|
player.get_damage(enemy.get_weapon().damage)
|
||||||
|
try:
|
||||||
|
index = GameObject.Projectile.shots.index(projectiles)
|
||||||
|
del GameObject.Projectile.shots[index]
|
||||||
|
except:
|
||||||
|
print("Error on indexing projectile")
|
||||||
|
#TODO Add Gameover event
|
||||||
|
|
||||||
|
#Check for bullets out of playground and delete it
|
||||||
|
if((projectile.pos_y > screen.get_size()[1]) or (projectile.pos_y < 0)):
|
||||||
|
#print(F"Lösche: {projectile}")
|
||||||
|
index = GameObject.Projectile.shots.index(projectiles)
|
||||||
|
del GameObject.Projectile.shots[index]
|
||||||
|
|
||||||
|
milliseconds = pygame.time.get_ticks()
|
||||||
|
seconds = milliseconds / 1000
|
||||||
|
now = time.time_ns()
|
||||||
|
rand = random.randint(0, 100)
|
||||||
|
|
||||||
|
for enemy in spawned_enemys:
|
||||||
|
enemy:GameObject.Enemy
|
||||||
|
if rand == 20 and (enemy.pos_x != 0 or enemy.pos_x >= (screen.get_size()[0]+enemy.width)):
|
||||||
|
enemy.move(5)
|
||||||
|
#enemy.movementqueue.append(5)
|
||||||
|
if rand == 50 and (enemy.pos_x != 0 or enemy.pos_x >= (screen.get_size()[0]+enemy.width)):
|
||||||
|
enemy.move(-5)
|
||||||
|
#enemy.movementqueue.append(-5)
|
||||||
|
rand1 = random.randint(0, 1000)
|
||||||
|
if rand1 == 50:
|
||||||
|
enemy.fire(screen)
|
||||||
|
|
||||||
|
enemy.render(screen)
|
||||||
|
|
||||||
|
enemy.firecontrol(screen)
|
||||||
|
|
||||||
|
screen
|
||||||
|
|
||||||
|
label1 = font1.render(F"Score: {player1.points}", True, (255,0,0))
|
||||||
|
fps_label = font2.render(F"FPS: {int(clock.get_fps())}", True, (255,0,0))
|
||||||
|
screen.blit(label1, ((screen.get_size()[0]/2)-(label1.get_size()[0]/2), screen.get_size()[1]-50))
|
||||||
|
screen.blit(fps_label, (screen.get_size()[0]-fps_label.get_size()[0]-10, screen.get_size()[1]-25))
|
||||||
|
screen.blit(hash_label, (25, screen.get_size()[1] -25))
|
||||||
|
|
||||||
|
#Scales the mainsurface
|
||||||
|
scaled_win = pygame.transform.scale(screen, window.get_size())
|
||||||
|
#Blits the mainsurface to the mainwindow
|
||||||
|
window.blit(scaled_win, (0, 0))
|
||||||
|
|
||||||
|
clock.tick(60)
|
||||||
|
pygame.display.flip()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#image = screen.blit(testimage, (pos_x, pos_y))
|
||||||
|
|
||||||
|
#mouse_pos = pygame.mouse.get_pos()
|
||||||
|
#print(int(pygame.time.get_ticks()/1000))
|
||||||
|
|
||||||
#print(mouse_pos)
|
#print(mouse_pos)
|
||||||
#print(image.topleft) #Gibt die Position einen Surfaces "obenlinks" aus
|
#print(image.topleft) #Gibt die Position einen Surfaces "obenlinks" aus
|
||||||
@@ -119,111 +241,4 @@ while(gamestate):
|
|||||||
#if(mouse_pos[1] <= max[1] and mouse_pos[1] >= image.topleft[1]):
|
#if(mouse_pos[1] <= max[1] and mouse_pos[1] >= image.topleft[1]):
|
||||||
#print("Treffer")
|
#print("Treffer")
|
||||||
#pos_x = mouse_pos[0]
|
#pos_x = mouse_pos[0]
|
||||||
#pos_y = mouse_pos[1]
|
#pos_y = mouse_pos[1]
|
||||||
|
|
||||||
player1.firecontrol(screen)
|
|
||||||
player2.firecontrol(screen)
|
|
||||||
|
|
||||||
#print("Spieler1 Lifes: ", player1.lifes)
|
|
||||||
#print("Spieler2 Lifes: ", player2.lifes)
|
|
||||||
|
|
||||||
#TODO If Playerposition are on the same x-axis then gamble hit by 50% chance
|
|
||||||
|
|
||||||
for projectiles in GameObject.Projectile.shots:
|
|
||||||
projectiles:dict
|
|
||||||
for key, projectile in projectiles.items():
|
|
||||||
projectile:GameObject.Projectile
|
|
||||||
#Check if player hits an enemy delete it
|
|
||||||
for enemy in spawned_enemys:
|
|
||||||
enemy:GameObject.Enemy
|
|
||||||
if(pygame.Rect.colliderect(player1.rect, player2.rect)):
|
|
||||||
#TODO: Laterrr!!
|
|
||||||
#print("Collision")
|
|
||||||
pass
|
|
||||||
if(pygame.Rect.colliderect(projectile.rect, enemy.rect)):
|
|
||||||
#print("HIT")
|
|
||||||
#Check if only a playerhit despawn enemys
|
|
||||||
if(projectile.name == "Player" or projectile.name == "Player2"):
|
|
||||||
player1.points += 10
|
|
||||||
player2.points += 10
|
|
||||||
index = spawned_enemys.index(enemy)
|
|
||||||
del spawned_enemys[index]
|
|
||||||
index = GameObject.Projectile.shots.index(projectiles)
|
|
||||||
del GameObject.Projectile.shots[index]
|
|
||||||
#print(F"Player-Points: {player1.points}")
|
|
||||||
#print(F"Player-Points: {player2.points}")
|
|
||||||
if(projectile.name == "Player"):
|
|
||||||
player1.kills += 1
|
|
||||||
|
|
||||||
if(projectile.name == "Player2"):
|
|
||||||
player2.kills += 1
|
|
||||||
|
|
||||||
#TODO Buggy pygame colliderect is true until projectile passed the hole playrect
|
|
||||||
# Life decrease only once!
|
|
||||||
if(pygame.Rect.colliderect(projectile.rect, player1.rect)):
|
|
||||||
#print("Game-Over")
|
|
||||||
player1.lifes -= 1
|
|
||||||
try:
|
|
||||||
index = GameObject.Projectile.shots.index(projectiles)
|
|
||||||
del GameObject.Projectile.shots[index]
|
|
||||||
except:
|
|
||||||
print("Error on indexing projectile")
|
|
||||||
#TODO Add Gameover event
|
|
||||||
if(pygame.Rect.colliderect(projectile.rect, player2.rect)):
|
|
||||||
#print("Game-Over")
|
|
||||||
player2.lifes -= 1
|
|
||||||
try:
|
|
||||||
index = GameObject.Projectile.shots.index(projectiles)
|
|
||||||
del GameObject.Projectile.shots[index]
|
|
||||||
except:
|
|
||||||
print("Error on indexing projectile")
|
|
||||||
#TODO Add Gameover event
|
|
||||||
|
|
||||||
#Check for bullets out of playground and delete it
|
|
||||||
if((projectile.pos_y > screen.get_size()[1]) or (projectile.pos_y < 0)):
|
|
||||||
#print(F"Lösche: {projectile}")
|
|
||||||
index = GameObject.Projectile.shots.index(projectiles)
|
|
||||||
del GameObject.Projectile.shots[index]
|
|
||||||
|
|
||||||
milliseconds = pygame.time.get_ticks()
|
|
||||||
seconds = milliseconds / 1000
|
|
||||||
now = time.time_ns()
|
|
||||||
|
|
||||||
#print("Playerkills 1:", player1.kills)
|
|
||||||
#print("Playerkills 2:", player2.kills)
|
|
||||||
|
|
||||||
player1.render(screen)
|
|
||||||
player2.render(screen)
|
|
||||||
#print(int(seconds), "\r")
|
|
||||||
|
|
||||||
rand = random.randint(0, 100)
|
|
||||||
for enemy in spawned_enemys:
|
|
||||||
enemy:GameObject.Enemy
|
|
||||||
if rand == 20:
|
|
||||||
enemy.move(5)
|
|
||||||
#enemy.movementqueue.append(5)
|
|
||||||
if rand == 50:
|
|
||||||
enemy.move(-5)
|
|
||||||
#enemy.movementqueue.append(-5)
|
|
||||||
rand1 = random.randint(0, 1000)
|
|
||||||
if rand1 == 50:
|
|
||||||
enemy.fire(screen)
|
|
||||||
|
|
||||||
enemy.render(screen)
|
|
||||||
|
|
||||||
enemy.firecontrol(screen)
|
|
||||||
|
|
||||||
label1 = font1.render(F"Score: {player1.points}", True, (255,0,0))
|
|
||||||
fps_label = font2.render(F"FPS: {int(clock.get_fps())}", True, (255,0,0))
|
|
||||||
screen.blit(label1, ((screen.get_size()[0]/2)-(label1.get_size()[0]/2), screen.get_size()[1]-50))
|
|
||||||
screen.blit(fps_label, (screen.get_size()[0]-fps_label.get_size()[0]-10, screen.get_size()[1]-25))
|
|
||||||
screen.blit(hash_label, (25, screen.get_size()[1] -25))
|
|
||||||
|
|
||||||
frametime = clock.get_time()
|
|
||||||
scaled_win = pygame.transform.smoothscale(screen, window.get_size())
|
|
||||||
window.blit(scaled_win, (0, 0))
|
|
||||||
#if(mouse_pos <= (image.topleft+image.size) and mouse_pos >= image.topleft):
|
|
||||||
# print("HIIIIITTT!!!!")
|
|
||||||
frametime = 0
|
|
||||||
clock.tick(60)
|
|
||||||
pygame.display.flip()
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import GameObject
|
import GameObject
|
||||||
|
|
||||||
class Laserblaster(GameObject.Weapons):
|
class Laserblaster(GameObject.Weapons):
|
||||||
def __init__(self, name, pos_x, pos_y, width, height, screen, image=None) -> None:
|
def __init__(self, name, pos_x, pos_y, width, height, damage:int, firerate:int, duration:int, screen, image=None) -> None:
|
||||||
super().__init__(name, pos_x, pos_y, width, height, 10, 2, 0, image)
|
super().__init__(name, pos_x, pos_y, width, height, damage, firerate, duration, screen, image)
|
||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.image = image
|
self.image = image
|
||||||
|
|
||||||
def fire(self):
|
def fire(self):
|
||||||
self.projectile = GameObject.Projectile("Enemy", self.pos_x, self.pos_y, 5, 10, self.screen, 2, self.image)
|
self.projectile = GameObject.Projectile("Enemy", self.pos_x, self.pos_y, 5, 10, self.screen, 2, self.image)
|
||||||
|
|||||||