Simulator Name Generator v0.2a

Feel free to showcase your own projects!
Post Reply
User avatar
OrbitalBlueprint
Posts: 528
Joined: 08 Sep 2013, 20:11
Contact:

Post » 09 Jan 2014, 21:10

Hello People! It's me, OrbitalBlueprint, and I noticed how many Simulator games there exist which end with "2014". So I decided to make silly little LOVE2D project which randomly generates a silly name! Of course, it's not completely random, since I want to expand the random generation variety one day. This is also my first, own LOVE2D project which was made completely without help, except for the font, which was simply taken from the LOVE2D forums. I'm pretty proud of it, and I will update it in the future to add sillier names or add even more stuff!

DOWNLOAD:
Sim_Gen.love file

Some stuff I have to add to this post:
-This is my very first LOVE2D project, so don't expect anything too good.
-The "Discovered" variable is a little bit bugged, so it would be cool if someone could help me out with it.
-If you have any name suggestions, leave them down in the replies.
-It requires LOVE2D 0.9.0 to run.

User avatar
Automatik
Posts: 1073
Joined: 20 Jul 2012, 17:54
Contact:

Post » 09 Jan 2014, 21:55

Some feedback about your code:
-

Code: Select all

function love.keypressed(key)
	if key == " " then
		number = math.random(1, 15)
	end
end

function love.keyreleased(key)
   if key == " " then
   print("New Name loaded, ID=" .. number .. "!")
		if number == 1 then
			discovered = discovered+1
		end
		if number == 2 then
			discovered = discovered+1
		end
		if number == 3 then
			discovered = discovered+1
		end
		if number == 4 then
			discovered = discovered+1
		end
		if number == 5 then
			discovered = discovered+1
		end
		if number == 6 then
			discovered = discovered+1
		end
		if number == 7 then
			discovered = discovered+1
		end
		if number == 8 then
			discovered = discovered+1
		end
		if number == 9 then
			discovered = discovered+1
		end
		if number == 10 then
			discovered = discovered+1
		end
		if number == 11 then
			discovered = discovered+1
		end
		if number == 12 then
			discovered = discovered+1
		end
		if number == 13 then
			discovered = discovered+1
		end
		if number == 14 then
			discovered = discovered+1
		end
		if number == 15 then
			discovered = discovered+1
		end
		
	end
end
Woah.
Better version(This make the counter work):

Code: Select all

function love.keypressed(key)--We put everything under love.keypressed
	if key == " " then
		number = math.random(1, 15)
		print("New Name loaded, ID=" .. number .. "!")
		discovered = discovered+1 --No code repetition
	end
end
Also,:

Code: Select all

function love.load()
	-- Do you need this? Almost no one will open the console.
	print("Random Simulation Game Generator by Chris S.")
	print("AKA TehPencilmaster/OrbitalBlueprint")
	print("www.tehpencilmaster.weebly.com")
	
	number = math.random(1, 15)
	discovered = 0
	
	font = love.graphics.newImageFont("font.png",
    " abcdefghijklmnopqrstuvwxyz" ..
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
    "123456789.,!?-+/():;%&`'*#=[]\"")
	love.graphics.setFont(font)--Moved here, since it stay set even after a frame
end
function love.draw()
	--No need for l.g.setColor, since the color is white by default
	love.graphics.print( "v0.2a                                              Copyright Chris S. 2014", 16, 580 )
	love.graphics.print( "15 Random Names Available - " .. discovered .. " discovered.", 16, 550)
	love.graphics.print( "Press Space to cycle through random names.", 16, 518)
	local listofnames = {"Pig" --This a table. It's really an awesome type of variable that can do a fuckton of stuff.
		,"Hobo"
		,"Fish"
		,"Lemon Eating"
		,"Spider Pig"
		,"Ghost Busting"
		,"Toilet Factory"
		,"Diarrhea"
		,"Mental Home"
		,"Potato Peeling"
		,"Potato Stomping"
		,"Diaper Tester"
		,"Forum Moderator"
		,"Bedroom Cleaning"
		,"Studying"}
	love.graphics.print(listofnames[number].." Simulator 2014", 16, 16, 0, 2)--Btw, you don't need to set Sy if Sx is already set and is the same as Sy.
end
Protip: if you are copy-pasting code, there is a better way of doing things .
-You don't need to define love.quit and love.update if you aren't using them.

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

Post » 09 Jan 2014, 22:38

Well, as you see I'm pretty much a noob still. I was just happy enough to see that this was actually working. As soon as I get access to my computer I will definitely change it up a bit!

User avatar
Mr.Q.Marx?
Posts: 849
Joined: 15 May 2012, 18:35

Post » 09 Jan 2014, 22:52

That doesn't account for getting the same name twice though Automatik.
For that I advise setting up a different table which has all names generated added to it and running a for loop to check to see if the string has already been loaded.

User avatar
Automatik
Posts: 1073
Joined: 20 Jul 2012, 17:54
Contact:

Post » 09 Jan 2014, 22:59

Mr.Q.Marx? wrote:That doesn't account for getting the same name twice though Automatik.
For that I advise setting up a different table which has all names generated added to it and running a for loop to check to see if the string has already been loaded.
Or simpler:

Code: Select all

--Initiation
table={}
--To add
table[name]=true
--To check
if table[name] then 

User avatar
Mr.Q.Marx?
Posts: 849
Joined: 15 May 2012, 18:35

Post » 10 Jan 2014, 00:22

I did not know that could be done. Gosh that's lovely.

Post Reply