I was just scripting a car that was meant to rotate left when left key is pressed, but for some reason, when I'm trying to execute it, it hang up on me and stops responding! Source code:
player={x=100,y=100,speed=150,img=nil,orientation=0,size=0.5,tlitvalue=(math.pi*2)/256,offsetx,offsety}
function love.load(arg)
player.img=love.graphics.newImage('assets/CarBlue.png')
player.offsetx=player.img:getWidth()/2
player.offsety=player.img:getHeight()/2
end
function love.update(dt)
while love.keyboard.isDown(left) do
player.orientation=(player.orientation-player.tlitvalue)*dt
end
end
function love.draw(dt)
love.graphics.draw(player.img, player.x, player.y, player.orientation, player.size, player.size, player.offsetx, player.offsety)
end
Help! Also, my first post, sorry if I made something dumb ;-)
love.exe hungs up for some reason
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: love.exe hungs up for some reason
Hi and welcome to the forums!
Your single issue with that is that while loop you put in love.update.
That function will be called by löve itself once each frame, so you don't need that loop there at all, just replace it with an if, and it should stop getting stuck in an infinite loop.
Also, do use [ code ] [ /code ] tags, makes your code more readable in posts.
Your single issue with that is that while loop you put in love.update.
That function will be called by löve itself once each frame, so you don't need that loop there at all, just replace it with an if, and it should stop getting stuck in an infinite loop.
Also, do use [ code ] [ /code ] tags, makes your code more readable in posts.
Me and my stuff True 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.
Re: love.exe hungs up for some reason
Thank you, it works fine, I'm still learning so I didn't know. ;-)
Who is online
Users browsing this forum: Google [Bot] and 4 guests