Page 1 of 1

Newbie Help

Posted: Thu Jun 11, 2015 8:00 am
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.

Re: Newbie Help

Posted: Thu Jun 11, 2015 9:13 am
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.

Re: Newbie Help

Posted: Thu Jun 11, 2015 9:47 am
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!