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.
Newbie Help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 3
- Joined: Thu Jun 11, 2015 7:36 am
Newbie Help
- Attachments
-
- Help.zip
- (1.9 KiB) Downloaded 156 times
Re: Newbie Help
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.
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
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 3
- Joined: Thu Jun 11, 2015 7:36 am
Re: Newbie Help
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!
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!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests