Black screen on start

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Nerdzmasterz
Prole
Posts: 4
Joined: Wed Feb 12, 2020 10:26 pm

Black screen on start

Post by Nerdzmasterz »

Hi, there!

I honestly don't know what I did. Things were great until I decided to use HUMP's camera to adjust the camera for only one scene, not both of them. Here is the main.lua file. The player code only has the images of the player and its X and Y position, so it's unrelated.

Code: Select all

windowCenterX     = love.graphics.getWidth() / 2
windowCenterY     = love.graphics.getHeight() / 2
startButtonWidth  = 228
startButtonHeight = 34
startButtonStartX = windowCenterX - (startButtonWidth / 2)
startButtonStartY = windowCenterY - (startButtonHeight / 2)
startButtonEndX   = startButtonStartX + startButtonWidth
startButtonEndY   = startButtonStartY + startButtonHeight

level = 0

function love.load()
  
  require("Player")
  sti = require("Simple-Tiled-Implementation-master/sti")
  
  BrokenBridge = sti("maps/BrokenBridge.lua")
  
  themeSound = love.audio.newSource("sounds/mad_scientist.mp3", "static")
  themeSound:setLooping(true)
  themeSound:play()
  
  sprites = {}
  sprites.background1 = love.graphics.newImage("sprites/Background1_pc.png")
  
  sprites.startButton = love.graphics.newImage("sprites/button_Start_G.png")
  sprites.pressedStartButton = love.graphics.newImage("sprites/button_Start_R.png")
  
  cameraFile = require("hump-master/camera")
  
  cam = cameraFile()

  normalWorld = love.physics.newWorld(0, 100)
  
end


function love.update(dt)
  
  if level > 0 then
    BrokenBridge:update(dt)
    cam:lookAt(Player.x, Player.y)
  end
end



function love.draw()
  
  cam:attach()
  

  
  if level > 0 then
  love.graphics.draw(Player, StartX, StartY, nil, 0.25, 0.25)
end

  if level == 1 then    
     BrokenBridge:drawLayer(BrokenBridge.layers["Background"])
   end
   
   cam:detach()
   
  love.graphics.draw(sprites.background1, 0, 0)
  love.graphics.draw(sprites.startButton, startButtonStartX, startButtonStartY)
end



function isStartButtonClicked(mouseX, mouseY)
  if (mouseX > startButtonStartX) and (mouseX < startButtonEndX) and (mouseY > startButtonStartY) and (mouseY < startButtonEndY) and level == 0 then
    return true
  end
  return false
  
  
  
end

function love.mousepressed(mouseX, mouseY, button, istouch)
  if isStartButtonClicked(mouseX, mouseY) then
    level = 1
  end
end

function startLevel()
  
  for i,obj in pairs(BrokenBridge.layers["StartPosition"]) do
    StartX = obj.x
    StartY = obj.y
  end
  
end
User avatar
papainoel14
Prole
Posts: 10
Joined: Fri Mar 13, 2020 3:59 pm

Re: Black screen on start

Post by papainoel14 »

in its main it is possible to notice that the game starts at level 0, however in the part of the draw it is noticed that only something is shown on the screen when the level is above 0, that is, until it goes out of 0 nothing will be shown.
If you want something to be shown as soon as you open the game you have to put draw at level 0.

I imagine that's it, I wait to see if it worked
Ninguem
Nerdzmasterz
Prole
Posts: 4
Joined: Wed Feb 12, 2020 10:26 pm

Re: Black screen on start

Post by Nerdzmasterz »

Thanks for the tip! Still not working, though.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 48 guests