Love for Lua Game Programming chapter 2 problem

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
Zace66
Prole
Posts: 2
Joined: Mon Sep 07, 2015 10:49 pm

Love for Lua Game Programming chapter 2 problem

Post by Zace66 »

I'm getting a problem with the following code... it doesn't like line 17 or 20 ( character.x = character.x – 1 * dt ) ( y-1)
Is this because the book was written a few years ago and things have moved on - if so is there a better book recommended to learn from please?
Sorry if this has been asked before but searching the forums didn't show anything up.

Code: Select all

function love.load()
	character = {}
	character.x = 300
	character.y = 400
	love.graphics.setBackgroundColor(225, 153, 0)
	love.graphics.setColor(0, 0, 225)
end

function love.draw()
    love.graphics.rectangle("fill", character.x, character.y, 100, 100)
end

function love.update(dt)
	if love.keyboard.isDown('d') then
		character.x = character.x + 1 * dt
	elseif love.keyboard.isDown('a') then
		character.x = character.x – 1 * dt
	end
	if love.keyboard.isDown('w') then
		character.y = character.y – 1 * dt
	elseif love.keyboard.isDown('s') then
		character.y = character.y + 1 * dt
	end
end
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Love for Lua Game Programming chapter 2 problem

Post by airstruck »

Those aren't minus signs, they're "U+2013 EN DASH"
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Love for Lua Game Programming chapter 2 problem

Post by zorg »

On another note, this issue came up more than once, so i'd be interested to know what kind of code editor (or system locale) messes with the minus sign.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Love for Lua Game Programming chapter 2 problem

Post by airstruck »

zorg wrote:On another note, this issue came up more than once, so i'd be interested to know what kind of code editor (or system locale) messes with the minus sign.
Probably some typesetting software did that and code was copypasted from book.
Zace66
Prole
Posts: 2
Joined: Mon Sep 07, 2015 10:49 pm

Re: Love for Lua Game Programming chapter 2 problem

Post by Zace66 »

Good old Notepad++, sigh, ive seen this before when coding PHP.

Arghh - sorry for bothering you (Shame on me for shortcutting the typing and relying on copy and paste)

Mind you the keys don't respond, or rather I don't see any movement or rotation. Sigh.
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: Love for Lua Game Programming chapter 2 problem

Post by arampl »

Just download example code for the book and use it.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests