ππLoves me or not gameπ
Turtle is a Python library which used to create graphics, pictures, and games. It was a part of the original Logo programming language. ... The Logo programming language was popular among the kids because it enables us to draw attractive graphs to the screen in the simple way.
We can use functions like turtle.forward(…) and turtle.right(…) which can move the turtle around.
This python code is used to create some game to make some funs with your friends.
PREVIEW:
Requirements: Text editor such as Python IDLE. In my case i’m using Pycharm (in mobile you can use pydroid 3).
Pycharm:
- Import the turtle module.This turtle module is a pre-installed python library that enables users to create pictures and shapes.
To install turtle module: pip install turtle
Let’s open the pycharm and create new project and start our turtle gaming program.
First we importing the turtle module.Now we creating two variables to store some commands like “yes / no”(smp, smp2).
import turtle
print(" ############π€©LOVES ME OR NOTπ################\n")
print(" -create by srilakivarma")
smp='yes'
smp2='no'
girl_name=input("Enter the name:\n\t")
ram=(input("Do you Like me "+girl_name+" , just say yes or no:\n\t"))
Creating variables like girl_name, ram to store input values which are given by the users.
- In ram (name)is taken as input ( values given by users )
- In girl_name variable it will ask some queries like “do you like me or not, just say yes or no”. If we put command yes/no it will store the temporary command in the girl_name. It will change every new inputs.
If loop condition:
Now we creating the if loop to comparing the variable ram with the smp and smp2 (var2==smp!=smp2). If we making the ram as yes and it will check whether it is equal to smp and not equal to smp2. If the loop gets true it executes following code.
if (ram==smp!=smp2):Now we consider variable pen with turtle command. pen=turtle.Turtle().
Now we trying to draw a heart, so let’s make function curve because heart contains two curves in left and right corners. To make a curve I’m using the for loop in range of 200.
pen = turtle.Turtle()
def curve():
for i in range(200):
pen.right(1)
pen.forward(1)
Now we defining some new function named as heart().
Speed- to increase pen speed
Fillcolor- fill the colour to given area
Forward - make the pen to move forward
Left - make the pen to move left
Right- make the pen to move right
def heart():
pen.speed(420)
pen.fillcolor('red')
pen.begin_fill()
pen.left(140)
pen.speed(190)
pen.forward(113)
curve()
pen.left(120)
curve()
pen.forward(112)
pen.end_fill()
Now we creating some text function to mention some quotes in turtle GUI.(Graphical User Interface). Now we moving the position of the pen x= -120, y= -50 ( this makes the quotes to displays in centre).
Color- represents the colour of your text.
Write- pen writes your text which you’re given to code.
Font- this represents the type of fonts which you need.
def text():
pen.up()
pen.setpos(-120,-50)
pen.down()
pen.color('#00999c')
pen.write("ππI Love You "+girl_name, font=("verdana", 21, "bold"))
heart()
text()
pen.ht()
turtle.done()
Output :
Elif loop condition:
Now we making elif part which are vice verse of if loop part. The same code which before we create in if loop do it same with some code given below.
elif(ram==smp2!=smp):
pen = turtle.Turtle()
def curve():
for i in range(200):
pen.right(1)
pen.forward(1)
def heart():
pen.speed(420)
pen.fillcolor('red')
pen.begin_fill()
pen.left(140)
pen.speed(190)
pen.forward(113)
curve()
pen.left(120)
curve()
pen.forward(112)
pen.end_fill()
# turtle.done()
heart()
Make the pen to move to the position x=0,y=160. Making the broken heart with zig zag line with code in if loop part.Let’s make some text function which we need to written to turtle GUI.
pen.penup()
pen.goto(0, 160)
pen.pendown()
for i in range(3):
pen.color("white")
pen.width(3.9)
pen.left(75)
pen.forward(40)
pen.right(65)
pen.forward(40)
pen.ht
def txt():
pen.penup()
pen.setpos(-120, -50)
pen.pendown()
pen.color("#00999c")
pen.write("π₯Ίπyou broke me"+girl_name,font=("verdana",21,"bold"))
txt()
pen.ht()
turtle.done()
Output :
If the user chooses the "no" option, which are compared to variables which we assigned and the loop condition of elif is executes with the turtle graphics.
Else loop condition:
Else part shows invalid statement because if the input values is not equal to command other than yes/no.
else:
print("π΅π«invalid statement,just say yes/noπ")
Output :
If the user chooses the other than the yes/no option, which are compared to variables which we assigned and the loop condition of else is executes without the turtle graphics.
click here->source code









Good effort
ReplyDelete