Beginner coding help

Feel free to showcase your own projects!
Locked
User avatar
StarFox
PERMABANNED
Posts: 1
Joined: 06 May 2012, 15:11

Post » 06 May 2012, 15:21

Hello World!

Today I have made a code in Notepad++ , But it did not work.
Can someone fix my code?

Code: Select all

function load ()
    player = player.png
end

function update (pm)
    playerX = 10
  playerY = 5
end

function update (dt)
    --Horizantal movement
    if love.keyboard.isDown("left") then
        playerX = playerX - 5*dt
    elseif love.keyboard.isDown("right") then
        playerX = playerX + 5*dt
     end

     --Vertical movement
     if love.keyboard.isDown("up") then
        playerY = playerY - 5*dt
     elseif love.keyboard.isDown("down") then
        playerY = playerY + 5*dt
     end
end

function update (gl)
    goalX = 25
  goalY = 45
end

function update (wn)
If playerX = 25 and
   playerY = 45
   love.graphics.printf("You win","center")
end

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 06 May 2012, 15:36

There's more things wrong with that than things right.
Go read a tutorial about lua.
Also don't make an alt when you're banned.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 06 May 2012, 15:50

To be fair, his lua isn't bad.
His understanding of love is the bit that needs some serious work.

User avatar
Lawnboy
Posts: 836
Joined: 03 Feb 2012, 02:24

Post » 06 May 2012, 15:53

Code: Select all

function love.load()
    player = love.graphics.newImage('player.png')
    playerX = 10
    playerY = 5
    win=false
end

function love.update(dt)
    --Horizantal movement
    if love.keyboard.isDown("left") then
        playerX = playerX - 5*dt
    elseif love.keyboard.isDown("right") then
        playerX = playerX + 5*dt
     end

     --Vertical movement
     if love.keyboard.isDown("up") then
        playerY = playerY - 5*dt
     elseif love.keyboard.isDown("down") then
        playerY = playerY + 5*dt
     end
    If playerX==25 and playerY==45 then
      win=true
    end
end
function love.draw()
  love.graphics.draw(player,playerX,playerY)
  if win==true then
    love.graphics.print('You Win',0,0)
  end
PLEASE read a tutorial. By the way, do you know how hard it is to get playerX and playerY at your EXACT coordinates?

Locked