Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, sys
- from pygame.locals import *
- #Magic numbers
- fps = 30
- winW = 640
- winH = 480
- boxSize = 40
- gapSize = 75
- boardW = 3
- boardH = 3
- xMargin = int((winW - (boardW * (boxSize + gapSize))) / 2)
- yMargin = int((winW - (boardW * (boxSize + gapSize))) / 2)
- #Lil bit o' color R G B
- NAVYBLUE = ( 60, 60, 100)
- correctCords = [[175,275,375],[375,275,175]]
- bgColor = NAVYBLUE
- unC = pygame.image.load("unC.png")
- cor = pygame.image.load("correct.png")
- inc = pygame.image.load("wrong.png")
- correct = "Correct"
- inCorrect = "Incorrect"
- def main():
- global FPSCLOCK, DISPLAYSURF
- pygame.init()
- FPSCLOCK = pygame.time.Clock()
- DISPLAYSURF = pygame.display.set_mode((winW, winH))
- mousex = 0 #stores x-coordinate of mouse event
- mousey = 0 #stores y-coordinate of mouse event
- pygame.display.set_caption("Branches")
- DISPLAYSURF.fill(bgColor)
- gridGame(inCorrect, correct,gapSize,xMargin,yMargin,boxSize)
- while True:
- mouseClicked = False
- for event in pygame.event.get():
- if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
- pygame.quit()
- sys.exit()
- elif event.type == MOUSEMOTION:
- mousex,mousey = event.pos
- elif event.type == MOUSEBUTTONUP:
- mousex, mousey = event.pos
- pos = pygame.mouse.get_pos()
- mouseClicked = True
- unCa = unC.get_rect()
- corA = cor.get_rect()
- print unCa
- print corA
- print pos
- if unCa.collidepoint(pos):
- DISPLAYSURF.blit(cor,(mousey,mousex))
- """lada = unC.get_rect()
- lada =
- if mousex and mousey == lada:
- for x in correctCords:
- for y in x:
- for z in x:
- if mousey and mousex == z and y:
- DISPLAYSURF.blit(cor,(mousey,mousex))
- print lada"""
- pygame.display.update()
- FPSCLOCK.tick(fps)
- def gridGame(inCorrect, correct,gapSize,xMargin,yMargin,boxSize):
- grid = []
- cordX = []
- cordY = []
- correctRecs = []
- #cordinates = []
- #cordinates.append([])
- #cordinates.append([])
- #cordinates.append([])
- #this is basically getBoard() all over again
- #This part will arrange the actual backend grid
- for row in range(3):
- grid.append([])
- #cordinates[0].append(gapSize+(row+1)*100)
- #cordinates[1].append(gapSize+(row+1)*100)
- #cordinates[2].append(gapSize+(row+1)*100)
- for column in range(3):
- grid[row].append(inCorrect)
- for row in range(3):
- cordX.append([])
- for column in range(3):
- cordX[row].append(gapSize+(row+1)*100)
- for row in range(3):
- cordY.append([])
- for column in range(3):
- cordY[row].append(gapSize+(column+1)*100)
- #print cordX[0][0], cordY[0][0]
- grid[0][2] = correct
- grid[1][1] = correct
- grid[2][0] = correct
- #Y-AXEL SKRIVS FoRST ([Y][X])
- #print cordinates[2][1]
- DISPLAYSURF.blit(cor,(100,100))
- #Let's draw it as well
- for row in range(3):
- for column in range(3):
- DISPLAYSURF.blit(unC,(gapSize+(row+1)*100,gapSize+(column+1)*100))
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement