Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 33 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
437ce44
Setting up GitHub Classroom Feedback
github-classroom[bot] Apr 29, 2024
2b1be09
add online IDE url
github-classroom[bot] Apr 29, 2024
eeec7e8
Final Project
carolz2004 Apr 29, 2024
91c5c06
Final Project
carolz2004 Apr 29, 2024
28c648f
.
ashleymera Apr 29, 2024
560fa42
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
ashleymera Apr 29, 2024
542370b
Final Project
carolz2004 Apr 29, 2024
0bc2646
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
carolz2004 Apr 29, 2024
02423cd
stuff
ashleymera Apr 29, 2024
792e8f0
Final Project
carolz2004 Apr 29, 2024
5d6893d
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
carolz2004 Apr 29, 2024
6ceb66c
c
ashleymera Apr 29, 2024
93b1510
Final Project
ashleymera Apr 29, 2024
0bbb0e3
ATP
ashleymera Apr 30, 2024
bc7ae3f
Final
carolz2004 Apr 30, 2024
d623d25
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
carolz2004 Apr 30, 2024
9b91e3c
pics
ashleymera Apr 30, 2024
9641051
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
ashleymera Apr 30, 2024
84cfdf4
down prince
ashleymera Apr 30, 2024
16d435d
.
carolz2004 May 1, 2024
bcc98f9
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
carolz2004 May 1, 2024
fb63110
hi
ashleymera May 1, 2024
2f204a8
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
ashleymera May 1, 2024
eceb5f7
.
ashleymera May 1, 2024
df83089
.
ashleymera May 3, 2024
2b895cd
.
ashleymera May 4, 2024
5d76175
.
ashleymera May 4, 2024
acc236d
.
carolz2004 May 4, 2024
9d0cf81
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
carolz2004 May 4, 2024
173ac9f
.
ashleymera May 4, 2024
99bae74
Merge branch 'master' of https://github.com/bucsspring2024/final-proj…
ashleymera May 5, 2024
e0fe2e3
.
ashleymera May 5, 2024
41458b1
.
ashleymera May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 91 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-718a45dd9cf7e7f842a935f5ebbe5719a5e09af4491e668f4dbf3b35d5cca122.svg)](https://classroom.github.com/online_ide?assignment_repo_id=14913552&assignment_repo_type=AssignmentRepo)

:warning: Everything between << >> needs to be replaced (remove << >> after replacing)

# << Project Title >>
## CS110 Final Project << Semester, Year >>
# Tower Rescue:
## CS110 Final Project Spring, 2024

## Team Members

<< List team member names >>
Carol Zhang
Ashley Mera

***
***

## Project Description

<< Give an overview of your project >>
Tower Rescue. For this project, there will be a girl in a tower that needs to be saved. Your character is supposed to save the girl but there is a evil witch at the top of the tower trying to chase you. This is a 2 player game so either person can win. The witch will win if she gets the prince before he can catch Rapunzel and the prince will win if he gets to Rapunzel without getting caught.

***

Expand All @@ -29,21 +31,93 @@
## Program Design

### Features

1. << Feature 1 >>
2. << Feature 2 >>
3. << Feature 3 >>
4. << Feature 4 >>
5. << Feature 5 >>
1. "Press start"
2. Moving characters
3. Witch with her apple
4. Tower background
5. "You win!"
=======

### Classes
Character class: represents the main characters and the character can move in various directions and perform actions like jumping
Tower class: represents the tower and checks for collisions with the character to determine if the character has reached the top
Witch class: the witch can throw apples at the character

- Character Class: Represents the main character of the game, tasked with saving the girl from the tower. The character can move in various directions and perform actions like jumping.
- Tower Class: Represents the tower where the girl is held captive. It checks for collisions with the character to determine if the character has reached the top of the tower.
-Witch Class: Represents the evil witch at the top of the tower. The witch can chase the prince and when they collide the witch will win.
-Apple Class: Represents the apples that is used with the witch.
-class StartMenu: Allows buttons to play
-class Highscore: Keeps track of time
-class Clouds: extra decorations for visuals
-class Rapunzel: The person who needs to be saved, if touched by prince, game is won.
-class button: Allows retry


- Controller Class: Manages the game loop, handles events, updates game logic, and controls the flow of the game.

- << You should have a list of each of your classes with a description >>

## ATP

| Step |Procedure |Expected Results |
|----------------------|:--------------------:|----------------------------------:|
| 1 | Run Counter Program |GUI window appears with count = 0 |
| 2 | click count button | display changes to count = 1 |
etc...
TEST CASE 1: Player Movement for the Prince
Test Description: Verify that the player can move left, right and up.
Test Steps:
1. Start the game
2. Press the left arrow key on keyboard
3. Verify the player moves left
4. Press the right key arrow key on keyboard
5. Verify the player moves right
6. Press the Up key arrow key on keyboard
7. Verify the player moves up
Expected Outcome: The player should move left, right or up using keyboard keys.

TEST CASE 2: Player Movement for the Witch
Test Description: Verify that the player can move left, right and up.
Test Steps:
1. Start the game
2. Press "1" on keyboard to move left
3. Verify the player moves left
4. Press "2" on keyboard
5. Verify the player moves right
6. Press "4" on keyboard to move down
7. Verify the player moves down
8. Press "3" on keyboard to move up
9. Verify the player moves up
Expected Outcome: The player should move left, right or up and down using keyboard numbers.


TEST CASE 3: Collision detected
Test Description: Ensure that collisions between the witch and prince are detected correctly. You are playing the witch (Keys for witch are 1 and 2, to move left and right and 3, 4 are to move up and down check test case 2 for verification)
Test Steps:
1.Start the game.
2. If you are playing the witch, chase the prince until collistion
3.Verify that the witch with apple hits the prince. It will say "Game Over"
4. If you are playing with prine, move the prince until he arrives to rapunzel
5. Verify that no collision is detected. The prince will win and screen will say "you win!"
Expected Outcome: Collision of characters should determine winning or losing outcome.



TEST CASE 4: Win/Lose Navigation
Test Description: Test the navigation through the game's menu
Test Steps:
1. Run the Game
2. Check to see if a "play button" appears
3. Click "PLAY"
4. Verify that game begins
5. Play the game
Expected Outcome: The beginning button should start the game

TEST CASE 5: Game Over/Retry Condition
1. Start the game
2. Play the game
3. If playing prince, get hit by witch
4. Verify that game displays "Game Over"
5. Click "retry"
6. Verify you can play again
7. If playing prince, get to rapunzel
8. Verify that game displays "You win"
9. Click "retry"
10. Verify you can play again

Expected Outcome: The game should display a message when the player loses or winsand you should get the option to play again.
Binary file added assets/Untitled design.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/finalgui.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/foldercontents.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
all of your media (images/music/video) go in this folder

Binary file added assets/gameover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/gui.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prince.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/quit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rapunzel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/retry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/startgame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/witch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/youwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import pygame
#import your controller
from src.controller import Controller

def main():
pygame.init()

games=Controller()
games.mainloop()
#Create an instance on your controller object
#Call your mainloop

Expand Down
Binary file added src/__pycache__/controller.cpython-310.pyc
Binary file not shown.
Binary file added src/__pycache__/game.cpython-310.pyc
Binary file not shown.
233 changes: 233 additions & 0 deletions src/controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import pygame
from src.game import Character
from src.game import Tower
from src.game import Witch
#from src.game import Apple
from src.game import StartButton
from src.game import Rapunzel
from src.game import Apple
from src.game import Cloud
from src.game import Highscore

#from src.game import RetryButton


class Controller:
def __init__(self):
pygame.init()
self.start_button = StartButton(300, 150, .60, 'assets/startgame.png')
self.retry_button = StartButton(400, 400, .60, 'assets/retry.png') # Add retry button THIS IS NEW, DELETE IF DONT WORK
self.start_button_visible = True
self.clock = pygame.time.Clock()
self.game_over = False


self.you_win_image = pygame.image.load('assets/youwin.png')
self.you_win_rect = self.you_win_image.get_rect()
self.you_win_rect.center = (400, 300)

self.game_over_image = pygame.image.load('assets/gameover.png')
self.game_over_rect = self.game_over_image.get_rect()
self.game_over_rect.center = (400, 300)

self.retry_image = pygame.image.load('assets/retry.png')
self.retry_rect = self.retry_image.get_rect()
self.retry_rect.center = (400, 300)


def reset_game(self):




self.cloud = Cloud(50, 150 , .90, 'assets/clouds.png')
self.prince = Character(100, 400, .25, 'assets/prince.png')
self.tower = Tower(300, 50 , .55, 'assets/tower.png')
self.witch = Witch(100, 20, .02,'assets/witch.png', )
self.apple = Apple(100, 50, .005, 'assets/apple.png')
self.rapunzel = Rapunzel (350, 150 , .30, 'assets/rapunzel.png')
self.score = 0


self.charactergroup= pygame.sprite.Group(self.prince)
self.witchgroup= pygame.sprite.Group(self.witch)
self.towergroup= pygame.sprite.Group(self.tower)
#self.startbuttongroup = pygame.sprite.Group(self.start_button)
self.rapunzelgroup = pygame.sprite.Group(self.rapunzel)
self.apple_group = pygame.sprite.Group(self.apple)
self.cloud_group = pygame.sprite.Group(self.cloud)





def mainloop(self):

screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
self.reset_game()
#CONSTANTS
INTRO=0
GAME=1
RETRY=2


cloud = Cloud(50, 150 , .90, 'assets/clouds.png')
prince = Character(100, 400, .25, 'assets/prince.png')
tower = Tower(300, 50 , .55, 'assets/tower.png')
witch = Witch(100, 20, .02,'assets/witch.png', )
apple = Apple(100, 50, .005, 'assets/apple.png')
rapunzel = Rapunzel (350, 150 , .30, 'assets/rapunzel.png')

charactergroup= pygame.sprite.Group(prince)
witchgroup= pygame.sprite.Group(witch)
towergroup= pygame.sprite.Group(tower)
startbuttongroup = pygame.sprite.Group(self.start_button)
rapunzelgroup = pygame.sprite.Group(rapunzel)
apple_group = pygame.sprite.Group(apple)
cloud_group = pygame.sprite.Group(cloud)





running = True
start_game = INTRO
game_over= False
score = 0

while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:

running = False
elif event.type == pygame.MOUSEBUTTONDOWN and start_game == INTRO:
if self.start_button.is_clicked(event.pos):
#if self.start_button.rect.collidepoint(event.pos):
start_game = GAME
score = 0
#self.startbuttongroup.empty()


elif event.type == pygame.MOUSEBUTTONDOWN and game_over:
#if self.retry_button.rect.collidepoint(event.pos):
if self.retry_button.is_clicked(event.pos): # Check for retry button click NEW STUFFY
print(self.score)
self.reset_game()
game_over = False
start_game= GAME



if start_game == GAME:
key=pygame.key.get_pressed()
if key[pygame.K_LEFT]:
self.prince.move_left()
if key[pygame.K_RIGHT]:
self.prince.move_right()
if key[pygame.K_UP]:
self.prince.move_up()
if key[pygame.K_DOWN]:
self.prince.move_down()
if key[pygame.K_1]:
self.witch.move_left()
if key[pygame.K_2]:
self.witch.move_right()
if key[pygame.K_1]:
self.apple.move_left()
if key[pygame.K_2]:
self.apple.move_right()
if key[pygame.K_3]:
self.apple.move_up()
self.witch.move_up()
if key[pygame.K_4]:
self.apple.move_down()
self.witch.move_down()





#prince.move_up() # Example movement, adjust as needed
#apple.move() # Example apple movement, adjust as needed

# Check collisions
#if tower.check_collision(prince):
# Handle collision logic
pass


self.charactergroup.update()
self.witchgroup.update()
self.towergroup.update()
#self.startbuttongroup.update()
self.rapunzelgroup.update()
self.apple_group.update()
self.cloud_group.update()
# Draw everything
screen.fill((" sky blue")) # White background
# Draw characters, tower, apples, etc.
self.cloud_group.draw(screen)
self.towergroup.draw(screen)
self.charactergroup.draw(screen)
self.witchgroup.draw(screen)
self.rapunzelgroup.draw(screen)
self.apple_group.draw(screen)



if pygame.sprite.collide_rect(self.prince, self.apple):
screen.blit(self.game_over_image, self.game_over_rect)
pygame.display.flip()
pygame.time.delay(3000) # Display for 3 seconds before quitting
start_game = RETRY
game_over= True
self.score=score

if pygame.sprite.collide_rect(self.prince, self.rapunzel):
screen.blit(self.you_win_image, self.you_win_rect)
pygame.display.flip()
pygame.time.delay(3000) # Display for 3 seconds before quitting
start_game = RETRY
game_over=True
self.score=score


#THIS IS NEW STUFF
if pygame.sprite.collide_rect(self.prince, self.apple) or pygame.sprite.collide_rect(self.prince, self.rapunzel):
#screen.blit(self.retry_image, self.retry_rect)
self.retry_button.draw(screen)
pygame.display.flip()
pygame.time.delay(3000) # Display for 3 seconds before quitting
start_game = RETRY
game_over= True
self.score=score






#if pygame.sprite.spritecollide(prince, apple_group, True):
#self.game_over = True
#print("Prince hit by apple! Witch wins.")

elif start_game == INTRO:
screen.fill("sky blue")
#self.startbuttongroup.draw(screen)
self.start_button.draw(screen)


#else:

#screen.fill("sky blue")
#startbuttongroup.draw(screen)

pygame.display.flip()
score += clock.tick(60)

pygame.quit()

if __name__ == "__main__":
controller = Controller()
controller.mainloop()
Loading