Skip to main content

Python fun game

πŸ’žπŸ’ž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:



            pydroid3:

Modules: 
Turtle module.
 
    • 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 :

      

          
                            



 If the user chooses the "yes" option, which are compared to variables which we assigned and the loop condition of if is executes with the turtle graphics.

                                        


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






 



Comments

Post a Comment

Popular posts from this blog

PYTHON TUTRLE

  LEARN WITH FUN@FUTURE_CODE    😘 ONLINE PROPOSAL 😍 Python  uses an interpreter to translate and run its code and that’s why it’s called a scripting language.   A  python script normally can be full of functions that can be be imported as a library of function in other scripts. This python code will help you to propose your girlfriend/boyfriend. we are going to draw the rose flower 🌹 with text to propose someone πŸ’– PREVIEW:    Requirements: Text editor such as Python IDLE (pycharm). Install the python text editor such as pycharm  use this source code given below. Import the turtle module. This  turtle module  is a pre-installed python library that enables users to create pictures and shapes by providing them with a virtual canvas.                     To install turtle module : pip install turtle   Let's we import the turtle module as t. Then we create a ...

Python boto3 send_message

  Automated message  PyAutoGUI is a Python automation library used to click, drag, scroll, move, etc. It can be used to click at an exact position. PyAutoGUI module ,Python scripts control the mouse and keyboard to automate interactions with other applications. The API is designed to be as simple. PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2 and 3.   This code is used to create the automated message in WhatsApp, iMessage, telegram and other social media.  Preview : Requirements:  text editor such as Python IDLE. In my case I’m using Pycharm {In mobile you can use Pydroid 3} Modules: PyautoGUI. Import the relevant module {pyautogui}. This pyautogui is pre-installed  python library that enables the users to create automations and mouse, keyboard controls. Features:  Sending keystrokes to applications (for example, to fill out forms). Take screenshots, and it is saved as .png or .jpeg extension. Locate an applicat...

Arduino projects

  I love you 8x8 matrix display MAX7219 Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. The Wiring and Arduino both use C/C++ as programming languages and Arduino uses a simplified version. Processing used Java as a programming language but served as the basis for Wiring, which was the basis for Arduino. In this tutorial we are creating the led display in 8x8 matrix MAX7219 module. Preview : Components required: Arduino UNO board LED matrix MAX7219 Jumper wires Diagram: In proteus schematic diagram: First we need Arduino IDLE for creating the led matrix display program. Download the Arduino IDLE from the given below link Arduino IDLE download link:  https://www.arduino.cc/en/software Then we need to dow...