Discord
Login
Community
DARK THEME

Basic programming question

I wanted to get advice as to why this program is not working. What I'm wanting is for the screen to change colour when I press space bar, which it does, however once you stop pressing space the screen reverts back to its original colour. The code I have is below

draw = function ()
  screen.fillRect(0,0,400,200,-164)
  if keyboard.SPACE then
    screen.fillRect(0,0,400,200,-100)
  end 
end 

Any ideas...

In this program you make the screen change color only while pressing space, if you want to make it change color even after relase the space bar you could put in update(): if keyboard.SPACE then color = 2 end

and in draw(): if color == 2 then screen.fillRect(0,0,400,200,-100) end

Thanks mate, that helped a lot.

no problem:)

Post a reply

Progress

Status

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