Some more things I noticed:
- You don't indent your code. Proper line indention would make your code much more readable and easier to debug.
- Interesting way to set your desired color, but calling setColor in the arguments list seems to be a very dirty way to do this imo.
Code: Select all
love.graphics.draw(player.img, player.x, player.y, 0, 1, 1, 20, 30, love.graphics.setColor(255,255,255))
- The text position is hard-coded which makes it hard to find the right position. You could use the position of your "solids" objects to make your code more flexible. You also print your text again for every object you draw. Move the print functions somewhere outside of the for loop, otherwise this is wasted processing power.
Code: Select all
love.graphics.print("A is for left, D is for right, W is for jump.", 10, 1230, 200, 2, 2, love.graphics.setColor(255, 0, 0))
- Changes like restarting the game or quitting shouldn't be made in your player.move function because it doesn't have anything to do with it.
Code: Select all
function player.move(dt) if love.keyboard.isDown("e") then love.event.quit() end if love.keyboard.isDown("r") then love.event.quit("restart") end if love.keyboard.isDown("q") then love.window.setMode( 1800, 900) end
Apart from that, you could make this more efficient by using the love.keypressed callback. - If you need a method to set the player position, then it doesn't make sense to hard-code the y value. Just use the method somewhere and pass the y argument to the variable.
Code: Select all
function player.setPosition(x, y) player.x, player.y = x, 1100 end