abhi1988sri
Still Fresh
- Joined
- Oct 20, 2013
- Messages
- 1
Hi,
I am new to python as well as pygame so was trying my hand on making TicTacToe.I made one with no animations in python but with animations, I see to get stuck with deciding win and loss. I want user to make use mouse click and if its in a certain region , I want to make "X" or "O". Also, how decide win or loss, how to match. Please help.
import pygame,sys
from pygame.locals import *
pygame.init()
FPS=30
fpsClock=pygame.time.Clock()
DISPLAYSURF=pygame.display.set_mode((500,500))
pygame.display.set_caption("TicTacToeAnimation")
WHITE=(255,255,255)
BLUE=(0,0,255)
GREEN=(0,255,0)
RED=(255,0,0)
xcord=120
ycord=100
myfont=pygame.font.SysFont("monopause",20)
label=myfont.render("TIC TAC TOE",1,(255,0,0,120))
#put sound here later
running=1
def drawLinesForMouse(x,y):
#do something make "X" or "O"
while running:
DISPLAYSURF.fill(WHITE)
event = pygame.event.poll()
if event.type == pygame.QUIT:
running=0
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
x,y=event.pos
DISPLAYSURF.blit(label,(150,10))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord,ycord),(300,ycord))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord,ycord+60),(300,ycord+60))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord+60,ycord-60),(xcord+60,200))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord+120,ycord-60),(xcord+120,200))
drawLinesForMouse(x,y)
pygame.display.update()
Any help is appreciated..
Thanks & Regards
Abhinav
I am new to python as well as pygame so was trying my hand on making TicTacToe.I made one with no animations in python but with animations, I see to get stuck with deciding win and loss. I want user to make use mouse click and if its in a certain region , I want to make "X" or "O". Also, how decide win or loss, how to match. Please help.
import pygame,sys
from pygame.locals import *
pygame.init()
FPS=30
fpsClock=pygame.time.Clock()
DISPLAYSURF=pygame.display.set_mode((500,500))
pygame.display.set_caption("TicTacToeAnimation")
WHITE=(255,255,255)
BLUE=(0,0,255)
GREEN=(0,255,0)
RED=(255,0,0)
xcord=120
ycord=100
myfont=pygame.font.SysFont("monopause",20)
label=myfont.render("TIC TAC TOE",1,(255,0,0,120))
#put sound here later
running=1
def drawLinesForMouse(x,y):
#do something make "X" or "O"
while running:
DISPLAYSURF.fill(WHITE)
event = pygame.event.poll()
if event.type == pygame.QUIT:
running=0
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
x,y=event.pos
DISPLAYSURF.blit(label,(150,10))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord,ycord),(300,ycord))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord,ycord+60),(300,ycord+60))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord+60,ycord-60),(xcord+60,200))
pygame.draw.line(DISPLAYSURF,BLUE,(xcord+120,ycord-60),(xcord+120,200))
drawLinesForMouse(x,y)
pygame.display.update()
Any help is appreciated..
Thanks & Regards
Abhinav