initial commit

master
drewgs83 4 years ago
commit 3f54a6e625

1
.gitignore vendored

@ -0,0 +1 @@
env/

@ -0,0 +1,122 @@
"""Final Project
Goal: Demonstrate what you have learned in this class with a GUI Tic-Tac-Toe
game. It's also good experience to see a description of what is wanted by a
non-programmer. My coworker helped write the following description.
Description:
--------------------------------------------------------------------------------
We are looking to develop a stand-alone Tic-Tac-Toe game! It should have the
following features:
Players should be able to play two people vs each other.
Players should be able to play one player vs computer (to encourage
players to keep playing, we want random moves, not an always wins computer
opponent).
We expect that players would be able to use the dropdown menus to start a
new game, and to exit the game.
It should automatically switch between X and O after one places their
mark.
We also want it to, in a one player game, let players pick X or O and then
randomize if they or the computer goes first, and let players know who is
going first, not just either make a move or wait on the player looking
like nothing happened.
--------------------------------------------------------------------------------
You are free to ask me any questions about this description for more
clarification. One thing I will say is to not worry about details until you
have a working Tic-Tac-Toe GUI. Then try adding the other parts in the
description later.
Requirements:
Look at the included 'CIS 216 Project Requirements' file. There are three
formats: CSV, Libre Office, and Microsoft Office. You can use whichever one is
easiest for you. It shows everything I will be looking for when I grade your
assignment to see you have learned topics in this class. In order to receive a
grade for each topic, you are _required_ to put a line number to show where you
have fulfilled the requirement. (Again, you only need to update one format file)
Grading: 20% of main class grade
- Final Project Draft: 5% - Participation points, just push up what you have
on or before April 12, 11:59 PM to get the full 5%. This is to encourage you
starting now, and not waiting until the end of the semester.
- Final Project: 15% - Push up for turn in before May 3, 5:00 PM. The
earlier you turn it in, the greater the chance I will be able to return it back
to you with suggested fixes for full credit!
Reminder: No work is accepted after May 3, 5:00 PM!
Name: <Andres Gomez>
Date: <2021-04-10>
Notes: <2021 -04-12 display board, and draft for program>
<2021 -04-23 add GUI https://pypi.org/project/PySimpleGUI/>
"""
import string
import PySimpleGUI as sg
import random
def play_game():
display_board ()
#while the game is still going
while game_going:
#handle a turn
handle_turn(current_player)
#check if he game has ended
check_if_game_over()
# cahnge to the other player
change_player()
#the game has ended
if winner == 'X' or winner == 'O':
print (winner + " won.")
elif winner == None:
print ("Tie.")
#Make the First window
def make_window1():
menu_def = [['Game', ['Start', 'Quit']],]
layout = [[sg.Menu(menu_def, )],
[sg.Text('Select the number of Players')],
[sg.Radio('One Player', group_id="P1_PREF", default=False, size=(10, 1)), sg.Radio('Two Players', group_id="P1_PREF", default=False, size=(10, 1))],
[sg.Text('Player 1, choose X or O, then click on "Start"')],
[sg.Radio('X', group_id="P2_PREF", default=False, size=(10, 1)), sg.Radio('O', group_id="P2_PREF", default=False, size=(10, 1))],
[sg.Button('Start')]]
return sg.Window('Window 1', layout, finalize=True)
#Make the Game window
def make_window2():
bw = {'size':(3,1), 'font':('Frankling Gothic Book', 24), 'button_color':("black","#F8F8F8")}
layout = [[sg.Text(key='-IN2-')],
[sg.Button('',**bw), sg.Button('',**bw),sg.Button('',**bw)],
[sg.Button('',**bw), sg.Button('',**bw),sg.Button('',**bw)],
[sg.Button('',**bw), sg.Button('',**bw),sg.Button('',**bw)],
[sg.Button('Exit')]]
return sg.Window('Window 2', layout, finalize=True)
#Call the Window Functions
def main():
#First window does not remain active
window2 = None
window1 = make_window1()
while True:
window, event, values = sg.read_all_windows()
if event == sg.WIN_CLOSED and window == window1 or event =='Quit':
break
if event == 'Start' and not window2:
window1.hide()
window2 = make_window2()
if window == window2 and (event in (sg.WIN_CLOSED, 'Exit')):
window2.close()
window2 = None
window1.un_hide()
if __name__ == '__main__':
main()

Binary file not shown.
Loading…
Cancel
Save