draw

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
teeter11
Prole
Posts: 27
Joined: Sun Jan 12, 2014 8:48 pm

draw

Post by teeter11 »

how do i call something to the love.draw?
( i want to call it when the player presses w)

Code: Select all

score = 0
playx = 300
playy = 420

function love.keypressed(key)
	if key == "w" then
		
	elseif key == "d" then
		playx = playx + 10
	elseif key == "a" then
		playx = playx - 10
	end
end

function love.draw()
	love.graphics.draw(player,playx,playy)
end

function love.load()
	love.graphics.setBackgroundColor(255,0,0)
	love.window.setTitle("Space Shooter Pre-Alpha")
	ammo = love.graphics.newImage("ammo.png")
	player = love.graphics.newImage("goodplayer.png")
end
lachlaan
Prole
Posts: 30
Joined: Sun Jun 30, 2013 7:23 pm

Re: draw

Post by lachlaan »

Could make a variable that toggles whenever the W key is down. The way you're doing it doesn't seem to allow for much else if W is pressed. Might want to have a look at checking for keypresses individually and triggering each key's action individually. Create a variable called wdown = false in love.load() (or whatever you want to call it) and then in update assign it the value of love.keyboard.isDown('w'). In love.draw() simply put in an if(wdown) where you draw whatever it is you want to draw when W is down.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests