Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Recognizing hipocricy isn't the strong suite of a twelve year-old. (that's for SOMEONE I KNOW)
- -- TODO: Make a weapon selection system and enemies with health.
- --draw "Hello world!" as a main menu and wait for input."
- function love.draw()
- love.graphics.print("Hello world!", 400,300) -- However, this doesn't seem to work. a "then" function would probably help nicely.
- end
- function love.load() -- load the player controller into the game
- player = {}
- end
- function love.load() -- put the player into the starting position
- player = {
- x = 256,
- y = 256,
- facing = up,
- }
- end
- function love.keypressed(key) -- we define the keys for the movement. TODO: change the keys to variables so that we can set custom controls in an options menu.
- -- we have also defined player.facing as a variable to set the direction the player is facing so we can use this to make our shooting script later on.
- if key == "w" then
- player.y = player.y - 32
- player.facing = "up"
- elseif key == "s" then
- player.y = player.y + 32
- player.facing = "down"
- elseif key == "a" then
- player.x = player.x - 32
- player.facing = "left"
- elseif key == "d" then
- player.x = player.x + 32
- player.facing = "right"
- end
- end
- function love.draw()
- love.graphics.rectangle("fill", player.x, player.y, 32, 32) -- we call a draw function to create a white rectangle in the coordinates we just called.
- love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 0, 10) -- we print out the FPS onto the top of the screen.
- -- the if and elseif lines below display the direction the player is facing.
- if player.facing == "up" then
- love.graphics.print("Facing: Up", 0, 20)
- elseif player.facing == "down" then
- love.graphics.print("Facing: Down", 0, 20)
- elseif player.facing == "left" then
- love.graphics.print("Facing: Left", 0, 20)
- elseif player.facing == "right" then
- love.graphics.print("Facing: Right", 0, 20)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement