Final Project Progress Report 3
- Screenshots.
So basically today I worked on my game hardcore. Everything is on track and I think it is 90% finished, took my around 5 hours today.
- Describe briefly what I’ve done.
Today, I finished up all my while loops and functions. As previously mentioned, there were many flaws in this game and today I limited a lot of them. I completed all the programming for the gameplay and also for the automated gameplay of the computer. This project was not as easy as I thought because in the beginning, when I was doing my Pecha Kucha, I thought this would not be that hard. However, programming this sort of action game was extremely challenging, but I enjoyed it. There were lots of difficulties and problems along the way. Such as using the “user_soldier_row” and “user_soldier_column” and “comp_row_grenade”. I had to test each one out and after a while I already felt dizzy. I currently have 718 lines of codes and this is because I did a lot of things the long way (since this is my first time coding an actual game). In this game, there are 5 figures (General, Archer, Grenade, Cannon, Soldier), and I have a set of code for each one. The good thing was that once I grasp the concept of 1 figure, then I could just reuse parts of that code for other figures. For example, as you can see in the screenshots above, there was a lot of repetition in while loops and for loops and if/else statements. I am sure there are shorter and faster ways but at the end of the day, my game works fine. One thing I added to my prototype that really enhanced my game was colour. While testing with my parents, they couldn’t tell the difference between the “user figures” and the “computer figures”. I came up with an idea of using colour but I had absolutely no idea how to execute it. So I did a lot of research online and luckily there were a few websites that provided the actual code for colour in Python. So I “borrowed” that code and used it in my program (as seen in the 3rd screenshot), and ultimately refined my prototype.
- A few lines of code with comments showing your understanding of the code.
elif the_choice == "Soldier" or the_choice == "soldier": x = False while (x == False): user_soldier_row = int(raw_input ("Insert the new soldier row:")) user_soldier_col = int(raw_input ("Insert thew new soldier col:")) if board[user_soldier_row][user_soldier_col] == "G" or board[user_soldier_row][user_soldier_col] == "A" or board[user_soldier_row][user_soldier_col] == "g" or board[user_soldier_row][user_soldier_col] == "C" or board[user_soldier_row][user_soldier_col] == "S": print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_soldier_row) - int (guess_row_soldier)) == 1 and abs(int(user_soldier_col) - int(guess_col_soldier)) == 1: print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_soldier_row) - int (guess_row_soldier)) > 1 or abs(int(user_soldier_col) - int(guess_col_soldier)) > 1: print "invalid, sorry. Please re-enter position" x = False elif board[user_soldier_row][user_soldier_col] == "X": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_soldier][comp_col_soldier] = "O" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "L": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_general][comp_col_general] = "L" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "d": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_archer][comp_col_archer] = "d" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "F": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_grenade][comp_col_grenade] = "F" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "Y": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_cannon][comp_col_cannon] = "Y" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "O": board[user_soldier_row][user_soldier_col] = "S" board[guess_row_soldier][guess_col_soldier] = "O" guess_row_soldier = user_soldier_row guess_col_soldier = user_soldier_col set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "h": print "Congratulations! You won the game!!!"
- Other resources you came across in this learning process (e.g. a post from a discussion forum, an advice from your friends/classmates).
Used internet.
https://pypi.python.org/pypi/colored
http://matplotlib.org/examples/color/named_colors.html