Refractored
Before Width: | Height: | Size: 909 B After Width: | Height: | Size: 14 KiB |
@ -11,7 +11,7 @@ class Game():
|
|||||||
self.DISPLAY_WIDTH, self.DISPLAY_HEIGHT = 1280, 720
|
self.DISPLAY_WIDTH, self.DISPLAY_HEIGHT = 1280, 720
|
||||||
self.window = pygame.Surface((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT))
|
self.window = pygame.Surface((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT))
|
||||||
self.realwindow = pygame.display.set_mode((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT))
|
self.realwindow = pygame.display.set_mode((self.DISPLAY_WIDTH,self.DISPLAY_HEIGHT))
|
||||||
pygame.display.set_caption("kfr 2 ???")
|
pygame.display.set_caption("Overflown")
|
||||||
pygame.init()
|
pygame.init()
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class Game():
|
|||||||
self.pasttime = time.time()
|
self.pasttime = time.time()
|
||||||
|
|
||||||
# Je charge la scene de base
|
# Je charge la scene de base
|
||||||
scenes.fight(self)
|
scenes.ingame(self)
|
||||||
|
|
||||||
def set_camera(self,posx,posy):
|
def set_camera(self,posx,posy):
|
||||||
self.globals["camerax"], self.globals["cameray"] = posx,posy
|
self.globals["camerax"], self.globals["cameray"] = posx,posy
|
||||||
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@ -4925,14 +4925,17 @@
|
|||||||
{"name": "Balloon", "id": 37, "_eid": "16494694", "x": 1360, "y": 160, "originX": 0, "originY": 0},
|
{"name": "Balloon", "id": 37, "_eid": "16494694", "x": 1360, "y": 160, "originX": 0, "originY": 0},
|
||||||
{"name": "Balloon", "id": 38, "_eid": "16494694", "x": 1264, "y": 128, "originX": 0, "originY": 0},
|
{"name": "Balloon", "id": 38, "_eid": "16494694", "x": 1264, "y": 128, "originX": 0, "originY": 0},
|
||||||
{
|
{
|
||||||
"name": "Spring",
|
"name": "WaterChange",
|
||||||
"id": 39,
|
"id": 40,
|
||||||
"_eid": "24018769",
|
"_eid": "48957583",
|
||||||
"x": 912,
|
"x": 208,
|
||||||
"y": 336,
|
"y": 208,
|
||||||
"originX": 0,
|
"originX": 0,
|
||||||
"originY": 0,
|
"originY": 0,
|
||||||
"values": {"angle": 180, "strength": 7}
|
"nodes": [
|
||||||
|
{"x": 240, "y": 240}
|
||||||
|
],
|
||||||
|
"values": {"Speed": 1}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
|
||||||
|
|
||||||
class Balloon(Ennemy):
|
class Balloon(Ennemy):
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
|
||||||
|
|
||||||
class Crate(Ennemy):
|
class Crate(Ennemy):
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from gamedata.objects.combat.movable import Movable
|
from gamedata.objects.ingame.movable import Movable
|
||||||
|
|
||||||
class Ennemy(Movable):
|
class Ennemy(Movable):
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
|
||||||
|
|
||||||
class Robot(Ennemy):
|
class Robot(Ennemy):
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
|
||||||
|
|
||||||
class Spring(Ennemy):
|
class Spring(Ennemy):
|
||||||
|
|
23
gamedata/objects/ingame/ennemies/waterchange.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
|
||||||
|
|
||||||
|
class WaterChange(Ennemy):
|
||||||
|
|
||||||
|
def __init__(self,*args):
|
||||||
|
|
||||||
|
super().__init__(*args)
|
||||||
|
self.rect[2] = self.tileset.tilew
|
||||||
|
self.rect[3] = self.tileset.tileh
|
||||||
|
self.canhit = False
|
||||||
|
self.candie = False
|
||||||
|
|
||||||
|
self.objective = self.nodes[0]["y"]+8
|
||||||
|
self.speed = self.customvalues["Speed"]
|
||||||
|
|
||||||
|
def step(self):
|
||||||
|
super().step()
|
||||||
|
if self.rect.colliderect(self.player.rect):
|
||||||
|
self.water.destinationy = self.objective
|
||||||
|
self.water.speed = self.speed
|
||||||
|
|
||||||
|
def draw(self):
|
||||||
|
pass
|
@ -1,4 +1,4 @@
|
|||||||
from gamedata.objects.combat.movable import Movable
|
from gamedata.objects.ingame.movable import Movable
|
||||||
|
|
||||||
class Player(Movable):
|
class Player(Movable):
|
||||||
|
|
@ -1,8 +1,9 @@
|
|||||||
from gamedata.objects.base import BaseObject
|
from gamedata.objects.base import BaseObject
|
||||||
from gamedata.objects.combat.ennemies.robot import Robot
|
from gamedata.objects.ingame.ennemies.robot import Robot
|
||||||
from gamedata.objects.combat.ennemies.crate import Crate
|
from gamedata.objects.ingame.ennemies.crate import Crate
|
||||||
from gamedata.objects.combat.ennemies.balloon import Balloon
|
from gamedata.objects.ingame.ennemies.balloon import Balloon
|
||||||
from gamedata.objects.combat.ennemies.spring import Spring
|
from gamedata.objects.ingame.ennemies.spring import Spring
|
||||||
|
from gamedata.objects.ingame.ennemies.waterchange import WaterChange
|
||||||
|
|
||||||
class TilesetRenderer(BaseObject):
|
class TilesetRenderer(BaseObject):
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ class TilesetRenderer(BaseObject):
|
|||||||
self.layers = []
|
self.layers = []
|
||||||
self.spawns = []
|
self.spawns = []
|
||||||
spawnlists = {"Spawns":self.spawns}
|
spawnlists = {"Spawns":self.spawns}
|
||||||
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring}
|
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring,"WaterChange":WaterChange}
|
||||||
self.queue = [] # For spawning ennemies after beeing initialized
|
self.queue = [] # For spawning ennemies after beeing initialized
|
||||||
if "layers" in json.keys() and type(json["layers"]).__name__=="list":
|
if "layers" in json.keys() and type(json["layers"]).__name__=="list":
|
||||||
solidlayer = False
|
solidlayer = False
|
@ -2,11 +2,14 @@ from gamedata.objects.base import BaseObject
|
|||||||
|
|
||||||
class Water(BaseObject):
|
class Water(BaseObject):
|
||||||
|
|
||||||
def __init__(self,y,game):
|
def __init__(self,game):
|
||||||
|
|
||||||
|
self.tileset = game.gameloop.findname("TilesetRenderer")[0]
|
||||||
|
y = self.tileset.spawns[0].center[1]+game.globals["camerah"]/2
|
||||||
|
self.destinationy = y
|
||||||
|
|
||||||
super().__init__(0,y,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
|
super().__init__(0,y,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
|
||||||
|
|
||||||
self.destinationy = y
|
|
||||||
self.speed = 10
|
self.speed = 10
|
||||||
|
|
||||||
self.depth = 2
|
self.depth = 2
|
@ -4,11 +4,11 @@ from gamedata.objects.bg.menubackground import MenuBackground
|
|||||||
from gamedata.objects.menu.optionmenu import OptionMenu
|
from gamedata.objects.menu.optionmenu import OptionMenu
|
||||||
from gamedata.objects.sliders.bgmslider import BGMSlider
|
from gamedata.objects.sliders.bgmslider import BGMSlider
|
||||||
from gamedata.objects.sliders.sfxslider import SFXSlider
|
from gamedata.objects.sliders.sfxslider import SFXSlider
|
||||||
from gamedata.objects.combat.player import Player
|
from gamedata.objects.ingame.player import Player
|
||||||
from gamedata.objects.combat.manager import FightManager
|
from gamedata.objects.ingame.manager import FightManager
|
||||||
from gamedata.objects.combat.hitbox import Hitbox
|
from gamedata.objects.ingame.hitbox import Hitbox
|
||||||
from gamedata.objects.combat.tileset import TilesetRenderer
|
from gamedata.objects.ingame.tileset import TilesetRenderer
|
||||||
from gamedata.objects.combat.water import Water
|
from gamedata.objects.ingame.water import Water
|
||||||
|
|
||||||
def main(game):
|
def main(game):
|
||||||
game.scaleCamera()
|
game.scaleCamera()
|
||||||
@ -18,17 +18,12 @@ def main(game):
|
|||||||
game.gameloop.summon(bg)
|
game.gameloop.summon(bg)
|
||||||
game.gameloop.summon(menu)
|
game.gameloop.summon(menu)
|
||||||
|
|
||||||
def fight(game):
|
def ingame(game,level="Level 1"):
|
||||||
game.scaleCamera(416,234)
|
game.scaleCamera(416,234)
|
||||||
game.gameloop.reinit()
|
game.gameloop.reinit()
|
||||||
mapname = game.lib.choice(list(game.levels_lib.keys()))
|
tileset = TilesetRenderer(0,0,game,level)
|
||||||
manager = FightManager(game)
|
|
||||||
game.gameloop.summon(manager)
|
|
||||||
tileset = TilesetRenderer(0,0,game,mapname)
|
|
||||||
game.gameloop.summon(tileset)
|
game.gameloop.summon(tileset)
|
||||||
box = Hitbox(100,80,game)
|
water = Water(game)
|
||||||
game.gameloop.summon(box)
|
|
||||||
water = Water(250,game)
|
|
||||||
game.gameloop.summon(water)
|
game.gameloop.summon(water)
|
||||||
p1 = Player(game)
|
p1 = Player(game)
|
||||||
game.gameloop.summon(p1)
|
game.gameloop.summon(p1)
|
||||||
|