Page 1 of 1

[SOLVED] Problem with simple code

Posted: Tue Nov 29, 2016 11:14 pm
by falk
Hey, guys! I'm completely new to programming and game development. I'm also not a native English speaker, so I'd like to apologize for all my language mistakes and idiotic questions in advance.
I use love2d version 0.10.1 and Lua version 5.2. I downloaded them some time ago, but started learning yesterday. But no more procrastination! With your help I'll become a game developer and I'll release a game before my death (did I mention I'm quite old?).
I've written some simple code and it doesn't work as I expected:

Code: Select all

local x, y, side
function love.load()
  x = love.graphics.getWidth() / 2 - 10
  y = love.graphics.getHeight() /2 - 10
  side = 20
end

function love.update(dt)
  if love.keyboard.isDown('up') then
    y = y - 20 * dt
  end
  if love.keyboard.isDown('down') then
    y = y + 20 * dt
  end
  if love.keyboard.isDown('left') then
    x = x - 20 * dt
  end
  if love.keyboard.isDown('right') then
    x = x + 20 * dt
  end
  if love.keyboard.isDown('space') then
    side = side + 50 * dt
  end
end

function love.draw()
  love.graphics.rectangle('fill', x, y, side, side)
end
So, I can go up, down, left, right, diagonal (by pressing two buttons), I can enlarge the square even when I move except (and that's something I cannot understand) when I move diagonally left-up. Pressing space when I already hold up and left arrow pressed does nothing (and it should enlarge the square). Also, when I hold the space button I can move any direction except left-up (so when I hold space bar pressed, pressing up and left arrow simultaneously doesn't do anything, the square is enlarging but not moving).
Any idea what's wrong? I'm not very bright, so I can't figure it out by myself. Help the old man, please.

EDIT: it's a ghosting issue (thing I have never heard of before). CHEERS for the answer!

Re: Problem with simple code

Posted: Wed Nov 30, 2016 3:02 am
by Beelz
It would assume it's a ghosting issue like explained here.