Read more about the article python code for smartphone controlled mouse using arduino IDE
Python Code For Smartphone Controlled Mouse Using Arduino IDE

python code for smartphone controlled mouse using arduino IDE

In this article we are going to make project : arduino base  smartphone controlled mouse using python code project. so guys let's start Step 1: pre-requirement  Arduino IDEBluetooth module (HC-05)Python…

Continue Readingpython code for smartphone controlled mouse using arduino IDE

Tic Tac Toe Project in python

Tic Tac Toe Project in python:

What is Tic Tac Toe?

you can play this game  anywhere with just a pen and paper.Tic Tac Toe is one of the most favorite played game and is the best time killer game that it.
 If you don’t know how to play this game don’t worry let us first understand that.With this Python project by python tutorials point, we are going to build an interactive game of Tic Tac Toe where we will learn new thing along the way. So let’s start:
How to play this game:
The game is played by two players. First, player draw a board with a 3×3 square matrix grid. The first starting player choose ‘X’ and draws it on matrix grid then it is the chance of the second player to draw ‘O’ sign on the available spaces. similar to this, the players draw ‘X’ and ‘O’ alternatively on the empty spaces. Finally the player wins the game otherwise the game draws python

Steps Follows to a Python Tic Tac Toe Game Project –

Step #01) How to install pygame library:

Step #02) Initializing game components

Step #03) Initializing Pygame window

Step #04) Load and transform images

Step #05) Define the functions

Step #06) Run the game forever

We need to run our game inside an infinite loop. It will continuously look for events and when a user presses the mouse button on the grid we will first get the X and Y coordinates of the mouse. Then we will check which square the user has clicked. Then we will draw the appropriate ‘X’ or ‘O’ image on the canvas. So that is basically what we will do in this Python project idea.

Step 01) How to install pygame library:

To implement this game, we need to use the basic concepts of Python and Pygame library which is a Python library for building cross-platform game. It contain the modules needed for run  computer graphic and sound libraries. 
To install the library, you can need to import library, use pip installer  command line:
    1. pip install pygame

tic tac toe in python:

Step 02) Initializing game components

    1. import pygame as pgs,sys
    1. from pygame.locals import *
    1. import time
    1. #Need to initialize global variable
    1. XO = ‘x’
    1. winner = None
    1. draw = False
    1. width = 300
    1. height = 300
    1. white = (255, 255, 255)
    1. line_color = (10,10,10)
    1. #TicTacToe 3×3 board size matrix
    1. TTT = [[None]*3,[None]*3,[None]*3]

2 payer tic tac toe python beginner :

Step 03) Initializing Pygame window

    1. #How to initializing pygame windows
    1. pgs.init()
    1. fps = 30
    1. CLOCK = pgs.time.Clock()
    1. screen = pgs.display.set_mode((width, height+100),0,32)
    1. pgs.display.set_caption(“python Tic Tac Toe”)

Step 04) Load and transform images

    1. #How to loading the image
    1. opening = pgs.image.load(‘pythonslearning.png’)
    1. y_img = pgs.image.load(‘y.png’)
    1. z_img = pgs.image.load(‘z.png’)
    1. #How to resizing image
    1. y_img = pgs.transform.scale(y_img, (80,80))
    1. z_img = pgs.transform.scale(z_img, (80,80))
    1. opening = pgs.transform.scale(opening, (width, height+100))
 (more…)

Continue ReadingTic Tac Toe Project in python