visualy tracking coordinate areas for sprites [Solutions Provided]
Posted: Fri Jan 10, 2020 2:29 pm
Hello, my name is klewis and I am new to the community. I just want to say how awesome love2d is going for me so far. I pretty excited with the workflow process of building up games through the language. I'm in the midst of creating a zombie game that includes some sprite characters.
Here is my progress so far:
..How can I enable something like a "debug mode" that shows me the actual spacial coordinates of the space that my sprite character taking up? In other words, I want to visually see an outline of the space that sprites take up.
* This will help me visually see that he is sitting on the top left of his given area by default
* It will also help me see (later) at what point collisions happen.
Is this possible with love2d?
Thanks!
Here is my progress so far:
Code: Select all
function love.load()
sprites = {}
sprites.player = love.graphics.newImage('sprites/player.png')
sprites.bullet = love.graphics.newImage('sprites/bullet.png');
sprites.zombie = love.graphics.newImage('sprites/zombie.png');
sprites.background = love.graphics.newImage('sprites/background.png');
player = {}
player.x = 600
player.y = 200
player.speed = 3
end
function love.update(dt)
if love.keyboard.isDown("s") then
player.y = player.y + player.speed
end
if love.keyboard.isDown("w") then
player.y = player.y - player.speed
end
if love.keyboard.isDown("s") then
player.y = player.y + player.speed
end
if love.keyboard.isDown("a") then
player.x = player.x - player.speed
end
if love.keyboard.isDown("d") then
player.x = player.x + player.speed
end
end
function love.draw()
love.graphics.draw(sprites.background, 0, 0)
love.graphics.draw(sprites.player, player.x, player.y)
end
* This will help me visually see that he is sitting on the top left of his given area by default
* It will also help me see (later) at what point collisions happen.
Is this possible with love2d?
Thanks!