Discord
Login
Community
DARK THEME

Help needed with flashlight

heres the code:

file 1:

initlight = function() fl = object x = 0 y = 0 name = "mouse" end

vis = object x = 0 y = 0 name = "vision" end end

updatelight = function() screen.setCursorVisible(false) fl.x = mx fl.y = my vis.x = fl.x vis.y = fl.y end

drawlight = function() sprites[vis.name].setFrame(1) screen.drawSprite(vis.name,0,0,1200,800) sprites[fl.name].setFrame(1) screen.drawSprite(fl.name,fl.x,fl.y,20,20)

if keyboard.F then sprites[vis.name].setFrame(1) screen.drawSprite(vis.name,vis.x,vis.y,1200,800) sprites[fl.name].setFrame(1) screen.drawSprite(fl.name,fl.x,fl.y,20,20) else sprites[vis.name].setFrame(0) screen.drawSprite(vis.name,0,0,1200,800) sprites[fl.name].setFrame(0) screen.drawSprite(fl.name,fl.x,fl.y,20,20) end end

file 2: initGame = function() initlight() end

updateGame = function() mx = mouse.x my = mouse.y updatelight() end

drawGame = function() screen.clear() intro() drawlight() end

updateTitle = function() end

drawTitle = function() end

file 3: init = function() state = "play" end

update = function() if state == "noplay" then updateTitle() elsif state == "play" then initGame() updateGame() end end

draw = function() if state == "noplay" then drawTitle() elsif state == "play" then drawGame() end screen.drawText(mx, 150,70,20,"rgb(255,255,255)") end

file 4: intro = function() sprites["cutscene"].setFrame(0) screen.drawSprite("cutscene",0,0,400,200) screen.drawText("This is you!",0,-90,20,"rgb(255,255,255)") end

i am not able to understand why i cant view the image properly below using the flashlight! i can only see the centre part of the image at all

make the code public and post a link to the project

here you go. can you tell me what i am doing wrong?

https://microstudio.io/i/AGameProgrammer/hideandseek/

intro = function()
  sprites["cutscene"].setFrame(1)                   // <<<<<<<<<<<<<<<<<< set 1 
  screen.drawSprite("cutscene",0,0,400,200)
  screen.drawText("This is you!",0,-90,20,"rgb(255,255,255)")
end
intro = function()
//  sprites["cutscene"].setFrame(0)
  screen.drawSprite("cutscene",0,0,400,200)
  screen.drawText("This is you!",0,-90,20,"rgb(255,255,255)")
end

no it doesn't work

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community