Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7789443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:18:02+00:00 2026-06-01T21:18:02+00:00

For some reason the code is not responding when i got the code if

  • 0

For some reason the code is not responding when i got the code if love.keyboard.isDown("s") Maybe i am using the functions just wrong but its still weird.

I tried using the Menu() function in love.keypressed and in love.update. Still no response.

Here is the full code:

main.lua

function love.load()
require "menu"
select = love.graphics.newImage("select.png")
Menu()
end
function love.draw()
   Menu()
end
function love.keypressed(key)
   Menu()
end

function love.update()
   Menu()
end

menu.lua

function Menu()
sly = 300
love.graphics.draw(select,sly,300)
if key == "w" then
    sly = sly + 50
end

if love.keyboard.isDown("s") then
    sly = sly - 50
end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:18:03+00:00Added an answer on June 1, 2026 at 9:18 pm

    Not sure what exactly you are trying to do here, but in your Menu() function you are resetting the sly variable every time you call it, and then modifying sly after you have already drawn the image. This results in nothing happening.

    If you change it so that sly is initialized outside Menu(), it at least moves the image when you press the ‘s’ key. Also, if you wanted ‘s’ to move it one way and ‘w’ to move it the other way, maybe the code should be like this:

    sly = 300
    
    function Menu()
    
        love.graphics.draw(select,sly,300)
        if love.keyboard.isDown("w") then
            sly = sly + 50
        end
    
        if love.keyboard.isDown("s") then
            sly = sly - 50
        end
    end
    

    Or you could pass the key variable into Menu() when you call it from love.keypressed and not use the keyboard.isDown function.

    Again, I’m not sure what you are really trying to do here, but it looks to me like the code is working fine, you may just have a logic error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Theres some reason for this code not reach the first else? I got it
For some reason, this code does not actually draw my bitmap file... or show
For some reason the following code does not work as expected when in IE
For some reason the code I have included below does not interpolate the variables
For some reason the code below is not adding annotations to the map view.
For some reason the code below is returning the results, put not in the
For some reason this PHP code below will not work, I can not figure
For some reason, the following code will work: The following code does not work:
For some reason this sort code is not working as I would expect: std::fstream
For some reason this code doesn't work in IE9 (could not try other versions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.