Added some decorations on menu

This commit is contained in:
theo@manjaro 2021-09-16 08:19:35 +02:00
parent 6a31017952
commit 87731f167b
5 changed files with 25 additions and 10 deletions

View File

@ -61,7 +61,7 @@ class Game():
self.pasttime = time.time() self.pasttime = time.time()
# Je charge la scene de base # Je charge la scene de base
scenes.ingame(self) scenes.main(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

View File

@ -1,17 +1,23 @@
from gamedata.objects.bg.backgrounddrawer import BackgroundDrawer from gamedata.objects.base import BaseObject
class MenuBackground(BackgroundDrawer): class MenuBackground(BaseObject):
def __init__(self,game): def __init__(self,game):
super().__init__(0,0,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT,game.sprite_lib["grid.png"],0.025) super().__init__(0,0,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
# Initialise son sprite # Islands
self.sprite = game.sprite_lib["ingame.png"]
# Shadow sprite
shadow = game.sprite_lib["shadow.png"] shadow = game.sprite_lib["shadow.png"]
self.shadow = game.pygame.transform.scale(shadow,(1500,1500)) # J'augmente la taille de l'ombre self.shadow = game.pygame.transform.scale(shadow,(1500,1500)) # J'augmente la taille de l'ombre
self.depth = 0
self.cameraratio = 0.1
def step(self): def step(self):
game = self.game game = self.game
super().step()
destx = (game.inputs["mouse"]["pos"][0]-game.DISPLAY_WIDTH/2) destx = (game.inputs["mouse"]["pos"][0]-game.DISPLAY_WIDTH/2)
desty = (game.inputs["mouse"]["pos"][1]-game.DISPLAY_HEIGHT/2) desty = (game.inputs["mouse"]["pos"][1]-game.DISPLAY_HEIGHT/2)
game.globals["camerax"] += (destx-game.globals["camerax"])/6 game.globals["camerax"] += (destx-game.globals["camerax"])/6
@ -19,5 +25,5 @@ class MenuBackground(BackgroundDrawer):
def draw(self): def draw(self):
game = self.game game = self.game
super().draw() game.window.blit(self.sprite,[-game.globals["camerax"]*self.cameraratio,-game.globals["cameray"]*self.cameraratio])
game.lib.drawcenter(game,self.shadow,game.DISPLAY_WIDTH/2,game.DISPLAY_HEIGHT*3/5) game.lib.drawcenter(game,self.shadow,game.DISPLAY_WIDTH/2,game.DISPLAY_HEIGHT*3/5)

View File

@ -8,7 +8,7 @@ class Clouds(BaseObject):
self.speed = speed self.speed = speed
self.minwidth = minwidth self.minwidth = minwidth
self.cameraratio = cameraratio self.cameraratio = cameraratio
depth = -1 self.depth = -2
self.horoffset = 0 self.horoffset = 0
def step(self): def step(self):
@ -18,4 +18,4 @@ class Clouds(BaseObject):
offset = (self.horoffset-self.game.globals["camerax"]*self.cameraratio)%self.sprite.get_width() offset = (self.horoffset-self.game.globals["camerax"]*self.cameraratio)%self.sprite.get_width()
nbsprites = round((self.minwidth+offset)//self.sprite.get_width()+2) nbsprites = round((self.minwidth+offset)//self.sprite.get_width()+2)
for i in range(nbsprites): for i in range(nbsprites):
self.game.window.blit(self.sprite,[(i-1)*self.sprite.get_width()+offset,0]) self.game.window.blit(self.sprite,[(i-1)*self.sprite.get_width()+offset,-self.game.globals["cameray"]*self.cameraratio])

View File

@ -17,7 +17,7 @@ class Skies(BaseObject):
self.speed = 0.02 self.speed = 0.02
self.timeelapsed = 0 self.timeelapsed = 0
self.depth = -2 self.depth = -3
self.blackrectalpha = 0.5 self.blackrectalpha = 0.5

View File

@ -7,12 +7,21 @@ from gamedata.objects.sliders.sfxslider import SFXSlider
from gamedata.objects.ingame.lemmings import Lemming from gamedata.objects.ingame.lemmings import Lemming
from gamedata.objects.ingame.manager import Manager from gamedata.objects.ingame.manager import Manager
from gamedata.objects.gameover import GameOver from gamedata.objects.gameover import GameOver
from gamedata.objects.ingame.skies import Skies
from gamedata.objects.ingame.clouds import Clouds
def main(game): def main(game):
game.scaleCamera() game.scaleCamera()
game.gameloop.reinit() game.gameloop.reinit()
bg = MenuBackground(game) bg = MenuBackground(game)
skies = Skies(game)
# Clouds in the background
clouds = Clouds(game,game.DISPLAY_WIDTH,speed=30,cameraratio=0.05)
cloudsdark = Clouds(game,game.DISPLAY_WIDTH,speed=10,cameraratio=0.02,spritename="cloudsdark.png")
game.gameloop.summon(cloudsdark)
game.gameloop.summon(clouds)
menu = MainMenu(game.DISPLAY_WIDTH/4,round(game.DISPLAY_HEIGHT*3/8),game,game.DISPLAY_WIDTH//2,game.DISPLAY_HEIGHT//2) menu = MainMenu(game.DISPLAY_WIDTH/4,round(game.DISPLAY_HEIGHT*3/8),game,game.DISPLAY_WIDTH//2,game.DISPLAY_HEIGHT//2)
game.gameloop.summon(skies)
game.gameloop.summon(bg) game.gameloop.summon(bg)
game.gameloop.summon(menu) game.gameloop.summon(menu)