HugoBDesigner's Screensaver Loader

Feel free to showcase your own projects!
Post Reply
User avatar
HugoBDesigner
Posts: 2188
Joined: 19 Sep 2012, 02:23
Contact:

Post » 29 Jan 2015, 10:42

(Shameless copy of Löve Forums thread. Here it is, by the way: http://love2d.org/forums/viewtopic.php? ... 70#p179553)

Hello again, everyone! This time, I worked hard on a project that isn't THAT MUCH useful, but rather entertaining. This was an experiment, and I made it in a single day, so if you find any problems, please contact me.

Description:
As the title says, it is a "Screensaver Loader". What that means is that not only does this plays screensavers (like any screensaver), but it can also LOAD custom user-made screensavers.
There are 3 screensavers that come with this: 1 made by a great friend, TurtleP (he made that before I started this project. In fact, his screensaver inspired me to do this all), and the other 2 by me (recycled from doodles I made on the "Code Doodles" thread). And, these 2 ones made by me are interactive: remember back in the old Windows versions where some screensavers were like "minigames" (especially the 3D maze)? Exactly, that's what this "program" allows you to do.

If anyone ends up making a screensaver for this, it'd be very nice if you posted here, as I'd like to know how well my program would work in other's computers, as well as how creative you can get!



Info:
To quit a screensaver, simply press any key/button or move your mouse around. If you're on an interactive screensaver, press [Esc]. To switch between screensavers, press [F1]. In the console for changing screensavers, use Left/Right, [a]/[d] or [click] in the arrows. To view the information about keys/mouse buttons, use [Mouse wheel] or drag the scrollbar. Simple as that!



Screenshots and Download:
Image
Pac-Man screensaver - By TurtleP
Selection menu
Selection menu (2)



Screensavers 1.0.love



How to make your OWN screensavers:
Place a .lua file inside a folder named "screensavers". If this folder wasn't already created in the game's folder, create it yourself. The game's folder is "hbd_screensavers", and goes on the "%appdata%/LOVE" folder (again, if it doesn't exists, create yourself).
Complete path: %appdata%/LOVE/hbd_screensavers/screensavers/[screensaver name].lua

Let's call this screensaver "test". The name of the .lua file doesn't matter, but the program will get the file name if no name is specified inside the file itself.

Code: Select all

local test = {}
test.name = "My first screensaver" --default to filename
test.author = "My name!!!" --default to "Unknown"
test.showmouse = true --if false, you don't even need this
If your screensaver is interactive, you can add a list of keys/mouse buttons and what they do:

Code: Select all

test.mouse = {
				["l"] = "Select something",
				["r"] = "Change something",
				["wu"] = "Increase something",
				["wd"] = "Decrease something",
				["m"] = "Do something RANDOM!!!"
				}

test.keys = {
				["A"] = "Do something",
				["W"] = "Do another thing",
				["Enter"] = "Toggle something",
				["Ctrl+S"] = "Save something",
				["Delete"] = "Delete something",
				["Space"] = "JUMP!!!"
				}
If your screensaver isn't interactive, you don't need those. Also, if it only uses mouse or keyboard, you just need the respective table. This is not a REQUIREMENT, but it makes things more clear.
Then, you'll have the callbacks. PAY ATTENTION: like any screensaver, the program will close as soon as you press a button/move the mouse. To avoid that, do this:

Code: Select all

function test:load()
	self.value = n
	self:startSomething()
end

function test:update(dt)
	--If you don't want the game to close on mouse movement, add the following line in the end:
	return true
end

function test:draw()
	--Draw your screensaver
end

function test:mousepressed(x, y, button)
	--If you don't want the game to close on mouse press, add the following line in the end:
	return true
end

function test:mousereleased(x, y, button)
	--If you don't want the game to close on mouse release, add the following line in the end:
	return true
end

function test:keypressed(key)
	--If you don't want the game to close on key press, add the following line in the end:
	return true
end

function test:keyreleased(key)
	--If you don't want the game to close on key release, add the following line in the end:
	return true
end

function test:startSomething()
	--Do something here. You can have as many functions/variables as you want, just try to keep using "self."
end
IMPORTANT: After you've added everything you need, add this in the very last line of your code (outside every function):

Code: Select all

return test
And that's basically it! Your screensaver will load inside the game as any other!
A couple of things to keep in mind: the keys "Escape" and "F1" have predefined functions, so avoid using them. And if you want your screensaver to quit, do "quit()" instead of "love.event.quit()", as there's already a function that handles a few things before quitting.


I hope you guys enjoy it, because it was really fun for me doing this!

User avatar
OrbitalBlueprint
Posts: 528
Joined: 08 Sep 2013, 20:11
Contact:

Post » 05 Feb 2015, 18:12

I was making a screensaver, however adding "return true" at the end of each function still cancels the game upon mouse or key presses.

User avatar
HugoBDesigner
Posts: 2188
Joined: 19 Sep 2012, 02:23
Contact:

Post » 05 Feb 2015, 20:50

You need to do the same on mousereleased and keyreleased. It's something a bit annoying, but not much I could have done about, since mouserelease and keyrelease can be also used. Also, thanks for using it :D

Post Reply