I've been given 3 days to create this game for my HighSchool final. I am beyond stressed out in that I've spent countless hours trying to code what i'm about to describe with no success so absolutely ANY help is appreciated. I've put some creativity into it in that the board is a iphone keyboard and the the tokens/chips are emojis. http://ift.tt/1tpt0Vd Basically the Player's chip is set to a certian cordinate which is the grey box over the middle collum, i need it to blit to either the left or right colum depending on the input and when the enter key is pressed, it drops in that column to the epmty row. Currently the random player selector keeps bliting both the players tokens and the keyboard input doesn't do anything, any suggestions? Also should I use a dictionary or set every spot to False and when a token takes its place, set it to True to check if occupied? Thanks once again!
"""
Name
Connect 3~Emoji Edition
"""
import pygame, sys, random
from pygame.locals import*
#Display
DISPLAYSURF=pygame.display.set_mode((850, 725), 0, 32)
pygame.display.set_caption('Connect 3~Emoji Edition')
#Colors
WHITE=(255, 255, 255)
#Players
Player1='P1'
Player2='P2'
turn=Player1
#Images
Board=pygame.image.load('Keyboard.png')
Boardx=45
Boardy=200
Token1=pygame.image.load('PoopEMJ.png')
Token1=pygame.transform.scale(Token1, (90, 90))
Token1x=375
Token1y=215
Token2=pygame.image.load('LaughingEMJ.png')
Token2=pygame.transform.scale(Token2, (90, 90))
Token2x=375
Token2y=215
while True:
DISPLAYSURF.fill(WHITE)
DISPLAYSURF.blit(Board,(Boardx, Boardy))
if random.randint(0, 1) == 0:#Randomly selects what player goes first
turn = Player1
DISPLAYSURF.blit(Token1,(Token1x, Token1y))
else:
turn = Player2
DISPLAYSURF.blit(Token2,(Token2x, Token2y))
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
if turn == Player1:
DISPLAYSURF.blit(Token1,(Token1x, Token1y))
if event.type == K_LEFT:
Token1x-=150
DISPLAYSURF.blit(Token1,(Token1x, Token1y))
if event.type == K_RIGHT:
Token1x+=150
DISPLAYSURF.blit(Token1,(Token1x, Token1y))
Aucun commentaire:
Enregistrer un commentaire