My first project! I need critiques! -XYZ

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
andropof91h
Prole
Posts: 3
Joined: Sun Jul 03, 2016 10:21 am

My first project! I need critiques! -XYZ

Post by andropof91h »

Hi,
I've "studied" python and c++ for a while some months ago.
I decided to resume studying, this time starting with this incredible framework (the first I ever used) and lua.
After my first 5 days in this new world i decided to share my first project ever, in order to get criticisms and help.

---------------------------------------------------------------------------------------------------------------------------------------

I've decided to start making a simple program that generates random (or pseudorandom) number/words.
I'm working on make many filters and options to make this simple program as completely as possible.

Currently the user can only choose between the number of consonants, vowels and numbers to generate.
Some features, like choose the order or the generated characters are only avaibles by editing the code (in a future update the user will insert all this kind of things).

Space = To generate
LeftMouse = To interact

---------------------------------------------------------------------------------------------------------------------------------------

I know it's not the most exciting project ever created, but for me it's a goal.
I didn't want to create a classic game for the first project.
Thank you for the kindness, it would be great if someone more experienced than me (not hard to find) wants to help me (advices on how to improve my code etc.) :awesome:

Code: Select all

function love.load()

	love.graphics.setBackgroundColor(50,50,50)

	--Window x/y

	Window_Height = love.graphics.getHeight()
	Window_Width = love.graphics.getWidth()

	--Fonts

	Font_Pcsenior_16 = love.graphics.newFont( "pcsenior.ttf", 16 )
	Font_Pcsenior_13 = love.graphics.newFont( "pcsenior.ttf", 13 )

	--Accepted texts
	----------------
	Array_Accepted_Text_Consonants_Button = {"1","2","3","4","5","6","7","8","9"}
	NumberOfConsonants = 0
	----------------
	Array_Accepted_Text_Vowels_Button = {"1","2","3","4","5","6","7","8","9"}
	NumberOfVowels = 0
	----------------
	Array_Accepted_Text_Numbers_Button = {"1","2","3","4","5","6","7","8","9"}
	NumberOfNumbers = 0
	----------------

	--Text

	Text_1 = ""
	Text_2 = ""
	Text_3 = ""

	Word = ""

	Maximum_Text_Lenght = 2

	--Text boxes

	Value_Standard_Added = 10
	Distance = 40
	Text_Color = 150
	Text_Color_Pressed = 100

	Text_Box_1_Visibility = true
	Text_Box_2_Visibility = true
   	Text_Box_3_Visibility = true
	----------------(1)
	Pression_Text_Box_1 = 1
	Pression_Text_Box_2 = 1
	Pression_Text_Box_3 = 1
	

	

	--Others
	Error = false
	Word = "Random!"

	--Arrays
	Array_Consonants={"B", "C", "D", "F", "G", "H", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "Z"}
	Array_Vowels={"A", "E", "I", "O", "U"}
	Array_Numbers={"0","1","2","3","4","5","6","7","8","9"}

	--Accepted text

	Accepted_Text = {0,1,2,3,4,5,6,7,8,9}
	Numbers1 = 10

end

function love.mousepressed(x, y, button, istouch)

   if button == 1 and x>Text_Box_1_X and x<Text_Box_1_X+Width_Text_Text_Box_1+Value_Standard_Added and y>Text_Box_1_Y and y<Text_Box_1_Y+Height_Text_Text_Box_1+Value_Standard_Added and Text_Box_1_Visibility == true then
   	Pression_Text_Box_1 = (Pression_Text_Box_1 + 1)
   	if Pression_Text_Box_1%2==0 then
   		Text_Box_2_Visibility = false
   		Text_Box_3_Visibility = false
   		Open = true
   	elseif Pression_Text_Box_1%2==1 then
   		Text_Box_2_Visibility = true
   		Text_Box_3_Visibility = true
   		Open = false
   	end
   end
   if button == 1 and x>Text_Box_2_X and x<Text_Box_2_X+Width_Text_Text_Box_2+Value_Standard_Added and y>Text_Box_2_Y and y<Text_Box_2_Y+Height_Text_Text_Box_2+Value_Standard_Added and Text_Box_2_Visibility == true then
   	Pression_Text_Box_2 = (Pression_Text_Box_2 + 1)
   	if Pression_Text_Box_2%2==0 then
   		Text_Box_1_Visibility = false
   		Text_Box_3_Visibility = false
   		Open = true
   	elseif Pression_Text_Box_2%2==1 then
   		Text_Box_1_Visibility = true
   		Text_Box_3_Visibility = true
   		Open = false
   	end
   end
   if button == 1 and x>Text_Box_3_X and x<Text_Box_3_X+Width_Text_Text_Box_3+Value_Standard_Added and y>Text_Box_3_Y and y<Text_Box_3_Y+Height_Text_Text_Box_3+Value_Standard_Added and Text_Box_3_Visibility == true then
   	Pression_Text_Box_3 = (Pression_Text_Box_3 + 1)
   	if Pression_Text_Box_3%2==0 then
   		Text_Box_1_Visibility = false
   		Text_Box_2_Visibility = false
   		Open = true
   	elseif Pression_Text_Box_3%2==1 then
   		Text_Box_1_Visibility = true
   		Text_Box_2_Visibility = true
   		Open = false
   	end
   end

end

function love.textinput(UserText)	
	if Pression_Text_Box_1%2==0 then
		
		Verify = tonumber(UserText)

		Numbers2 = Numbers1

		Control = false

		while Control == false do
			Numbers2 = (Numbers2-1)
			if Verify == Accepted_Text[Numbers2] then
				Control = true
				Error = false
			end
			if Numbers2 == 0 then
				Control = true
				Error = true
			end
		end
		if Error == false then			
			NumberOfConsonants = NumberOfConsonants..Verify
			if string.len(NumberOfConsonants)>Maximum_Text_Lenght then
			NumberOfConsonants=0
		end			
		end	
	end		
	if Pression_Text_Box_2%2==0 then
		
		Verify = tonumber(UserText)

		Numbers2 = Numbers1

		Control = false

		while Control == false do
			Numbers2 = (Numbers2-1)
			if Verify == Accepted_Text[Numbers2] then
				Control = true
				Error = false
			end
			if Numbers2 == 0 then
				Control = true
				Error = true
			end
		end
		if Error == false then			
			NumberOfVowels = NumberOfVowels..Verify
			if string.len(NumberOfVowels)>Maximum_Text_Lenght then
			NumberOfVowels=0
		end			
		end	
	end		
	if Pression_Text_Box_3%2==0 then
		
		Verify = tonumber(UserText)

		Numbers2 = Numbers1

		Control = false

		while Control == false do
			Numbers2 = (Numbers2-1)
			if Verify == Accepted_Text[Numbers2] then
				Control = true
				Error = false
			end
			if Numbers2 == 0 then
				Control = true
				Error = true
			end
		end
		if Error == false then			
			NumberOfNumbers = NumberOfNumbers..Verify
			if string.len(NumberOfNumbers)>Maximum_Text_Lenght then
			NumberOfNumbers=0
		end			
		end	
	end		
end

function love.update(dt)
	
	PressPlay = love.keyboard.isDown("space")
	
	
end

function love.draw()

	function WordGenerator(NumberOfConsonants, NumberOfVowels, NumberOfNumbers)

	Word = ""

	Consonants = ""
	Vowels = ""
	Numbers = ""	


	for NumberOfConsonants = NumberOfConsonants, 1, -1
	do 
		
		RandomNumber = love.math.random(1, 16)
		Consonants = Consonants.. Array_Consonants[RandomNumber]
	
	end
	for NumberOfVowels = NumberOfVowels, 1, -1
	do 

		RandomNumber = love.math.random(1, 5)
		Vowels = Vowels .. Array_Vowels[RandomNumber]
		
	end
	for NumberOfNumbers = NumberOfNumbers, 1, -1
	do 

		RandomNumber = love.math.random(1, 10)
		Numbers = Numbers .. Array_Numbers[RandomNumber]

	end

	Order_1 = Numbers
	Order_2 = Vowels
	Order_3 = Consonants

	 


	Word = Order_1..Order_2..Order_3

	
	
	return Word, Order_1
	end

	if PressPlay == true then
	WordGenerator(NumberOfConsonants, NumberOfVowels, NumberOfNumbers)	
	end

	--Random text box

	Width_Random_Text_Box = Font_Pcsenior_13:getWidth(Word)
	Height_Random_Text_Box = Font_Pcsenior_13:getHeight(Word)

	Text_Random_Text_Box = love.graphics.newText(Font_Pcsenior_16, Word)
	love.graphics.draw(Text_Random_Text_Box,(Window_Width/2)-(Width_Random_Text_Box/2) ,100)

	--Text boxes
	----------------(1)
	if Text_Box_1_Visibility == true then
		Text_Text_Box_1 = "Number of consonants to generate: " .. NumberOfConsonants

		Width_Text_Text_Box_1 = Font_Pcsenior_13:getWidth(Text_Text_Box_1)
		Height_Text_Text_Box_1 = Font_Pcsenior_13:getHeight(Text_Text_Box_1)

		Text_Box_1_Width = (Width_Text_Text_Box_1 + Value_Standard_Added)
		Text_Box_1_Height = (Height_Text_Text_Box_1 + Value_Standard_Added)

		Text_Box_1_X = (Window_Width/2) - (Text_Box_1_Width/2)
		Text_Box_1_Y = (Window_Height/2) - (Text_Box_1_Height/2)

		if Pression_Text_Box_1%2==0 then
			love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
			love.graphics.rectangle("fill", Text_Box_1_X, Text_Box_1_Y,Text_Box_1_Width , Text_Box_1_Height)
			love.graphics.setColor(225,225,225)
		elseif Pression_Text_Box_1%2==1 then
			love.graphics.setColor(Text_Color,Text_Color,Text_Color)
			love.graphics.rectangle("fill", Text_Box_1_X, Text_Box_1_Y,Text_Box_1_Width , Text_Box_1_Height)
			love.graphics.setColor(225,225,225)
		end

		Text_Sentence_Text_Box_1 = love.graphics.newText( Font_Pcsenior_13, Text_Text_Box_1 )
		love.graphics.draw(Text_Sentence_Text_Box_1, Text_Box_1_X+(Value_Standard_Added/2), Text_Box_1_Y+(Value_Standard_Added/2))
		
	end
	----------------(2)
	if Text_Box_2_Visibility == true then
		Text_Text_Box_2 = "Number of vowels to generate: " .. NumberOfVowels

		Width_Text_Text_Box_2 = Font_Pcsenior_13:getWidth(Text_Text_Box_2)
		Height_Text_Text_Box_2 = Font_Pcsenior_13:getHeight(Text_Text_Box_2)

		Text_Box_2_Width = (Width_Text_Text_Box_2 + Value_Standard_Added)
		Text_Box_2_Height = (Height_Text_Text_Box_2 + Value_Standard_Added)

		Text_Box_2_X = (Window_Width/2) - (Text_Box_2_Width/2)
		Text_Box_2_Y = (Window_Height/2) - (Text_Box_2_Height/2) + (Distance)


		if Pression_Text_Box_2%2==0 then
			love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
			love.graphics.rectangle("fill", Text_Box_2_X, Text_Box_2_Y,Text_Box_2_Width , Text_Box_2_Height)
			love.graphics.setColor(225,225,225)
		elseif Pression_Text_Box_2%2==1 then
			love.graphics.setColor(Text_Color,Text_Color,Text_Color)
			love.graphics.rectangle("fill", Text_Box_2_X, Text_Box_2_Y,Text_Box_2_Width , Text_Box_2_Height)
			love.graphics.setColor(225,225,225)
		end

		Text_Sentence_Text_Box_2 = love.graphics.newText( Font_Pcsenior_13, Text_Text_Box_2 )
		love.graphics.draw(Text_Sentence_Text_Box_2, Text_Box_2_X+(Value_Standard_Added/2), Text_Box_2_Y+(Value_Standard_Added/2))
		
	end
	----------------(3)
	if Text_Box_3_Visibility == true then
		Text_Text_Box_3 = "Number of numbers to generate: " .. NumberOfNumbers

		Width_Text_Text_Box_3 = Font_Pcsenior_13:getWidth(Text_Text_Box_3)
		Height_Text_Text_Box_3 = Font_Pcsenior_13:getHeight(Text_Text_Box_3)

		Text_Box_3_Width = (Width_Text_Text_Box_3 + Value_Standard_Added)
		Text_Box_3_Height = (Height_Text_Text_Box_3 + Value_Standard_Added)

		Text_Box_3_X = (Window_Width/2) - (Text_Box_3_Width/2)
		Text_Box_3_Y = (Window_Height/2) - (Text_Box_3_Height/2) + (Distance * 2)


		if Pression_Text_Box_3%2==0 then
			love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
			love.graphics.rectangle("fill", Text_Box_3_X, Text_Box_3_Y,Text_Box_3_Width , Text_Box_3_Height)
			love.graphics.setColor(225,225,225)
		elseif Pression_Text_Box_3%2==1 then
			love.graphics.setColor(Text_Color,Text_Color,Text_Color)
			love.graphics.rectangle("fill", Text_Box_3_X, Text_Box_3_Y,Text_Box_3_Width , Text_Box_3_Height)
			love.graphics.setColor(225,225,225)
		end

		Text_Sentence_Text_Box_3 = love.graphics.newText( Font_Pcsenior_13, Text_Text_Box_3 )
		love.graphics.draw(Text_Sentence_Text_Box_3, Text_Box_3_X+(Value_Standard_Added/2), Text_Box_3_Y+(Value_Standard_Added/2))
		
	end


end
Attachments
XYZ.love
(7.57 KiB) Downloaded 121 times
User avatar
pgimeno
Party member
Posts: 3684
Joined: Sun Oct 18, 2015 2:58 pm

Re: My first project! I need critiques! -XYZ

Post by pgimeno »

It's nice to see that you've set yourself a low bar for starters. Many people get swamped when trying to do their first steps with a big project.

My main criticism is that data input is not intuitive. People are very used to controls you can navigate through, with arrows or the tab key, without losing sight of the rest of controls, and with a cursor and some kind of feedback on which control has focus. Making a good edit control is not easy; maybe you can use an existing GUI library for that.

There are other forms of providing input, e.g. with arrows and the mouse (a spinner control), but you'd need to make that clearer to the user if you want to use one.

You have a lot of code in love.draw; that should be mostly for drawing only. In particular, you're redefining the WordGenerator function every frame. That's resource-consuming.

It's not clear to me that the intention is to display a bunch of words quickly changing until it stops in one. If that's it, then fine. Otherwise you'll have to work a bit more on that.
User avatar
andropof91h
Prole
Posts: 3
Joined: Sun Jul 03, 2016 10:21 am

Re: My first project! I need critiques! -XYZ

Post by andropof91h »

Thank you for your reply and advises!

--------------------------------------------------------------------------------------
Here is an update!
According to your suggestions i've edited my code ("You have a lot of code in love.draw; that should be mostly for drawing only. In particular, you're redefining the WordGenerator function every frame. That's resource-consuming.").

I've also tried to make the interface more "User friendly": now it's possible to increase or decrease the number of generated characters with arrows. ("My main criticism is that data input is not intuitive. People are very used to controls you can navigate through, with arrows or the tab key, without losing sight of the rest of controls...")

Now it's possible to choose the order in which the generated characters will be printed. (Blue is the first, Red is the second and Orange the third). Soon will be possible to set orange color by using left mouse (now you have to use right mouse) and to generate alternately the characters type.

A (orrible) sound now will play if you try to edit characters number [made by tapping on my chair, i'll edit it soon...].

I'll also have to fix some more problem.

-----------------------------------------------------------------------------------------

As always any tip and advice is welcome.

P.S: I know there something called "OOP" but because of my english level i'm not able to understand how it works... will be great if someone could help me understand it (with examples etc.)

Code: Select all

function love.load()

	love.graphics.setBackgroundColor(50,50,50)

	--Audio

	Text_Box_Left_Open = love.audio.newSource( "lol.mp3" , "static" )

	--Window x/y

	Window_Height = love.graphics.getHeight()
	Window_Width = love.graphics.getWidth()

	--Fonts

	Font_Pcsenior_16 = love.graphics.newFont( "1pcsenior.ttf", 16 )
	Font_Pcsenior_13 = love.graphics.newFont( "1pcsenior.ttf", 13 )

	--Accepted texts
	----------------
	
	NumberOfConsonants = "4"
	----------------
	NumberOfVowels = "4"
	----------------
	NumberOfNumbers = "2"
	----------------

	--Text

	Text_1 = ""
	Text_2 = ""
	Text_3 = ""

	Word = ""

	Maximum_Text_Lenght = 1

	--Text boxes

	Value_Standard_Added = 10
	Distance = 40
	Text_Color = 150
	Text_Color_Pressed = 100

	Text_Box_1_Visibility = true
	Text_Box_2_Visibility = true
   	Text_Box_3_Visibility = true
	----------------(1)
	Pression_Text_Box_1 = 1
	Pression_Text_Box_2 = 1
	Pression_Text_Box_3 = 1
	------------------Order
	Order_Box_N_Text="N"
	Order_Box_V_Text="V"
	Order_Box_C_Text="C"
	

	

	--Others
	Error = false
	Word = "Random!"
	Pression_Order_Box_N = 1
	Pression_Order_Box_V = 2
	Pression_Order_Box_C = 1.5

	PressPlay_1=0


	--Arrays
	Array_Consonants={"B", "C", "D", "F", "G", "H", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "Z"}
	Array_Vowels={"A", "E", "I", "O", "U"}
	Array_Numbers={"0","1","2","3","4","5","6","7","8","9"}

	--Accepted text

	Accepted_Text = {0,1,2,3,4,5,6,7,8,9}
	Numbers1 = 11

	function WordGenerator(NumberOfConsonants, NumberOfVowels, NumberOfNumbers)

	Word = ""

	Consonants = ""
	Vowels = ""
	Numbers = ""


	for NumberOfConsonants = NumberOfConsonants, 1, -1
	do 
		
		RandomNumber = love.math.random(1, 16)
		Consonants = Consonants.. Array_Consonants[RandomNumber]
	
	end
	for NumberOfVowels = NumberOfVowels, 1, -1
	do 

		RandomNumber = love.math.random(1, 5)
		Vowels = Vowels .. Array_Vowels[RandomNumber]
		
	end
	for NumberOfNumbers = NumberOfNumbers, 1, -1
	do 

		RandomNumber = love.math.random(1, 10)
		Numbers = Numbers .. Array_Numbers[RandomNumber]

	end
		
	return Consonants, Vowels, Numbers
	end


end

function love.keypressed(key)

	if key == "space" then
		PressPlay_1=PressPlay_1+1
	end

end

function love.mousepressed(x, y, button, istouch)

   if button == 1 and x>Text_Box_1_X and x<Text_Box_1_X+Width_Text_Text_Box_1+Value_Standard_Added and y>Text_Box_1_Y and y<Text_Box_1_Y+Height_Text_Text_Box_1+Value_Standard_Added and Text_Box_1_Visibility == true then
   	Pression_Text_Box_1 = (Pression_Text_Box_1 + 1)
   	if Pression_Text_Box_1%2==0 then
   		Text_Box_2_Visibility = false
   		Text_Box_3_Visibility = false
   		Open = true
   		love.audio.play( Text_Box_Left_Open )
   	elseif Pression_Text_Box_1%2==1 then
   		Text_Box_2_Visibility = true
   		Text_Box_3_Visibility = true
   		
   		love.audio.play( Text_Box_Left_Open )
   	end
   end
   if button == 1 and x>Text_Box_2_X and x<Text_Box_2_X+Width_Text_Text_Box_2+Value_Standard_Added and y>Text_Box_2_Y and y<Text_Box_2_Y+Height_Text_Text_Box_2+Value_Standard_Added and Text_Box_2_Visibility == true then
   	Pression_Text_Box_2 = (Pression_Text_Box_2 + 1)
   	if Pression_Text_Box_2%2==0 then
   		Text_Box_1_Visibility = false
   		Text_Box_3_Visibility = false
   		Open = true
   		love.audio.play( Text_Box_Left_Open )
   	elseif Pression_Text_Box_2%2==1 then
   		Text_Box_1_Visibility = true
   		Text_Box_3_Visibility = true
   		
   		love.audio.play( Text_Box_Left_Open )
   	end
   end
   if button == 1 and x>Text_Box_3_X and x<Text_Box_3_X+Width_Text_Text_Box_3+Value_Standard_Added and y>Text_Box_3_Y and y<Text_Box_3_Y+Height_Text_Text_Box_3+Value_Standard_Added and Text_Box_3_Visibility == true then
   	Pression_Text_Box_3 = (Pression_Text_Box_3 + 1)
   	if Pression_Text_Box_3%2==0 then
   		Text_Box_1_Visibility = false
   		Text_Box_2_Visibility = false
   		Open = true
   		love.audio.play( Text_Box_Left_Open )
   	elseif Pression_Text_Box_3%2==1 then
   		Text_Box_1_Visibility = true
   		Text_Box_2_Visibility = true
   		
   		love.audio.play( Text_Box_Left_Open )
   	end
   end
   if button == 1 and x>Order_Box_X and x<Order_Box_X+Width_Text_Order_Box+Value_Standard_Added and y>Order_Box_Y and y<Order_Box_Y+Height_Text_Order_Box+Value_Standard_Added then
   	Pression_Order_Box_N = Pression_Order_Box_N + 1
   end
   if button == 2 and x>Order_Box_X and x<Order_Box_X+Width_Text_Order_Box+Value_Standard_Added and y>Order_Box_Y and y<Order_Box_Y+Height_Text_Order_Box+Value_Standard_Added then
   	Pression_Order_Box_N = Pression_Order_Box_N + 1.50
   end
   if button == 1 and x>Order_Box_X_2 and x<Order_Box_X_2+Width_Text_Order_Box_2+Value_Standard_Added and y>Order_Box_Y_2 and y<Order_Box_Y_2+Height_Text_Order_Box_2+Value_Standard_Added then
   	Pression_Order_Box_V = Pression_Order_Box_V + 1
   end
   if button == 2 and x>Order_Box_X_2 and x<Order_Box_X_2+Width_Text_Order_Box_2+Value_Standard_Added and y>Order_Box_Y_2 and y<Order_Box_Y_2+Height_Text_Order_Box_2+Value_Standard_Added then
   	Pression_Order_Box_V = Pression_Order_Box_V + 1.50
   end
   if button == 1 and x>Order_Box_X_3 and x<Order_Box_X_3+Width_Text_Order_Box_3+Value_Standard_Added and y>Order_Box_Y_3 and y<Order_Box_Y_3+Height_Text_Order_Box_3+Value_Standard_Added then
   	Pression_Order_Box_C = Pression_Order_Box_C + 1
   end
   if button == 2 and x>Order_Box_X_3 and x<Order_Box_X_3+Width_Text_Order_Box_3+Value_Standard_Added and y>Order_Box_Y_3 and y<Order_Box_Y_3+Height_Text_Order_Box_3+Value_Standard_Added then
   	Pression_Order_Box_C = Pression_Order_Box_C + 1.50
   end

   --Increase/decrease

   
   if button == 1 and x>Text_Box_1_X-(Text_Box_1_Height+5) and x<Text_Box_1_X-(5) and y>Text_Box_1_Y and y<Text_Box_1_Y+Text_Box_1_Height then
   	NumberOfConsonants=NumberOfConsonants-1
   end
   if button == 1 and x>Text_Box_1_X+Text_Box_1_Width+5 and x<Text_Box_1_X+Text_Box_1_Width+5+Text_Box_1_Height  and y>Text_Box_1_Y and y<Text_Box_1_Y+Text_Box_1_Height then
   	NumberOfConsonants=NumberOfConsonants+1
   end
   

   ---------------------

    if button == 1 and x>Text_Box_2_X-(Text_Box_2_Height+5) and x<Text_Box_2_X-(5) and y>Text_Box_2_Y and y<Text_Box_2_Y+Text_Box_2_Height then
   	NumberOfVowels=NumberOfVowels-1
   end
   if button == 1 and x>Text_Box_2_X+Text_Box_2_Width+5 and x<Text_Box_2_X+Text_Box_2_Width+5+Text_Box_2_Height  and y>Text_Box_2_Y and y<Text_Box_2_Y+Text_Box_2_Height then
   	NumberOfVowels=NumberOfVowels+1
   end

   ---------------------

    if button == 1 and x>Text_Box_3_X-(Text_Box_3_Height+5) and x<Text_Box_3_X-(5) and y>Text_Box_3_Y and y<Text_Box_3_Y+Text_Box_3_Height then
   	NumberOfNumbers=NumberOfNumbers-1
   end
   if button == 1 and x>Text_Box_3_X+Text_Box_3_Width+5 and x<Text_Box_3_X+Text_Box_3_Width+5+Text_Box_3_Height  and y>Text_Box_3_Y and y<Text_Box_3_Y+Text_Box_3_Height then
   	NumberOfNumbers=NumberOfNumbers+1
   end

end

function love.textinput(UserText)	
	if Pression_Text_Box_1%2==0 then
		
		Verify = tonumber(UserText)

		Numbers2 = Numbers1

		Control = false

		while Control == false do
			Numbers2 = (Numbers2-1)
			if Verify == Accepted_Text[Numbers2] then
				Control = true
				Error = false
			end
			if Numbers2 == 0 then
				Control = true
				Error = true
			end
		end
		if Error == false then		
			
			NumberOfConsonants = NumberOfConsonants..Verify
			if string.len(NumberOfConsonants)>Maximum_Text_Lenght then
			NumberOfConsonants=""
			end			
		end	
	end		
	if Pression_Text_Box_2%2==0 then
		
		Verify = tonumber(UserText)

		Numbers2 = Numbers1

		Control = false

		while Control == false do
			Numbers2 = (Numbers2-1)
			if Verify == Accepted_Text[Numbers2] then
				Control = true
				Error = false
			end
			if Numbers2 == 0 then
				Control = true
				Error = true
			end
		end
		if Error == false then			
			NumberOfVowels = NumberOfVowels..Verify
			if string.len(NumberOfVowels)>Maximum_Text_Lenght then
			NumberOfVowels=""
		end			
		end	
	end		
	if Pression_Text_Box_3%2==0 then
		
		Verify = tonumber(UserText)

		Numbers2 = Numbers1

		Control = false

		while Control == false do
			Numbers2 = (Numbers2-1)
			if Verify == Accepted_Text[Numbers2] then
				Control = true
				Error = false
			end
			if Numbers2 == 0 then
				Control = true
				Error = true
			end
		end
		if Error == false then			
			NumberOfNumbers = NumberOfNumbers..Verify
			if string.len(NumberOfNumbers)>Maximum_Text_Lenght then
			NumberOfNumbers=""
		end			
		end	
	end		
end

function love.update(dt)
	
	PressPlay = love.keyboard.isDown("space")
	
end

function love.draw()	

	--Text boxes
	----------------(1)
	if Text_Box_1_Visibility == true then
		Text_Text_Box_1 = "Number of consonants to generate: " .. NumberOfConsonants

		Width_Text_Text_Box_1 = Font_Pcsenior_13:getWidth(Text_Text_Box_1)
		Height_Text_Text_Box_1 = Font_Pcsenior_13:getHeight(Text_Text_Box_1)

		Text_Box_1_Width = (Width_Text_Text_Box_1 + Value_Standard_Added)
		Text_Box_1_Height = (Height_Text_Text_Box_1 + Value_Standard_Added)

		Text_Box_1_X = (Window_Width/2) - (Text_Box_1_Width/2)
		Text_Box_1_Y = (Window_Height/2) - (Text_Box_1_Height/2)

		if Pression_Text_Box_1%2==0 then
			love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
			love.graphics.rectangle("fill", Text_Box_1_X, Text_Box_1_Y,Text_Box_1_Width , Text_Box_1_Height)
			love.graphics.setColor(225,225,225)
		elseif Pression_Text_Box_1%2==1 then
			love.graphics.setColor(Text_Color,Text_Color,Text_Color)
			love.graphics.rectangle("fill", Text_Box_1_X, Text_Box_1_Y,Text_Box_1_Width , Text_Box_1_Height)
			love.graphics.setColor(225,225,225)
		end

		love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
		love.graphics.rectangle("fill", (Text_Box_1_X-(Text_Box_1_Height+5)), Text_Box_1_Y, Text_Box_1_Height, Text_Box_1_Height)
		love.graphics.setColor(225,225,225)

		love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
		love.graphics.rectangle("fill", (Text_Box_1_X+Text_Box_1_Width+5), Text_Box_1_Y, Text_Box_1_Height, Text_Box_1_Height)
		love.graphics.setColor(225,225,225)

		Text_Sentence_Text_Box_1 = love.graphics.newText( Font_Pcsenior_13, Text_Text_Box_1 )
		love.graphics.draw(Text_Sentence_Text_Box_1, Text_Box_1_X+(Value_Standard_Added/2), Text_Box_1_Y+(Value_Standard_Added/2))


		
	end
	----------------(2)
	if Text_Box_2_Visibility == true then
		Text_Text_Box_2 = "Number of vowels to generate: " .. NumberOfVowels

		Width_Text_Text_Box_2 = Font_Pcsenior_13:getWidth(Text_Text_Box_2)
		Height_Text_Text_Box_2 = Font_Pcsenior_13:getHeight(Text_Text_Box_2)

		Text_Box_2_Width = (Width_Text_Text_Box_2 + Value_Standard_Added)
		Text_Box_2_Height = (Height_Text_Text_Box_2 + Value_Standard_Added)

		Text_Box_2_X = (Window_Width/2) - (Text_Box_2_Width/2)
		Text_Box_2_Y = (Window_Height/2) - (Text_Box_2_Height/2) + (Distance)


		if Pression_Text_Box_2%2==0 then
			love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
			love.graphics.rectangle("fill", Text_Box_2_X, Text_Box_2_Y,Text_Box_2_Width , Text_Box_2_Height)
			love.graphics.setColor(225,225,225)
		elseif Pression_Text_Box_2%2==1 then
			love.graphics.setColor(Text_Color,Text_Color,Text_Color)
			love.graphics.rectangle("fill", Text_Box_2_X, Text_Box_2_Y,Text_Box_2_Width , Text_Box_2_Height)
			love.graphics.setColor(225,225,225)
		end

		love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
		love.graphics.rectangle("fill", (Text_Box_2_X-(Text_Box_2_Height+5)), Text_Box_2_Y, Text_Box_2_Height, Text_Box_2_Height)
		love.graphics.setColor(225,225,225)

		love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
		love.graphics.rectangle("fill", (Text_Box_2_X+Text_Box_2_Width+5), Text_Box_2_Y, Text_Box_2_Height, Text_Box_2_Height)
		love.graphics.setColor(225,225,225)

		Text_Sentence_Text_Box_2 = love.graphics.newText( Font_Pcsenior_13, Text_Text_Box_2 )
		love.graphics.draw(Text_Sentence_Text_Box_2, Text_Box_2_X+(Value_Standard_Added/2), Text_Box_2_Y+(Value_Standard_Added/2))
		
	end
	----------------(3)
	if Text_Box_3_Visibility == true then
		Text_Text_Box_3 = "Number of numbers to generate: " .. NumberOfNumbers

		Width_Text_Text_Box_3 = Font_Pcsenior_13:getWidth(Text_Text_Box_3)
		Height_Text_Text_Box_3 = Font_Pcsenior_13:getHeight(Text_Text_Box_3)

		Text_Box_3_Width = (Width_Text_Text_Box_3 + Value_Standard_Added)
		Text_Box_3_Height = (Height_Text_Text_Box_3 + Value_Standard_Added)

		Text_Box_3_X = (Window_Width/2) - (Text_Box_3_Width/2)
		Text_Box_3_Y = (Window_Height/2) - (Text_Box_3_Height/2) + (Distance * 2)


		if Pression_Text_Box_3%2==0 then
			love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
			love.graphics.rectangle("fill", Text_Box_3_X, Text_Box_3_Y,Text_Box_3_Width , Text_Box_3_Height)
			love.graphics.setColor(225,225,225)
		elseif Pression_Text_Box_3%2==1 then
			love.graphics.setColor(Text_Color,Text_Color,Text_Color)
			love.graphics.rectangle("fill", Text_Box_3_X, Text_Box_3_Y,Text_Box_3_Width , Text_Box_3_Height)
			love.graphics.setColor(225,225,225)
		end

		love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
		love.graphics.rectangle("fill", (Text_Box_3_X-(Text_Box_3_Height+5)), Text_Box_3_Y, Text_Box_3_Height, Text_Box_3_Height)
		love.graphics.setColor(225,225,225)

		love.graphics.setColor(Text_Color_Pressed,Text_Color_Pressed,Text_Color_Pressed)
		love.graphics.rectangle("fill", (Text_Box_3_X+Text_Box_3_Width+5), Text_Box_3_Y, Text_Box_3_Height, Text_Box_3_Height)
		love.graphics.setColor(225,225,225)




		Text_Sentence_Text_Box_3 = love.graphics.newText( Font_Pcsenior_13, Text_Text_Box_3 )
		love.graphics.draw(Text_Sentence_Text_Box_3, Text_Box_3_X+(Value_Standard_Added/2), Text_Box_3_Y+(Value_Standard_Added/2))
		
	end

	--Order 

	if PressPlay == true then
	NumberOfConsonants=tonumber(NumberOfConsonants)
	NumberOfVowels=tonumber(NumberOfVowels)
	NumberOfNumbers=tonumber(NumberOfNumbers)
	WordGenerator(NumberOfConsonants, NumberOfVowels, NumberOfNumbers)
	end	

	Width_Text_Order_Box = Font_Pcsenior_13:getWidth(Order_Box_N_Text)
	Height_Text_Order_Box = Font_Pcsenior_13:getHeight(Order_Box_N_Text)

	Order_Box_Width = (Width_Text_Order_Box + Value_Standard_Added)
	Order_Box_Height = (Height_Text_Order_Box + Value_Standard_Added)

	Order_Box_X = (Window_Width/2) - (Order_Box_Width/2)
	Order_Box_Y = (Window_Height/2) - (Order_Box_Height/2) + (Distance * 3)

	Pos_1=""
	Pos_2=""
	Pos_3=""

	Verify_Order=""
	Verify_Order2=0

	if Pression_Order_Box_N%2==0 then
		love.graphics.setColor(255,71,71)
		love.graphics.rectangle("fill", Order_Box_X, Order_Box_Y,Order_Box_Width , Order_Box_Height)
		love.graphics.setColor(225,225,225)
		Pos_2=Numbers
		Verify_Order_Numbers=2
		
	elseif Pression_Order_Box_N%2==1 then
		love.graphics.setColor(71,149,255)
		love.graphics.rectangle("fill", Order_Box_X, Order_Box_Y,Order_Box_Width , Order_Box_Height)
		love.graphics.setColor(225,225,225)
		Pos_1=Numbers
		Verify_Order_Numbers=1
	else
		love.graphics.setColor(255,158,71)
		love.graphics.rectangle("fill", Order_Box_X, Order_Box_Y,Order_Box_Width , Order_Box_Height)
		love.graphics.setColor(225,225,225)
		Pos_3=Numbers
		Verify_Order_Numbers=3
	end

	Text_Sentence_Order_Box_N = love.graphics.newText( Font_Pcsenior_13, Order_Box_N_Text )
	love.graphics.draw(Text_Sentence_Order_Box_N, Order_Box_X+(Value_Standard_Added/2), Order_Box_Y+(Value_Standard_Added/2))

	-----------------------------------	

	Width_Text_Order_Box_2 = Font_Pcsenior_13:getWidth(Order_Box_V_Text)
	Height_Text_Order_Box_2 = Font_Pcsenior_13:getHeight(Order_Box_V_Text)

	Order_Box_Width_2 = (Width_Text_Order_Box_2 + Value_Standard_Added)
	Order_Box_Height_2 = (Height_Text_Order_Box_2 + Value_Standard_Added)

	Order_Box_X_2 = (Window_Width/2) - (Order_Box_Width_2/2+Distance)
	Order_Box_Y_2 = (Window_Height/2) - (Order_Box_Height_2/2) + (Distance * 3)

	if Pression_Order_Box_V%2==0 then
		love.graphics.setColor(255,71,71)
		love.graphics.rectangle("fill", Order_Box_X_2, Order_Box_Y_2,Order_Box_Width_2 , Order_Box_Height_2)
		love.graphics.setColor(225,225,225)
		Pos_2=Vowels
		Verify_Order_Vowels=2		
	elseif Pression_Order_Box_V%2==1 then
		love.graphics.setColor(71,149,255)
		love.graphics.rectangle("fill", Order_Box_X_2, Order_Box_Y_2,Order_Box_Width_2 , Order_Box_Height_2)
		love.graphics.setColor(225,225,225)
		Pos_1=Vowels
		Verify_Order_Vowels=1
	else
		love.graphics.setColor(255,158,71)
		love.graphics.rectangle("fill", Order_Box_X_2, Order_Box_Y_2,Order_Box_Width_2 , Order_Box_Height_2)
		love.graphics.setColor(225,225,225)
		Pos_3=Vowels
		Verify_Order_Vowels=3
	end

	Text_Sentence_Order_Box_V = love.graphics.newText( Font_Pcsenior_13, Order_Box_V_Text )
	love.graphics.draw(Text_Sentence_Order_Box_V, Order_Box_X_2+(Value_Standard_Added/2), Order_Box_Y_2+(Value_Standard_Added/2))

	------------------------------------------

	Width_Text_Order_Box_3 = Font_Pcsenior_13:getWidth(Order_Box_C_Text)
	Height_Text_Order_Box_3 = Font_Pcsenior_13:getHeight(Order_Box_C_Text)

	Order_Box_Width_3 = (Width_Text_Order_Box_3 + Value_Standard_Added)
	Order_Box_Height_3 = (Height_Text_Order_Box_3 + Value_Standard_Added)

	Order_Box_X_3 = (Window_Width/2) - (Order_Box_Width_3/2-Distance)
	Order_Box_Y_3 = (Window_Height/2) - (Order_Box_Height_3/2) + (Distance * 3)

	if Pression_Order_Box_C%2==0 then
		love.graphics.setColor(255,71,71)
		love.graphics.rectangle("fill", Order_Box_X_3, Order_Box_Y_3,Order_Box_Width_3 , Order_Box_Height_3)
		love.graphics.setColor(225,225,225)
		Pos_2=Consonants
		Verify_Order_Consonants=2
		
		
	elseif Pression_Order_Box_C%2==1 then
		love.graphics.setColor(71,149,255)
		love.graphics.rectangle("fill", Order_Box_X_3, Order_Box_Y_3,Order_Box_Width_3 , Order_Box_Height_3)
		love.graphics.setColor(225,225,225)
		Pos_1=Consonants
		Verify_Order_Consonants=1
		
		
	else
		love.graphics.setColor(255,158,71)
		love.graphics.rectangle("fill", Order_Box_X_3, Order_Box_Y_3,Order_Box_Width_3 , Order_Box_Height_3)
		love.graphics.setColor(225,225,225)
		Pos_3=Consonants
		Verify_Order_Consonants=3
		
		
	end

	Text_Sentence_Order_Box_C = love.graphics.newText( Font_Pcsenior_13, Order_Box_C_Text )
	love.graphics.draw(Text_Sentence_Order_Box_C, Order_Box_X_3+(Value_Standard_Added/2), Order_Box_Y_3+(Value_Standard_Added/2))

	--Random text box

	
	
	if PressPlay == true then
	NumberOfConsonants=tonumber(NumberOfConsonants)
	NumberOfVowels=tonumber(NumberOfVowels)
	NumberOfNumbers=tonumber(NumberOfNumbers)
	Verify_Order=Verify_Order_Numbers+Verify_Order_Vowels+Verify_Order_Consonants
	if Verify_Order==6 then
		WordGenerator(NumberOfConsonants, NumberOfVowels, NumberOfNumbers)	
		Word=Pos_1..Pos_2..Pos_3
	else
		Word="Error!"
	end
	end
	

	Word_1=Word
	Width_Random_Text_Box = Font_Pcsenior_16:getWidth(Word_1)
	Height_Random_Text_Box = Font_Pcsenior_16:getHeight(Word_1)

	Text_Random_Text_Box = love.graphics.newText(Font_Pcsenior_16, Word_1)
	love.graphics.draw(Text_Random_Text_Box,(Window_Width/2)-(Width_Random_Text_Box/2) ,100)

end
Attachments
XYZ.love
(12.42 KiB) Downloaded 77 times
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests