From b0bbff62eca2392a5209f86c3166bdb3f6e78be0 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:55:11 -0500 Subject: [PATCH 01/29] Update lab_01.py --- Lab 01 - First Program/lab_01.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lab 01 - First Program/lab_01.py b/Lab 01 - First Program/lab_01.py index e69de29bb..811bb1938 100644 --- a/Lab 01 - First Program/lab_01.py +++ b/Lab 01 - First Program/lab_01.py @@ -0,0 +1 @@ +Sup \ No newline at end of file From 97d4e1c984680edb323d19ef958b6d4d6346a434 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 8 Feb 2024 08:49:24 -0500 Subject: [PATCH 02/29] Hello World --- Lab 01 - First Program/lab_01.py | 2 +- Testing/test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lab 01 - First Program/lab_01.py b/Lab 01 - First Program/lab_01.py index 811bb1938..182a3e952 100644 --- a/Lab 01 - First Program/lab_01.py +++ b/Lab 01 - First Program/lab_01.py @@ -1 +1 @@ -Sup \ No newline at end of file +Sup \ No newline at end of file diff --git a/Testing/test.py b/Testing/test.py index e69de29bb..f301245e2 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -0,0 +1 @@ +print("Hello World!") From e1111c5f43795680905fea7614d523cf257e8c48 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 8 Feb 2024 09:35:14 -0500 Subject: [PATCH 03/29] Update lab_01.py --- Lab 01 - First Program/lab_01.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lab 01 - First Program/lab_01.py b/Lab 01 - First Program/lab_01.py index 182a3e952..ee439b1bd 100644 --- a/Lab 01 - First Program/lab_01.py +++ b/Lab 01 - First Program/lab_01.py @@ -1 +1,8 @@ -Sup \ No newline at end of file +print("Hold your ground! Hold Your Ground!. \nSons of Gondor, of Rohan, my brothers.") +print("""A day may come when the courage of men fails, +when we forsake and break all bonds of fellowship, but it is not this day. +An hour of wolves and shattered shields, +when the age of men comes crashing down, +but it is not this day!""") +print("This day we fight!") +print("By all that you hold dear on this good Earth, \nI bid you stand, \nMen of the West!") From cc39517993616d657a2031a73f5408176107949c Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 08:59:14 -0500 Subject: [PATCH 04/29] Learning Loops --- In Class Lab Activities/Loops/for_loops.py | 11 +++++++++++ Testing/test.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 In Class Lab Activities/Loops/for_loops.py diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py new file mode 100644 index 000000000..1a29d087b --- /dev/null +++ b/In Class Lab Activities/Loops/for_loops.py @@ -0,0 +1,11 @@ +# Review questions chapter 11 +"""for i in range(10): + print("Hi!")""" + + + + +# General Kenobi +for i in range (5): + print("Hello") +print("There") \ No newline at end of file diff --git a/Testing/test.py b/Testing/test.py index f301245e2..8b1378917 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -1 +1 @@ -print("Hello World!") + From 313bf202c324da6d2a801fcc15b6aaca173e10b7 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:01:19 -0500 Subject: [PATCH 05/29] Update for_loops.py --- In Class Lab Activities/Loops/for_loops.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py index 1a29d087b..9cd18cb51 100644 --- a/In Class Lab Activities/Loops/for_loops.py +++ b/In Class Lab Activities/Loops/for_loops.py @@ -1,11 +1,17 @@ # Review questions chapter 11 """for i in range(10): - print("Hi!")""" + print("Hi!") -# General Kenobi + +for i in range (5): + print("Hello") +print("There")""" + + for i in range (5): print("Hello") -print("There") \ No newline at end of file + print("There") +# General Kenobi \ No newline at end of file From 4c51d790f68cc8c99a690f5b44696d50cb447d5c Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:05:18 -0500 Subject: [PATCH 06/29] Update for_loops.py --- In Class Lab Activities/Loops/for_loops.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py index 9cd18cb51..5eeb51390 100644 --- a/In Class Lab Activities/Loops/for_loops.py +++ b/In Class Lab Activities/Loops/for_loops.py @@ -4,14 +4,22 @@ - - for i in range (5): print("Hello") -print("There")""" +print("There") + for i in range (5): print("Hello") print("There") -# General Kenobi \ No newline at end of file +# General Kenobi + + + +for i in range (10): + print(i)""" + + + + From 1fc95f1bb1614e7c0d84202d0c04ee8826eac144 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:16:18 -0500 Subject: [PATCH 07/29] Update for_loops.py --- In Class Lab Activities/Loops/for_loops.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py index 5eeb51390..096ed0395 100644 --- a/In Class Lab Activities/Loops/for_loops.py +++ b/In Class Lab Activities/Loops/for_loops.py @@ -18,8 +18,21 @@ for i in range (10): - print(i)""" + print(i) + + +for i in range (1,11): + print(i) +for i in range (10): + print(i+1) + +for i in range (2, 12, 2): + print(i)""" + + +for i in range (5): + print((i+1)*2) \ No newline at end of file From 9062b7b7b87ace070980389b22d56e43fca2e8c2 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:25:36 -0500 Subject: [PATCH 08/29] Update for_loops.py --- In Class Lab Activities/Loops/for_loops.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py index 096ed0395..a376cb3b2 100644 --- a/In Class Lab Activities/Loops/for_loops.py +++ b/In Class Lab Activities/Loops/for_loops.py @@ -31,8 +31,12 @@ for i in range (2, 12, 2): - print(i)""" + print(i) for i in range (5): - print((i+1)*2) \ No newline at end of file + print((i+1)*2) + + +for i in range (10, 0, -1): + print(i)""" \ No newline at end of file From a6821febc5ff4cbd9cd8e2ee014b02b1ef287d1c Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:56:32 -0500 Subject: [PATCH 09/29] Update for_loops.py --- In Class Lab Activities/Loops/for_loops.py | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py index a376cb3b2..79a87962d 100644 --- a/In Class Lab Activities/Loops/for_loops.py +++ b/In Class Lab Activities/Loops/for_loops.py @@ -39,4 +39,33 @@ for i in range (10, 0, -1): - print(i)""" \ No newline at end of file + print(i) + + +for i in range(3): + print("a") + for j in range(3): + print("b") + + + +a = 0 +for i in range(10): + a = a + 1 + for j in range(10): + a = a + 1 +print(a) + + +total = 0 +for i in range(1, 101): + total = total + i + print(total) + + +i=0 +while i < 10: + print(i) + i=i+1""" + + From 8d1be322d354fdb668099e4c1b8c6d7d471f4a7e Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:04:30 -0500 Subject: [PATCH 10/29] Update for_loops.py --- In Class Lab Activities/Loops/for_loops.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py index 79a87962d..b1e219f68 100644 --- a/In Class Lab Activities/Loops/for_loops.py +++ b/In Class Lab Activities/Loops/for_loops.py @@ -66,6 +66,23 @@ i=0 while i < 10: print(i) - i=i+1""" + i=i+1 + + +i = 1 +while i <= 2**32: + print(i) + i *= 2""" + + +keep_going="yes" + +while keep_going="yes" + a = input("would you like to try again?") + if a = "no" + keep_going=a + else + + From ecaea9756fcac49fe2703fa2135e45d30c8d4526 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 4 Mar 2024 11:29:27 -0500 Subject: [PATCH 11/29] Update --- Lab 04 - Camel/lab_04.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Lab 04 - Camel/lab_04.py b/Lab 04 - Camel/lab_04.py index e69de29bb..352f9c469 100644 --- a/Lab 04 - Camel/lab_04.py +++ b/Lab 04 - Camel/lab_04.py @@ -0,0 +1,24 @@ +miles=0 +thirst=0 +camel=0 +natives=-20 +canteen=3 +player=0 +# This is a comment +def main(): + print("Welcome to Camel!") + print("You have stolen a camel to make your way across the great Mobi desert.") + print("The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.") + + done=False + while not done: + print("""A. Drink from your canteen.\nB. Ahead moderate speed.\nC. Ahead full speed.\nD. Stop for the night.\nE. Status check.\nQ. Quit.""") + choice = input("What is your choice? ") + if choice.upper() == 'Q': + done=True + print("Thanks for playing!") + elif choice.upper == 'E': + print("Miles traveled:{miles}") + print("Drinks remaining:{canteen}") + print("The natives are {natives} miles away.") +main() \ No newline at end of file From a1313bd9634b053d8e623d19c0dd95a344cdf3da Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 7 Mar 2024 07:42:08 -0500 Subject: [PATCH 12/29] Lab help --- Lab 04 - Camel/lab_04.py | 79 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 7 deletions(-) diff --git a/Lab 04 - Camel/lab_04.py b/Lab 04 - Camel/lab_04.py index 352f9c469..2f5d69c61 100644 --- a/Lab 04 - Camel/lab_04.py +++ b/Lab 04 - Camel/lab_04.py @@ -1,15 +1,52 @@ -miles=0 +#Game Variables thirst=0 camel=0 natives=-20 canteen=3 player=0 -# This is a comment +DESERT_SIZE = 200 + +import random +#Game Functions +def move_natives(min_val, max_val): + global natives + natives += random.randint(min_val, max_val) +def rest_for_the_night(): + global camel + print("You've stopped for the night. Your camel lays down by your fire and is fully rested.") + camel = 0 + move_natives(7,14) +def move_player(min_val, max_val): + global player + random_val = random.randint(min_val, max_val) + player += random_val +def go_full_speed(): + global thirst, camel + move_player(10, 20) + thirst += 1 + camel += random.randint(1, 3) + move_natives(7, 14) + print(f"You have traveled {player} miles.") +def go_moderate_speed(): + global thirst, camel + move_player(5, 12) + thirst += 1 + camel += 1 + move_natives(7, 14) + print(f"You have traveled {player} miles.") +def drink_from_canteen(): + global canteen, thirst + if canteen > 0: + canteen -= 1 + thirst = 0 + else: + print("Oh No! Your canteen is empty!") + +#Main Game def main(): print("Welcome to Camel!") print("You have stolen a camel to make your way across the great Mobi desert.") print("The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.") - done=False while not done: print("""A. Drink from your canteen.\nB. Ahead moderate speed.\nC. Ahead full speed.\nD. Stop for the night.\nE. Status check.\nQ. Quit.""") @@ -17,8 +54,36 @@ def main(): if choice.upper() == 'Q': done=True print("Thanks for playing!") - elif choice.upper == 'E': - print("Miles traveled:{miles}") - print("Drinks remaining:{canteen}") - print("The natives are {natives} miles away.") + elif choice.upper() == 'E': + print(f"Miles traveled: {player}") + print(f"Drinks remaining: {canteen}") + print(f"The natives are {natives} miles away.") + elif choice.upper() == 'D': + rest_for_the_night() + elif choice.upper() == 'C': + go_full_speed() + elif choice.upper() == 'B': + go_moderate_speed() + elif choice.upper() == 'A': + drink_from_canteen() + #Game Check + if thirst>=6: + done=True + print("You've died of thirst!") + elif thirst>4: + print("You are thirst.") + if camel>=8: + done=True + print("Your camel is dead.") + if camel>=5: + print("Your camel is getting tired.") + if natives>=player: + done=True + print("The natives have caught you!") + elif(natives-player)<15: + print("The natives are getting close!") + if player>200: + done=True + print("You've made it across the desert! You won!") + main() \ No newline at end of file From 0b32e85f62a621df0b307153f8b5c80c9732149b Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 7 Mar 2024 07:45:20 -0500 Subject: [PATCH 13/29] Lab help --- Lab 04 - Camel/lab_04.py | 1 - Testing/test.py | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Lab 04 - Camel/lab_04.py b/Lab 04 - Camel/lab_04.py index 2f5d69c61..09cacc1f0 100644 --- a/Lab 04 - Camel/lab_04.py +++ b/Lab 04 - Camel/lab_04.py @@ -4,7 +4,6 @@ natives=-20 canteen=3 player=0 -DESERT_SIZE = 200 import random #Game Functions diff --git a/Testing/test.py b/Testing/test.py index 8b1378917..d55cc04d4 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -1 +1,9 @@ - +if camel > 8: + done = True + print("Your camel died of exhaustion.") +elif camel > 5: + print("Your camel is getting tired.") +if natives >= player: + print("The natives have caught you, you lost!") +elif (natives - player) < 15: + print("The natives are getting close!") \ No newline at end of file From b3e9dbcedf4dcbf6e3df18818984325d20691c94 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 7 Mar 2024 09:55:55 -0500 Subject: [PATCH 14/29] Update lab_04.py It's finally done! --- Lab 04 - Camel/lab_04.py | 107 ++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 36 deletions(-) diff --git a/Lab 04 - Camel/lab_04.py b/Lab 04 - Camel/lab_04.py index 09cacc1f0..94d30b21e 100644 --- a/Lab 04 - Camel/lab_04.py +++ b/Lab 04 - Camel/lab_04.py @@ -1,24 +1,42 @@ -#Game Variables -thirst=0 -camel=0 -natives=-20 -canteen=3 -player=0 - import random -#Game Functions + +# Game Variables +thirst = 0 +camel = 0 +natives = -20 +canteen = 3 +player = 0 + + +# Game Functions +def find_oasis(): + global thirst, camel, canteen + for i in range(1): + if random.randrange(20) == 19: + print("You have found an oasis! You refill your canteen and are able to rest alongside your camel") + thirst = 0 + camel = 0 + canteen = 3 + + def move_natives(min_val, max_val): global natives natives += random.randint(min_val, max_val) + + def rest_for_the_night(): global camel print("You've stopped for the night. Your camel lays down by your fire and is fully rested.") camel = 0 - move_natives(7,14) + move_natives(7, 14) + + def move_player(min_val, max_val): global player random_val = random.randint(min_val, max_val) player += random_val + + def go_full_speed(): global thirst, camel move_player(10, 20) @@ -26,6 +44,9 @@ def go_full_speed(): camel += random.randint(1, 3) move_natives(7, 14) print(f"You have traveled {player} miles.") + find_oasis() + + def go_moderate_speed(): global thirst, camel move_player(5, 12) @@ -33,6 +54,9 @@ def go_moderate_speed(): camel += 1 move_natives(7, 14) print(f"You have traveled {player} miles.") + find_oasis() + + def drink_from_canteen(): global canteen, thirst if canteen > 0: @@ -41,22 +65,29 @@ def drink_from_canteen(): else: print("Oh No! Your canteen is empty!") -#Main Game + +# Main Game def main(): print("Welcome to Camel!") print("You have stolen a camel to make your way across the great Mobi desert.") - print("The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.") - done=False + print("The natives want their camel back and are chasing you down!") + print("Survive your desert trek and out run the natives.") + done = False while not done: - print("""A. Drink from your canteen.\nB. Ahead moderate speed.\nC. Ahead full speed.\nD. Stop for the night.\nE. Status check.\nQ. Quit.""") + print("A. Drink from your canteen.") + print("B. Ahead moderate speed") + print("C. Ahead full speed.") + print("D. Stop for the night.") + print("E. Status check.") + print("Q. Quit.") choice = input("What is your choice? ") if choice.upper() == 'Q': - done=True + done = True print("Thanks for playing!") elif choice.upper() == 'E': print(f"Miles traveled: {player}") print(f"Drinks remaining: {canteen}") - print(f"The natives are {natives} miles away.") + print(f"The natives are {player - natives} miles away.") elif choice.upper() == 'D': rest_for_the_night() elif choice.upper() == 'C': @@ -65,24 +96,28 @@ def main(): go_moderate_speed() elif choice.upper() == 'A': drink_from_canteen() - #Game Check - if thirst>=6: - done=True - print("You've died of thirst!") - elif thirst>4: - print("You are thirst.") - if camel>=8: - done=True - print("Your camel is dead.") - if camel>=5: - print("Your camel is getting tired.") - if natives>=player: - done=True - print("The natives have caught you!") - elif(natives-player)<15: - print("The natives are getting close!") - if player>200: - done=True - print("You've made it across the desert! You won!") - -main() \ No newline at end of file + # Game Check + if thirst >= 6: + done = True + print("You've died of thirst!") + elif thirst > 4: + print("You are thirsty.") + + if camel >= 8: + done = True + print("Your camel is dead.") + elif camel >= 5: + print("Your camel is getting tired.") + + if natives >= player: + done = True + print("The natives have caught you!") + elif (player - natives) < 15: + print("The natives are getting close!") + + if player >= 200: + done = True + print("You've made it across the desert! You won!") + + +main() From e8c92e8925f198ea309d78bd72da4a9d3c0d1251 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 7 Mar 2024 09:55:55 -0500 Subject: [PATCH 15/29] Update lab_04.py It's finally done! --- Lab 04 - Camel/lab_04.py | 107 +++++++++++++++++++++++------------ Lab 05 - Loopy Lab/lab_05.py | 106 ++++++++++++++++++++++++++++++++++ Testing/test.py | 9 --- 3 files changed, 177 insertions(+), 45 deletions(-) diff --git a/Lab 04 - Camel/lab_04.py b/Lab 04 - Camel/lab_04.py index 09cacc1f0..94d30b21e 100644 --- a/Lab 04 - Camel/lab_04.py +++ b/Lab 04 - Camel/lab_04.py @@ -1,24 +1,42 @@ -#Game Variables -thirst=0 -camel=0 -natives=-20 -canteen=3 -player=0 - import random -#Game Functions + +# Game Variables +thirst = 0 +camel = 0 +natives = -20 +canteen = 3 +player = 0 + + +# Game Functions +def find_oasis(): + global thirst, camel, canteen + for i in range(1): + if random.randrange(20) == 19: + print("You have found an oasis! You refill your canteen and are able to rest alongside your camel") + thirst = 0 + camel = 0 + canteen = 3 + + def move_natives(min_val, max_val): global natives natives += random.randint(min_val, max_val) + + def rest_for_the_night(): global camel print("You've stopped for the night. Your camel lays down by your fire and is fully rested.") camel = 0 - move_natives(7,14) + move_natives(7, 14) + + def move_player(min_val, max_val): global player random_val = random.randint(min_val, max_val) player += random_val + + def go_full_speed(): global thirst, camel move_player(10, 20) @@ -26,6 +44,9 @@ def go_full_speed(): camel += random.randint(1, 3) move_natives(7, 14) print(f"You have traveled {player} miles.") + find_oasis() + + def go_moderate_speed(): global thirst, camel move_player(5, 12) @@ -33,6 +54,9 @@ def go_moderate_speed(): camel += 1 move_natives(7, 14) print(f"You have traveled {player} miles.") + find_oasis() + + def drink_from_canteen(): global canteen, thirst if canteen > 0: @@ -41,22 +65,29 @@ def drink_from_canteen(): else: print("Oh No! Your canteen is empty!") -#Main Game + +# Main Game def main(): print("Welcome to Camel!") print("You have stolen a camel to make your way across the great Mobi desert.") - print("The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.") - done=False + print("The natives want their camel back and are chasing you down!") + print("Survive your desert trek and out run the natives.") + done = False while not done: - print("""A. Drink from your canteen.\nB. Ahead moderate speed.\nC. Ahead full speed.\nD. Stop for the night.\nE. Status check.\nQ. Quit.""") + print("A. Drink from your canteen.") + print("B. Ahead moderate speed") + print("C. Ahead full speed.") + print("D. Stop for the night.") + print("E. Status check.") + print("Q. Quit.") choice = input("What is your choice? ") if choice.upper() == 'Q': - done=True + done = True print("Thanks for playing!") elif choice.upper() == 'E': print(f"Miles traveled: {player}") print(f"Drinks remaining: {canteen}") - print(f"The natives are {natives} miles away.") + print(f"The natives are {player - natives} miles away.") elif choice.upper() == 'D': rest_for_the_night() elif choice.upper() == 'C': @@ -65,24 +96,28 @@ def main(): go_moderate_speed() elif choice.upper() == 'A': drink_from_canteen() - #Game Check - if thirst>=6: - done=True - print("You've died of thirst!") - elif thirst>4: - print("You are thirst.") - if camel>=8: - done=True - print("Your camel is dead.") - if camel>=5: - print("Your camel is getting tired.") - if natives>=player: - done=True - print("The natives have caught you!") - elif(natives-player)<15: - print("The natives are getting close!") - if player>200: - done=True - print("You've made it across the desert! You won!") - -main() \ No newline at end of file + # Game Check + if thirst >= 6: + done = True + print("You've died of thirst!") + elif thirst > 4: + print("You are thirsty.") + + if camel >= 8: + done = True + print("Your camel is dead.") + elif camel >= 5: + print("Your camel is getting tired.") + + if natives >= player: + done = True + print("The natives have caught you!") + elif (player - natives) < 15: + print("The natives are getting close!") + + if player >= 200: + done = True + print("You've made it across the desert! You won!") + + +main() diff --git a/Lab 05 - Loopy Lab/lab_05.py b/Lab 05 - Loopy Lab/lab_05.py index e69de29bb..5bd80afad 100644 --- a/Lab 05 - Loopy Lab/lab_05.py +++ b/Lab 05 - Loopy Lab/lab_05.py @@ -0,0 +1,106 @@ +import arcade + + +def draw_section_outlines(): + # Draw squares on bottom + arcade.draw_rectangle_outline(150, 150, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(450, 150, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(750, 150, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(1050, 150, 300, 300, arcade.color.BLACK) + + # Draw squares on top + arcade.draw_rectangle_outline(150, 450, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(450, 450, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(750, 450, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(1050, 450, 300, 300, arcade.color.BLACK) + + +def draw_section_1(): + for row in range(30): + for column in range(30): + x = column * 10 + 5 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + + +def draw_section_2(): + # Below, replace "pass" with your code for the loop. + # Use the modulus operator and an if statement to select the color + # Don't loop from 30 to 60 to shift everything over, just add 300 to x. + for row in range(30): + for column in range(30): + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' + if column % 2 == 0: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + elif column % 2 == 1: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.BLACK) + + +def draw_section_3(): + # Use the modulus operator and an if/else statement to select the color. + # Don't use multiple 'if' statements. + for row in range(30): + for column in range(30): + x = column * 10 + 5 + 600 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' + if row % 2 == 0: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + elif row % 2 == 1: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.BLACK) + + +def draw_section_4(): + # Use the modulus operator and just one 'if' statement to select the color. + for row in range(30): + for column in range(30): + color = arcade.color.BLACK + x = column * 10 + 5 + 900 + y = row * 10 + 5 + if row % 2 == 0 and column % 2 == 0: + color = arcade.color.WHITE + arcade.draw_rectangle_filled(x, y, 5, 5, color) + +def draw_section_5(): + # Do NOT use 'if' statements to complete 5-8. Manipulate the loops instead. + pass + + +def draw_section_6(): + pass + + +def draw_section_7(): + pass + + +def draw_section_8(): + pass + + +def main(): + # Create a window + arcade.open_window(1200, 600, "Lab 05 - Loopy Lab") + arcade.set_background_color(arcade.color.AIR_FORCE_BLUE) + + arcade.start_render() + + # Draw the outlines for the sections + draw_section_outlines() + + # Draw the sections + draw_section_1() + draw_section_2() + draw_section_3() + draw_section_4() + draw_section_5() + draw_section_6() + draw_section_7() + draw_section_8() + + arcade.finish_render() + + arcade.run() + + +main() \ No newline at end of file diff --git a/Testing/test.py b/Testing/test.py index d55cc04d4..e69de29bb 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -1,9 +0,0 @@ -if camel > 8: - done = True - print("Your camel died of exhaustion.") -elif camel > 5: - print("Your camel is getting tired.") -if natives >= player: - print("The natives have caught you, you lost!") -elif (natives - player) < 15: - print("The natives are getting close!") \ No newline at end of file From 2e405269813dc07953120b346f1b56f6fd9bdb35 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 14 Mar 2024 09:55:47 -0400 Subject: [PATCH 16/29] Update lab_04.py It's finally done! --- Lab 06 - Text Adventure/lab_06.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Lab 06 - Text Adventure/lab_06.py b/Lab 06 - Text Adventure/lab_06.py index e69de29bb..61019076b 100644 --- a/Lab 06 - Text Adventure/lab_06.py +++ b/Lab 06 - Text Adventure/lab_06.py @@ -0,0 +1,16 @@ +class Room: + """ This is a class that defines Rooms.""" + def __init__(self): + """ Set up Room attributes. """ + self.description = "" + self.north = 0 + self.south = 0 + self.east = 0 + self.west = 0 + + +def main(): + + """Main program function.""" + my_list = [] + room = Room() \ No newline at end of file From 8c6414c7a368da88309892e3ffbfeaf6ec20a868 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:52:31 -0400 Subject: [PATCH 17/29] Update lab_04.py It's finally done! --- Testing/test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Testing/test.py b/Testing/test.py index e69de29bb..0f8eeb744 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -0,0 +1,6 @@ +class Cat(): + def __init__(self): + self.age = 0 + self.name = "" + self.weight = 0 + print("New dog!") \ No newline at end of file From e561a6b3aa6df56f91fd1ef23263da6cce13772c Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:55:24 -0400 Subject: [PATCH 18/29] Update lab_04.py It's finally done! --- In Class Lab Activities/class_methods.py | 54 ++++++++++++++++++++++++ Testing/test.py | 53 +++++++++++++++++++++-- 2 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 In Class Lab Activities/class_methods.py diff --git a/In Class Lab Activities/class_methods.py b/In Class Lab Activities/class_methods.py new file mode 100644 index 000000000..5e5406cb8 --- /dev/null +++ b/In Class Lab Activities/class_methods.py @@ -0,0 +1,54 @@ +"""class Cat: + def __init__(self): + self.color = "" + self.name = "" + self.weight = 0 + + def meow(self): + print("Meow!") + + +my_cat = Cat() +my_cat.color = "Brown" +my_cat.name = "Tank" +my_cat.weight = 10 + +print("My cats name is", my_cat.name) +my_cat.meow() + +class Monster: + def __init__(self): + self.name = "" + self.health = 0 + + def decrease_health(self, amount): + self.health -= amount + if 0 >= self.health: + print("The monster is dead.") + + +monster1 = Monster() +monster1.name = "Omnom" +monster1.health = 30 + +print("The monster is", monster1.name) +monster1.decrease_health(31) + +class Monster: + def __init__(self, health, name): + self.name = name + self.health = health + + def decrease_health(self, amount): + self.health -= amount + if 0 >= self.health: + print("The monster is dead.") + +class Star: + def __init__(self): + print("A star is born!") + +star1 = Star() +star2 = Star() +star3 = Star()""" + diff --git a/Testing/test.py b/Testing/test.py index 0f8eeb744..0b11bd00e 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -1,6 +1,53 @@ -class Cat(): +"""class Cat: def __init__(self): - self.age = 0 + self.color = "" self.name = "" self.weight = 0 - print("New dog!") \ No newline at end of file + + def meow(self): + print("Meow!") + + +my_cat = Cat() +my_cat.color = "Brown" +my_cat.name = "Tank" +my_cat.weight = 10 + +print("My cats name is", my_cat.name) +my_cat.meow() + +class Monster: + def __init__(self): + self.name = "" + self.health = 0 + + def decrease_health(self, amount): + self.health -= amount + if 0 >= self.health: + print("The monster is dead.") + + +monster1 = Monster() +monster1.name = "Omnom" +monster1.health = 30 + +print("The monster is", monster1.name) +monster1.decrease_health(31) + +class Monster: + def __init__(self, health, name): + self.name = name + self.health = health + + def decrease_health(self, amount): + self.health -= amount + if 0 >= self.health: + print("The monster is dead.") + +class Star: + def __init__(self): + print("A star is born!") + +star1 = Star() +star2 = Star() +star3 = Star()""" \ No newline at end of file From 2c34b639047b400fcd2bc47ad627624881be027c Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:39:00 -0400 Subject: [PATCH 19/29] Update lab_04.py It's finally done! --- Lab 05 - Loopy Lab/lab_05.py | 30 ++++++++++++++----- Testing/test.py | 56 ++++-------------------------------- 2 files changed, 29 insertions(+), 57 deletions(-) diff --git a/Lab 05 - Loopy Lab/lab_05.py b/Lab 05 - Loopy Lab/lab_05.py index 5bd80afad..b70f0a262 100644 --- a/Lab 05 - Loopy Lab/lab_05.py +++ b/Lab 05 - Loopy Lab/lab_05.py @@ -29,7 +29,7 @@ def draw_section_2(): # Don't loop from 30 to 60 to shift everything over, just add 300 to x. for row in range(30): for column in range(30): - x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' if column % 2 == 0: arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) @@ -61,21 +61,37 @@ def draw_section_4(): color = arcade.color.WHITE arcade.draw_rectangle_filled(x, y, 5, 5, color) + def draw_section_5(): - # Do NOT use 'if' statements to complete 5-8. Manipulate the loops instead. - pass + for column in range(30): + for row in range(column + 1): + x = column * 10 + 5 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def draw_section_6(): - pass + for row in range(30): + for column in range(30 - row): + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def draw_section_7(): - pass + for row in range(30): + for column in range(row + 1): + x = column * 10 + 5 + 600 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def draw_section_8(): - pass + for row in range(30): + for column in range(row + 1): + x = 290 - column * 10 + 5 + 900 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def main(): @@ -103,4 +119,4 @@ def main(): arcade.run() -main() \ No newline at end of file +main() diff --git a/Testing/test.py b/Testing/test.py index 0b11bd00e..dd087f07e 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -1,53 +1,9 @@ -"""class Cat: - def __init__(self): - self.color = "" - self.name = "" - self.weight = 0 +for row in range(10): - def meow(self): - print("Meow!") + for j in range(row): + print(" ", end=" ") + for j in range(10 - row): + print(j, end=" ") -my_cat = Cat() -my_cat.color = "Brown" -my_cat.name = "Tank" -my_cat.weight = 10 - -print("My cats name is", my_cat.name) -my_cat.meow() - -class Monster: - def __init__(self): - self.name = "" - self.health = 0 - - def decrease_health(self, amount): - self.health -= amount - if 0 >= self.health: - print("The monster is dead.") - - -monster1 = Monster() -monster1.name = "Omnom" -monster1.health = 30 - -print("The monster is", monster1.name) -monster1.decrease_health(31) - -class Monster: - def __init__(self, health, name): - self.name = name - self.health = health - - def decrease_health(self, amount): - self.health -= amount - if 0 >= self.health: - print("The monster is dead.") - -class Star: - def __init__(self): - print("A star is born!") - -star1 = Star() -star2 = Star() -star3 = Star()""" \ No newline at end of file + print() \ No newline at end of file From 352b055c18cc4480e4ed1dc99e5498f0a60154a2 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:39:00 -0400 Subject: [PATCH 20/29] We're getting there --- Lab 05 - Loopy Lab/lab_05.py | 30 ++++++++++++++----- Testing/test.py | 56 ++++-------------------------------- 2 files changed, 29 insertions(+), 57 deletions(-) diff --git a/Lab 05 - Loopy Lab/lab_05.py b/Lab 05 - Loopy Lab/lab_05.py index 5bd80afad..b70f0a262 100644 --- a/Lab 05 - Loopy Lab/lab_05.py +++ b/Lab 05 - Loopy Lab/lab_05.py @@ -29,7 +29,7 @@ def draw_section_2(): # Don't loop from 30 to 60 to shift everything over, just add 300 to x. for row in range(30): for column in range(30): - x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' if column % 2 == 0: arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) @@ -61,21 +61,37 @@ def draw_section_4(): color = arcade.color.WHITE arcade.draw_rectangle_filled(x, y, 5, 5, color) + def draw_section_5(): - # Do NOT use 'if' statements to complete 5-8. Manipulate the loops instead. - pass + for column in range(30): + for row in range(column + 1): + x = column * 10 + 5 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def draw_section_6(): - pass + for row in range(30): + for column in range(30 - row): + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def draw_section_7(): - pass + for row in range(30): + for column in range(row + 1): + x = column * 10 + 5 + 600 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def draw_section_8(): - pass + for row in range(30): + for column in range(row + 1): + x = 290 - column * 10 + 5 + 900 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) def main(): @@ -103,4 +119,4 @@ def main(): arcade.run() -main() \ No newline at end of file +main() diff --git a/Testing/test.py b/Testing/test.py index 0b11bd00e..dd087f07e 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -1,53 +1,9 @@ -"""class Cat: - def __init__(self): - self.color = "" - self.name = "" - self.weight = 0 +for row in range(10): - def meow(self): - print("Meow!") + for j in range(row): + print(" ", end=" ") + for j in range(10 - row): + print(j, end=" ") -my_cat = Cat() -my_cat.color = "Brown" -my_cat.name = "Tank" -my_cat.weight = 10 - -print("My cats name is", my_cat.name) -my_cat.meow() - -class Monster: - def __init__(self): - self.name = "" - self.health = 0 - - def decrease_health(self, amount): - self.health -= amount - if 0 >= self.health: - print("The monster is dead.") - - -monster1 = Monster() -monster1.name = "Omnom" -monster1.health = 30 - -print("The monster is", monster1.name) -monster1.decrease_health(31) - -class Monster: - def __init__(self, health, name): - self.name = name - self.health = health - - def decrease_health(self, amount): - self.health -= amount - if 0 >= self.health: - print("The monster is dead.") - -class Star: - def __init__(self): - print("A star is born!") - -star1 = Star() -star2 = Star() -star3 = Star()""" \ No newline at end of file + print() \ No newline at end of file From 9622edc4234fa194f07ce053191c40c59a6021c5 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Tue, 23 Apr 2024 09:54:55 -0400 Subject: [PATCH 21/29] We're getting there --- In Class Lab Activities/Array backed grids.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 In Class Lab Activities/Array backed grids.py diff --git a/In Class Lab Activities/Array backed grids.py b/In Class Lab Activities/Array backed grids.py new file mode 100644 index 000000000..1d383f630 --- /dev/null +++ b/In Class Lab Activities/Array backed grids.py @@ -0,0 +1,76 @@ +import arcade + +width = 20 +height = 20 +margin = 5 +ROW_COUNT=10 +COLUMN_COUNT=10 +SCREEN_WIDTH = width * COLUMN_COUNT + margin * (COLUMN_COUNT + 1) +SCREEN_HEIGHT = width * ROW_COUNT + margin * (ROW_COUNT + 1) + + +class MyGame(arcade.Window): + """ + Main application class. + """ + + def __init__(self, width, height): + super().__init__(width, height) + # --- Create grid of numbers + # Create an empty list + self.grid = [] + # Loop for each row + for row in range(ROW_COUNT): + # For each row, create a list that will + # represent an entire row + self.grid.append([]) + # Loop for each column + for column in range(COLUMN_COUNT): + # Add a the number zero to the current row + self.grid[row].append(0) + + arcade.set_background_color(arcade.color.BLACK) + + + def on_draw(self): + """ + Render the screen. + """ + + arcade.start_render() + for row in range(ROW_COUNT): + for column in range(COLUMN_COUNT): + color = arcade.color.WHITE + if self.grid[row][column] == 1: + color = arcade.color.GREEN + x = (margin + width) * column + margin + width // 2 + y = (margin + width) * row + margin + width // 2 + arcade.draw_rectangle_filled(x, y, width, height, color) + + + + + def on_mouse_press(self, x, y, button, key_modifiers): + """ + Called when the user presses a mouse button. + """ + column = x // (width + margin) + row = y // (height+margin) + + print(f"Click coordinates: ( {x}, {y}. Grid Coordinates: ({row}, {column})") + + if row < ROW_COUNT and column < COLUMN_COUNT: + + if self.grid[row][column] == 0: + self.grid[row][column] = 1 + else: + self.grid[row][column] = 0 + +def main(): + + window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT) + arcade.run() + + +if __name__ == "__main__": + main() \ No newline at end of file From 38e1c2fd1e6ddb17c6c143bd9059da9126d352eb Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 2 May 2024 09:59:29 -0400 Subject: [PATCH 22/29] Final Project Work --- In Class Lab Activities/Array backed grids.py | 14 +- Lab 12 - Final Lab/final lab.py | 138 ++++++++++++++++++ Lab 12 - Final Lab/part_12.py | 0 requirements.txt | 4 +- 4 files changed, 146 insertions(+), 10 deletions(-) create mode 100644 Lab 12 - Final Lab/final lab.py delete mode 100644 Lab 12 - Final Lab/part_12.py diff --git a/In Class Lab Activities/Array backed grids.py b/In Class Lab Activities/Array backed grids.py index 1d383f630..f82b1de8f 100644 --- a/In Class Lab Activities/Array backed grids.py +++ b/In Class Lab Activities/Array backed grids.py @@ -3,8 +3,8 @@ width = 20 height = 20 margin = 5 -ROW_COUNT=10 -COLUMN_COUNT=10 +ROW_COUNT = 10 +COLUMN_COUNT = 10 SCREEN_WIDTH = width * COLUMN_COUNT + margin * (COLUMN_COUNT + 1) SCREEN_HEIGHT = width * ROW_COUNT + margin * (ROW_COUNT + 1) @@ -31,7 +31,6 @@ def __init__(self, width, height): arcade.set_background_color(arcade.color.BLACK) - def on_draw(self): """ Render the screen. @@ -47,15 +46,12 @@ def on_draw(self): y = (margin + width) * row + margin + width // 2 arcade.draw_rectangle_filled(x, y, width, height, color) - - - def on_mouse_press(self, x, y, button, key_modifiers): """ Called when the user presses a mouse button. """ column = x // (width + margin) - row = y // (height+margin) + row = y // (height + margin) print(f"Click coordinates: ( {x}, {y}. Grid Coordinates: ({row}, {column})") @@ -66,11 +62,11 @@ def on_mouse_press(self, x, y, button, key_modifiers): else: self.grid[row][column] = 0 -def main(): +def main(): window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.run() if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/Lab 12 - Final Lab/final lab.py b/Lab 12 - Final Lab/final lab.py new file mode 100644 index 000000000..86760cd7a --- /dev/null +++ b/Lab 12 - Final Lab/final lab.py @@ -0,0 +1,138 @@ +""" +Example of Pymunk Physics Engine Platformer +""" +""" +Example of Pymunk Physics Engine Platformer +""" + +import math + +from typing import Optional + +import arcade + + + +SCREEN_TITLE = "PyMunk Platformer" + + + +# How big are our image tiles? + +SPRITE_IMAGE_SIZE = 128 + + + +# Scale sprites up or down + +SPRITE_SCALING_PLAYER = 0.5 + +SPRITE_SCALING_TILES = 0.5 + + + +# Scaled sprite size for tiles + +SPRITE_SIZE = int(SPRITE_IMAGE_SIZE * SPRITE_SCALING_PLAYER) + + + +# Size of grid to show on screen, in number of tiles + +SCREEN_GRID_WIDTH = 25 + +SCREEN_GRID_HEIGHT = 15 + + + +# Size of screen to show, in pixels + +SCREEN_WIDTH = SPRITE_SIZE * SCREEN_GRID_WIDTH + +SCREEN_HEIGHT = SPRITE_SIZE * SCREEN_GRID_HEIGHT + + + +class GameWindow(arcade.Window): + """ Main Window """ + + def __init__(self, width, height, title): + """ Create the variables """ + + # Init the parent class + super().__init__(width, height, title) + + # Player sprite + self.player_sprite: Optional[arcade.Sprite] = None + + # Sprite lists we need + self.player_list: Optional[arcade.SpriteList] = None + self.wall_list: Optional[arcade.SpriteList] = None + self.bullet_list: Optional[arcade.SpriteList] = None + self.item_list: Optional[arcade.SpriteList] = None + + # Track the current state of what key is pressed + self.left_pressed: bool = False + self.right_pressed: bool = False + + # Set background color + arcade.set_background_color(arcade.color.AMAZON) + + def setup(self): + """ Set up everything with the game """ + + # Create the sprite lists + self.player_list = arcade.SpriteList() + self.bullet_list = arcade.SpriteList() + + # Map name + map_name = ":resources:/tiled_maps/pymunk_test_map.json" + + # Load in TileMap + tile_map = arcade.load_tilemap(map_name, SPRITE_SCALING_TILES) + + # Pull the sprite layers out of the tile map + self.wall_list = tile_map.sprite_lists["Platforms"] + self.item_list = tile_map.sprite_lists["Dynamic Items"] + + # Create player sprite + self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", + SPRITE_SCALING_PLAYER) + # Set player location + grid_x = 1 + grid_y = 1 + self.player_sprite.center_x = SPRITE_SIZE * grid_x + SPRITE_SIZE / 2 + self.player_sprite.center_y = SPRITE_SIZE * grid_y + SPRITE_SIZE / 2 + # Add to player sprite list + self.player_list.append(self.player_sprite) + + def on_key_press(self, key, modifiers): + """Called whenever a key is pressed. """ + pass + + def on_key_release(self, key, modifiers): + """Called when the user releases a key. """ + pass + + def on_update(self, delta_time): + """ Movement and game logic """ + pass + + def on_draw(self): + """ Draw everything """ + self.clear() + self.wall_list.draw() + self.bullet_list.draw() + self.item_list.draw() + self.player_list.draw() + + +def main(): + """ Main function """ + window = GameWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) + window.setup() + arcade.run() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/Lab 12 - Final Lab/part_12.py b/Lab 12 - Final Lab/part_12.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/requirements.txt b/requirements.txt index ab9354ea0..ea1018859 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ -arcade +arcade~=3.0.0.dev25 + +tcod~=16.2.2 \ No newline at end of file From 25f9e527c1ef12e2880dd7aaf9390d52011109fe Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Tue, 7 May 2024 09:54:46 -0400 Subject: [PATCH 23/29] Lab 10 --- Lab 10 - Spell Check/lab_10.py | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Lab 10 - Spell Check/lab_10.py b/Lab 10 - Spell Check/lab_10.py index e69de29bb..feba08ebf 100644 --- a/Lab 10 - Spell Check/lab_10.py +++ b/Lab 10 - Spell Check/lab_10.py @@ -0,0 +1,54 @@ +import re + + +# This function takes in a line of text and returns +# a list of words in the line. +def split_line(line): + return re.findall('[A-Za-z]+(?:\'[A-Za-z]+)?', line) + + +def main(): + """ Read in lines from a file """ + + # Open the file for reading, and store a pointer to it in the new + # variable "file" + my_file = open("dictionary.txt") + + # Create an empty list to store our names + dictionary_list = [] + + # Loop through each line in the file like a list + for line in my_file: + # Remove any line feed, carriage returns or spaces at the end of the line + line = line.strip() + + # Add the name to the list + dictionary_list.append(line) + + my_file.close() + + my_file = open("AliceInWonderLand200.txt") + + for line in my_file: + word_list = split_line(line) + for word in word_list: + # --- Linear search + key = word.upper() + + # Start at the beginning of the list + current_list_position = 0 + + # Loop until you reach the end of the list, or the value at the + # current position is equal to the key + while current_list_position < len(word_list) and word_list[current_list_position] != key: + # Advance to the next item in the list + current_list_position += 1 + + if current_list_position < len(word_list): + print(key, "is at position", current_list_position) + + my_file.close() + + + +main() From 4686c072c772b906031fbcfbc6b852e90a15ad27 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 9 May 2024 09:34:33 -0400 Subject: [PATCH 24/29] Lab 10 final --- Lab 10 - Spell Check/lab_10.py | 43 ++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/Lab 10 - Spell Check/lab_10.py b/Lab 10 - Spell Check/lab_10.py index feba08ebf..aadef910e 100644 --- a/Lab 10 - Spell Check/lab_10.py +++ b/Lab 10 - Spell Check/lab_10.py @@ -28,7 +28,7 @@ def main(): my_file.close() my_file = open("AliceInWonderLand200.txt") - + print("---Linear Search---") for line in my_file: word_list = split_line(line) for word in word_list: @@ -40,15 +40,50 @@ def main(): # Loop until you reach the end of the list, or the value at the # current position is equal to the key - while current_list_position < len(word_list) and word_list[current_list_position] != key: + while current_list_position < len(dictionary_list) and dictionary_list[current_list_position] != key: # Advance to the next item in the list current_list_position += 1 - if current_list_position < len(word_list): - print(key, "is at position", current_list_position) + line_number = current_list_position + if current_list_position < len(dictionary_list): + print(end="") + else: + print("Possible misspelled word", key, "on line", line_number) + print("---Binary Search---") my_file.close() + my_file = open("AliceInWonderLand200.txt") + for line in my_file: + word_list = split_line(line) + for word in word_list: + # --- Binary search + key = word.upper() + lower_bound = 0 + upper_bound = len(dictionary_list) - 1 + found = False + + # Loop until we find the item, or our upper/lower bounds meet + while lower_bound <= upper_bound and not found: + + # Find the middle position + middle_pos = (lower_bound + upper_bound) // 2 + + # Figure out if we: + # move up the lower bound, or + # move down the upper bound, or + # we found what we are looking for + if dictionary_list[middle_pos] < key: + lower_bound = middle_pos + 1 + elif dictionary_list[middle_pos] > key: + upper_bound = middle_pos - 1 + else: + found = True + + if found: + print(end="") + else: + print("Possible misspelled word", key, "on line", line_number) main() From 8e099da5cab9bc12c8552b518ab87f3d2bb87bae Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 16 May 2024 18:17:32 -0400 Subject: [PATCH 25/29] Update final lab.py --- Lab 12 - Final Lab/final lab.py | 376 ++++++++++++++++++++++++-------- 1 file changed, 291 insertions(+), 85 deletions(-) diff --git a/Lab 12 - Final Lab/final lab.py b/Lab 12 - Final Lab/final lab.py index 86760cd7a..0642a2ea3 100644 --- a/Lab 12 - Final Lab/final lab.py +++ b/Lab 12 - Final Lab/final lab.py @@ -1,138 +1,344 @@ -""" -Example of Pymunk Physics Engine Platformer -""" -""" -Example of Pymunk Physics Engine Platformer -""" +import random -import math -from typing import Optional +# Game Functions +def intro(): + # Starts the game + print( + "You are part of an elite counter terrorism task force, responsible for bringing down some of the most " + "dangerous people in the world.") + print("For weeks now, you have been tracking an unidentified target.") + print("All you know is that whoever this individual is, dozens of terrorist attacks can be traced back to them.") + print( + "For a moment you finally had them cornered. However, right before your team could apprehend them, " + "the got away.") + print("You followed them into a hidden underground bunker. You've seen something like this before.") + print("There is a locked door on the far end of this dark room.") -import arcade + input("Press any button to continue") + print("") + print("A prerecorded voice begins to fill the room.") + print("Dear Failed Agent,") + print("You may have tracked me here, but you will never catch me now. ") + print("I wish you the best of luck with your failure. ") + print("That's when you notice a lock on the dor with three numbers. " + "He may have escaped but he doesn't have to get away. " + "The clues to open it could be in this room.") + print("") + print("You examine the room and see:") -SCREEN_TITLE = "PyMunk Platformer" +# Function which builds a menu which will be called later +def menu(list, questions): + # Function which builds a menu which will be called later + for item in list: + print(list.index(item), item) + result = input(questions) -# How big are our image tiles? + try: -SPRITE_IMAGE_SIZE = 128 + result = int(result) + except: + print("Selection must be a whole number between 0-9") -# Scale sprites up or down + return result -SPRITE_SCALING_PLAYER = 0.5 -SPRITE_SCALING_TILES = 0.5 +def door(code): + # Wound up following a tutorial and using try and break to simplify the overall + # code https://www.geeksforgeeks.org/python-try-except/ and https://www.geeksforgeeks.org/python-try-except/. + # This helped solve the issue of the game not ending. Used return instead of true, so it was easier to send the + # loop back to the caller code + # https://realpython.com/python-return-statement/#:~:text=You%20can%20use%20the%20return,further%20computation%20in%20your%20programs. + print("You walk to the door. The rotary padlock contains three digits. You enter a code") + while True: + try: -# Scaled sprite size for tiles + option1 = int(input("Digit one: ")) -SPRITE_SIZE = int(SPRITE_IMAGE_SIZE * SPRITE_SCALING_PLAYER) + break + except: + print("Digit one must be a whole number between 0-9:") -# Size of grid to show on screen, in number of tiles + while True: -SCREEN_GRID_WIDTH = 25 + try: -SCREEN_GRID_HEIGHT = 15 + option2 = int(input("Digit two: ")) + break + except: -# Size of screen to show, in pixels + print("Digit two must be a whole number between 0-9:") -SCREEN_WIDTH = SPRITE_SIZE * SCREEN_GRID_WIDTH + while True: -SCREEN_HEIGHT = SPRITE_SIZE * SCREEN_GRID_HEIGHT + try: + option3 = int(input("Digit three: ")) + break -class GameWindow(arcade.Window): - """ Main Window """ + except: - def __init__(self, width, height, title): - """ Create the variables """ + print("Digit three must be a whole number between 0-9:") - # Init the parent class - super().__init__(width, height, title) + chosenCode = int(str(option1) + str(option2) + str(option3)) - # Player sprite - self.player_sprite: Optional[arcade.Sprite] = None + print("") - # Sprite lists we need - self.player_list: Optional[arcade.SpriteList] = None - self.wall_list: Optional[arcade.SpriteList] = None - self.bullet_list: Optional[arcade.SpriteList] = None - self.item_list: Optional[arcade.SpriteList] = None + if chosenCode == code: - # Track the current state of what key is pressed - self.left_pressed: bool = False - self.right_pressed: bool = False + print("As the door clicks open you see him cowering in the corner. You take out your cuffs, a smile" + "spreading across your face as your team moves in. The good guys won today.") - # Set background color - arcade.set_background_color(arcade.color.AMAZON) + return 1 - def setup(self): - """ Set up everything with the game """ + else: - # Create the sprite lists - self.player_list = arcade.SpriteList() - self.bullet_list = arcade.SpriteList() + print("You jiggle the padlock, but to no avail. The code is incorrect.") - # Map name - map_name = ":resources:/tiled_maps/pymunk_test_map.json" + return 0 - # Load in TileMap - tile_map = arcade.load_tilemap(map_name, SPRITE_SCALING_TILES) - # Pull the sprite layers out of the tile map - self.wall_list = tile_map.sprite_lists["Platforms"] - self.item_list = tile_map.sprite_lists["Dynamic Items"] +def window(choice, codeLocation, codeValue): + print("") + print("You look at the window. It's dark, and damp. " + "Mold grows along the edges and you cannot see through its musty panes.") - # Create player sprite - self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", - SPRITE_SCALING_PLAYER) - # Set player location - grid_x = 1 - grid_y = 1 - self.player_sprite.center_x = SPRITE_SIZE * grid_x + SPRITE_SIZE / 2 - self.player_sprite.center_y = SPRITE_SIZE * grid_y + SPRITE_SIZE / 2 - # Add to player sprite list - self.player_list.append(self.player_sprite) + if choice == codeLocation: + print("Carved into the edging, you see the number " + str(codeValue) + ".") - def on_key_press(self, key, modifiers): - """Called whenever a key is pressed. """ - pass + print("") - def on_key_release(self, key, modifiers): - """Called when the user releases a key. """ - pass + else: - def on_update(self, delta_time): - """ Movement and game logic """ - pass + print("You find no code.") - def on_draw(self): - """ Draw everything """ - self.clear() - self.wall_list.draw() - self.bullet_list.draw() - self.item_list.draw() - self.player_list.draw() + print("") + + +def briefcase(choice, codeLocation, codeValue): + print("") + + print("The backpack was on the suspects back during the chase. Maybe it still contains intel.") + + if choice == codeLocation: + print("Within the front pocket, you see the number " + str(codeValue) + " written on a crumpled note.") + + print("") + + else: + + print("You find no code.") + + print("") + + +def ashtray(choice, codeLocation, codeValue): + print("") + + print("A cracked ash tray holds the remains of a cigar.") + + if choice == codeLocation: + + print("On the base, you see the number " + str(codeValue) + ".") + + else: + + print("You find no code.") + + print("") + + +def bucket(choice, codeLocation, codeValue): + print("") + + print("The bucket sits in the middle of the floor. It seems to " + "hold " + "bullet casings") + + if choice == codeLocation: + + print("Within, you see exactly " + str(codeValue) + " stones.") + + print("") + + else: + + print("You find no code.") + + print("") + + +def painting(choice, codeLocation, codeValue): + print("") + + print("A gruesome scene depicting atrocities this monster has committed. " + "This fate will fall on many others if you can't crack the code.") + + if choice == codeLocation: + + print("Painted in the corner, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def gemcase(choice, codeLocation, codeValue): + print("") + + print("Thousands of dollars in stollen gems line the inside of this simple box.") + + if choice == codeLocation: + + print("Etched inside the lid, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def rug(choice, codeLocation, codeValue): + print("") + + print("A dusty woven rug adorns the otherwise ragged wooden floor, you notice a corner is turned up.") + + if choice == codeLocation: + + print("Carved onto the floor beneath, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def mirror(choice, codeLocation, codeValue): + print("") + + print("The mirror is grimy and unpleasant. " + "The unnatural reflection leers back at you. But you notice it isn't reflecting every detail of the room.") + + if choice == codeLocation: + + print("As you study your reflection, you notice the number " + str(codeValue) + " painted onto your shirt in " + "the reflection.") + + print("") + + else: + + print("You find no code.") + + print("") + + +def bookshelf(choice, codeLocation, codeValue): + print("") + + print("A bookshelf filled with old catches your attention, something is off about them.") + + if choice == codeLocation: + + print("You notice the books are all the same volume. The volume number is " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") def main(): - """ Main function """ - window = GameWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) - window.setup() - arcade.run() + # Main game loop + codeSegment1 = random.randint(0, 9) + + codeSegment2 = random.randint(0, 9) + + codeSegment3 = random.randint(0, 9) + + code = int(str(codeSegment1) + str(codeSegment2) + str(codeSegment3)) + + items = ["Door", "Window", "Briefcase", "Ashtray", "Bucket", "Painting", "Jewelry Box", "Rug", "Mirror", "Bookshelf"] + + code1Location = random.randint(1, 3) + + code2Location = random.randint(4, 6) + + code3Location = random.randint(7, 9) + + intro() + done = False + while not done: + choice = menu(items, "What do you want to inspect? ") + + if choice == 1: + + window(choice, code1Location, codeSegment1) + + elif choice == 2: + + briefcase(choice, code1Location, codeSegment1) + + elif choice == 3: + + ashtray(choice, code1Location, codeSegment1) + + elif choice == 4: + + bucket(choice, code2Location, codeSegment2) + + elif choice == 5: + + painting(choice, code2Location, codeSegment2) + + elif choice == 6: + + gemcase(choice, code2Location, codeSegment2) + + elif choice == 7: + + rug(choice, code3Location, codeSegment3) + + elif choice == 8: + + mirror(choice, code3Location, codeSegment3) + + elif choice == 9: + + bookshelf(choice, code3Location, codeSegment3) + + elif choice == 0: + + result = Door(code) + + if result == 1: + break -if __name__ == "__main__": - main() \ No newline at end of file +main() From 584833a1772d4f441a38f540818d2ad519b07b82 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 16 May 2024 19:01:31 -0400 Subject: [PATCH 26/29] Update lab_02.py --- Lab 02 - Draw a Picture/lab_02.py | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Lab 02 - Draw a Picture/lab_02.py b/Lab 02 - Draw a Picture/lab_02.py index e69de29bb..a1347145d 100644 --- a/Lab 02 - Draw a Picture/lab_02.py +++ b/Lab 02 - Draw a Picture/lab_02.py @@ -0,0 +1,59 @@ + +import arcade + + +arcade.open_window(800, 600, ) + +# Set the background color +arcade.set_background_color(arcade.color.BLUE_GRAY) + +# Get ready to draw +arcade.start_render() + +# Draw the snowy ground +arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.WHITE) + +# --- Draw Clouds --- + +arcade.draw_ellipse_filled(200, 350, 50, 50, arcade.color.SNOW) + +arcade.draw_ellipse_filled(500, 270, 200, 110, arcade.color.SNOW) + +arcade.draw_ellipse_filled(10, 250, 110, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(670, 280, 90, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(400, 300, 70, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(300, 400, 150, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(750, 500, 150, 150, arcade.color.SNOW) + +arcade.draw_ellipse_filled(500, 500, 50, 50, arcade.color.SNOW) + +# --- Draw Snowman --- + +# Bottom circle +arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK) +arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE) +arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE) +arcade.draw_circle_filled(490, 110, 10, arcade.color.BLACK_BEAN) + +# Middle Circle +arcade.draw_circle_filled(490, 180, 30, arcade.color.BLACK) +arcade.draw_circle_filled(490, 180, 25, arcade.color.BLACK_OLIVE) +arcade.draw_circle_filled(490, 180, 18, arcade.color.OLD_LACE) +arcade.draw_circle_filled(490, 180, 5, arcade.color.BLACK_BEAN) + +# Top Circle +arcade.draw_circle_filled(490, 230, 25, arcade.color.BLACK) +arcade.draw_circle_filled(490, 230, 15, arcade.color.BLACK_OLIVE) +arcade.draw_circle_filled(490, 230, 18, arcade.color.OLD_LACE) +arcade.draw_circle_filled(490, 225, 3, arcade.color.ORANGE) +arcade.draw_circle_filled(500, 230, 3, arcade.color.BLACK_BEAN) +arcade.draw_circle_filled(480, 230, 3, arcade.color.BLACK_BEAN) +# --- Finish drawing --- +arcade.finish_render() + +# Keep the window up until someone closes it. +arcade.run() From 928d5332b09b7bd1ef078e0d27aa0cfd7d80e4d9 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 16 May 2024 19:07:32 -0400 Subject: [PATCH 27/29] Update lab_03.py --- Lab 03 - Draw Using Functions/lab_03.py | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Lab 03 - Draw Using Functions/lab_03.py b/Lab 03 - Draw Using Functions/lab_03.py index e69de29bb..c345de34d 100644 --- a/Lab 03 - Draw Using Functions/lab_03.py +++ b/Lab 03 - Draw Using Functions/lab_03.py @@ -0,0 +1,63 @@ +import arcade + +SCREEN_WIDTH = 800 +SCREEN_HEIGHT = 600 + + +def main(): + arcade.open_window(800, 600, ) + + # Set the background color + arcade.set_background_color(arcade.color.BLUE_GRAY) + + # Get ready to draw + arcade.start_render() + + # Draw the grass + arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.WHITE) + + # --- Draw Clouds --- + + arcade.draw_ellipse_filled(200, 350, 50, 50, arcade.color.SNOW) + + arcade.draw_ellipse_filled(500, 270, 200, 110, arcade.color.SNOW) + + arcade.draw_ellipse_filled(10, 250, 110, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(670, 280, 90, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(400, 300, 70, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(300, 400, 150, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(750, 500, 150, 150, arcade.color.SNOW) + + arcade.draw_ellipse_filled(500, 500, 50, 50, arcade.color.SNOW) + + # --- Draw Snowman --- + + # Bottom circle + arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK) + arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 110, 10, arcade.color.BLACK_BEAN) + + # Middle Circle + arcade.draw_circle_filled(490, 180, 30, arcade.color.BLACK) + arcade.draw_circle_filled(490, 180, 25, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 180, 18, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 180, 5, arcade.color.BLACK_BEAN) + + # Top Circle + arcade.draw_circle_filled(490, 230, 25, arcade.color.BLACK) + arcade.draw_circle_filled(490, 230, 15, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 230, 18, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 225, 3, arcade.color.ORANGE) + arcade.draw_circle_filled(500, 230, 3, arcade.color.BLACK_BEAN) + arcade.draw_circle_filled(480, 230, 3, arcade.color.BLACK_BEAN) + # --- Finish drawing --- + arcade.finish_render() + + +# Call the main function to get the program started. +main() From 69c8e67c0129ad0ef5eaa6f18783a21f46d906c7 Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 16 May 2024 21:36:21 -0400 Subject: [PATCH 28/29] Update final lab.py --- Lab 12 - Final Lab/final lab.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lab 12 - Final Lab/final lab.py b/Lab 12 - Final Lab/final lab.py index 0642a2ea3..668f475f6 100644 --- a/Lab 12 - Final Lab/final lab.py +++ b/Lab 12 - Final Lab/final lab.py @@ -4,14 +4,12 @@ # Game Functions def intro(): # Starts the game - print( - "You are part of an elite counter terrorism task force, responsible for bringing down some of the most " + print("You are part of an elite counter terrorism task force, responsible for bringing down some of the most " "dangerous people in the world.") print("For weeks now, you have been tracking an unidentified target.") print("All you know is that whoever this individual is, dozens of terrorist attacks can be traced back to them.") print( - "For a moment you finally had them cornered. However, right before your team could apprehend them, " - "the got away.") + "For a moment you finally had them cornered. However, right before your team could apprehend them, they got away.") print("You followed them into a hidden underground bunker. You've seen something like this before.") print("There is a locked door on the far end of this dark room.") @@ -284,7 +282,7 @@ def main(): code = int(str(codeSegment1) + str(codeSegment2) + str(codeSegment3)) - items = ["Door", "Window", "Briefcase", "Ashtray", "Bucket", "Painting", "Jewelry Box", "Rug", "Mirror", "Bookshelf"] + items = ["Door", "Window", "Briefcase", "Ashtray", "Bucket", "Painting", "Gem Case", "Rug", "Mirror", "Bookshelf"] code1Location = random.randint(1, 3) @@ -342,3 +340,4 @@ def main(): main() + From 5ca530ab57293e8bcffcdf7b4b9b8e7ee0ccc88e Mon Sep 17 00:00:00 2001 From: buchmanj1 <159155313+buchmanj1@users.noreply.github.com> Date: Thu, 16 May 2024 21:48:27 -0400 Subject: [PATCH 29/29] Update lab_03.py --- Lab 03 - Draw Using Functions/lab_03.py | 50 ++++++++++++++++--------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/Lab 03 - Draw Using Functions/lab_03.py b/Lab 03 - Draw Using Functions/lab_03.py index c345de34d..91e926d47 100644 --- a/Lab 03 - Draw Using Functions/lab_03.py +++ b/Lab 03 - Draw Using Functions/lab_03.py @@ -3,8 +3,7 @@ SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 - -def main(): +def setupdrawing(): arcade.open_window(800, 600, ) # Set the background color @@ -13,9 +12,11 @@ def main(): # Get ready to draw arcade.start_render() - # Draw the grass - arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.WHITE) - + # Draw the ground +def drawground(): + arcade.draw_rectangle_filled(0, 800, 200, 0, arcade.color.WHITE) + +def drawcloud(): # --- Draw Clouds --- arcade.draw_ellipse_filled(200, 350, 50, 50, arcade.color.SNOW) @@ -34,29 +35,42 @@ def main(): arcade.draw_ellipse_filled(500, 500, 50, 50, arcade.color.SNOW) - # --- Draw Snowman --- +def snowmantop(): + # Top Circle + arcade.draw_circle_filled(490, 230, 25, arcade.color.BLACK) + arcade.draw_circle_filled(490, 230, 15, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 230, 18, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 225, 3, arcade.color.ORANGE) + arcade.draw_circle_filled(500, 230, 3, arcade.color.BLACK_BEAN) + arcade.draw_circle_filled(480, 230, 3, arcade.color.BLACK_BEAN) + +def snowmanmiddle(): + # Middle Circle + arcade.draw_circle_filled(490, 180, 30, arcade.color.BLACK) + arcade.draw_circle_filled(490, 180, 25, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 180, 18, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 180, 5, arcade.color.BLACK_BEAN) +def snowmanbottom(): # Bottom circle arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK) arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE) arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE) arcade.draw_circle_filled(490, 110, 10, arcade.color.BLACK_BEAN) - # Middle Circle - arcade.draw_circle_filled(490, 180, 30, arcade.color.BLACK) - arcade.draw_circle_filled(490, 180, 25, arcade.color.BLACK_OLIVE) - arcade.draw_circle_filled(490, 180, 18, arcade.color.OLD_LACE) - arcade.draw_circle_filled(490, 180, 5, arcade.color.BLACK_BEAN) - # Top Circle - arcade.draw_circle_filled(490, 230, 25, arcade.color.BLACK) - arcade.draw_circle_filled(490, 230, 15, arcade.color.BLACK_OLIVE) - arcade.draw_circle_filled(490, 230, 18, arcade.color.OLD_LACE) - arcade.draw_circle_filled(490, 225, 3, arcade.color.ORANGE) - arcade.draw_circle_filled(500, 230, 3, arcade.color.BLACK_BEAN) - arcade.draw_circle_filled(480, 230, 3, arcade.color.BLACK_BEAN) + +def main(): + setupdrawing() + drawground() + drawcloud() + snowmantop() + snowmanbottom() + snowmanmiddle() + # --- Finish drawing --- arcade.finish_render() + arcade.run() # Call the main function to get the program started.