Newbie Help

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
nicksystem
Prole
Posts: 3
Joined: Thu Jun 11, 2015 7:36 am

Newbie Help

Post by nicksystem »

Hi,

Very new to Love. Have played around with Processing a bit though.

I'm just trying to get a rectangle bouncing around the screen at this point as a test.

Can't figure out what's wrong with my code. :?

Any assistance would be greatly appreciated. Using 3 files (main, conf & player) so i've zipped it rather than post the code.
Attachments
Help.zip
(1.9 KiB) Downloaded 156 times
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Newbie Help

Post by Nixola »

There you are. Rename that file to Help.love and you've made the standart LÖVE file, which can easily be opened in it by anyone who's got it installed! ^^
Anyway, I made some small changes to your code.
First of all, I'm now passing the "dt" parameter to PLAYER_UPDATE and player.move: this will allow you to get a constant speed, which doesn't depend on the framerate.
Second, your old code only moved the player by 3 (and not by player.speed) if it was outside certain boundaries, but it did nothing on the inside: I changed the code so that the player has a new variable, "player.direction", which is either 1 or -1 and changes whenever you get outside the boundaries. By multiplying the speed by it, you can effectively change the direction of the player.
I'm attaching a .love file, which is just a zip file as yours with a different extension.
Attachments
Help.love
(828 Bytes) Downloaded 166 times
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
nicksystem
Prole
Posts: 3
Joined: Thu Jun 11, 2015 7:36 am

Re: Newbie Help

Post by nicksystem »

Ah perfect!

I did some research into delta time, thanks for showing me that. I'll remember that in future.

The player.direction is an excellent idea, it all works.

Thanks for your help. I appreciate it!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests