diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..35c0173 Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..642ff51 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.REPL.enableREPLSmartSend": false +} \ No newline at end of file diff --git a/README.md b/README.md index 28a3578..6185d2b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,17 @@ +[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-718a45dd9cf7e7f842a935f5ebbe5719a5e09af4491e668f4dbf3b35d5cca122.svg)](https://classroom.github.com/online_ide?assignment_repo_id=14588448&assignment_repo_type=AssignmentRepo) -:warning: Everything between << >> needs to be replaced (remove << >> after replacing) - -# << Project Title >> -## CS110 Final Project << Semester, Year >> +# Enter Valorant +## CS110 Final Project Spring, 2024 ## Team Members -<< List team member names >> +none *** ## Project Description -<< Give an overview of your project >> +I want to make a Enter the Gungeon style game where the character you pick are from Valorant. You will play as Jett and be able to use her basic abilities as well has have the art style of Enter the Gungeon. *** @@ -30,20 +29,76 @@ ### Features -1. << Feature 1 >> -2. << Feature 2 >> -3. << Feature 3 >> -4. << Feature 4 >> -5. << Feature 5 >> +1. Agent Selection - where you pick the agent (Jett) +2. Moveable Character - The agent(Jett) can be controlled to move left right and at an angle +3. Shoot - You would be able to shoot a gun at the direction you click +4. Changing Backgrounds - you are able to move between screens +5. Game Completed Screen - when you complete the level, the game ends with a screen ### Classes -- << You should have a list of each of your classes with a description >> +- Class Controller: controls what game state the game is in from Menu, Agent Selection, Game, and Gameover mode. In each of the game states you can do certain things and can go between the states. +- Class Jett: initializes Jett's attributes like her speed, animation, gun, size and abilities. Additionally, it is also where her movement controls, shooting mechanics, abilities and animations are. +- Class Classic: initializes the gun Classic's attributes like its shooting speed and sprites. +- Class Bullet: initializes the bullet's attributes of the Classic gun like the speed and size. It also controlls the direction that the bulllets shoots and where it comes out of from the gun sprite. +- Class Room: initializes the background, boundaries, obstacles and componenets of the rooms. +- Class gameController: initializes the room backrounds themselves as well as control room changes. Also create the components of the rooms like the signs, dummies and how Jett interact with the rooms. ## 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 +----------------------------- +- Test Description: Verify that the player can move in all directions including diagonals +- Test Steps: + 1. Start game by pressing SPACE + 2. Move left and right with A and D respectively + 3. Move up and down with W and S respectively + 4. Move diagonals with A+W, D+W, A+S, and D+S +- Expected Outcome: The players moves in the appropriate direction and changes sprite thats corresponds with the directions + +Test Case 2: Dash Ability +--------------------------- +- Test Description: Verify that the player can use her dash ability +- Test Steps: + 1. Start game by pressing SPACE + 2. To use her dash ability press E + 3. The direction of the dash corresponds with the WASD keys + 4. Verify that the player moves in a specific direction quickly + 5. Verify that the sprite changes with dash + 6. Ensure that there is a slight cooldown between dashes + 7. Verify that the player can go in all 8 directions +- Expected Outcome: When utilizing her ability, the player should move very quickly towards the direction they are moving towards + +Test Case 3: Updraft Ability +----------------------------- +- Test Description: Verify that the player can use her updraft ability +- Test Steps: + 1. Start game by pressing SPACE + 2. To use her updraft ability press Q + 3. Verify that she moves up and comes back down + 4. Verify that she becomes slightly transparent + 5. Verify the updraft sprite plays + 6. Ensure that there is a slight cooldown between updrafts +- Expected Outcome: When utilizing her updraft ability, she moves up and then down while being transparent and changes sprite. + +Test Case 4: Smoke Ball Ability +-------------------------------- +- Test Description: Verify that the player can throw smoke ball towards a certain direction +- Test Steps: + 1. Start game by pressing SPACE + 2. To use her smoke ball ability press C + 3. Verify that the player throws smoke balls towards the direction of the mouse + 4. Verify that smoke travels a fixed distance before stopping + 5. The smoke ball expands after stopping +- Expected Outcome: When utilizing the smoke ball ability, she throws a smoke ball towards the direction of the mouse before stopping and expanding before disappearing after 3-4 seconds + +Test Case 5: Gun Play +--------------------- +- Test Description: Verify that the player can switch between gun and hand and shoot with the gun +- Test Steps: + 1. Start the game by pressing SPACE + 2. To switch to gun press 2 and switch to hand press 3 + 3. Aim with your mouse and click to shoot + 4. Verify that the bullet travels to the mouse and keeps going until hitting an obstacle +- Expected Outcome: The player switches to their gun and shoot a bullet at the direction the mouse is. The bullet will travel until either it exits the screen or hit an obstacle + diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..3826aeb Binary files /dev/null and b/__pycache__/main.cpython-310.pyc differ diff --git a/assets/agentSelection.png b/assets/agentSelection.png new file mode 100644 index 0000000..bc3988b Binary files /dev/null and b/assets/agentSelection.png differ diff --git a/assets/background.png b/assets/background.png new file mode 100644 index 0000000..6f6d4c0 Binary files /dev/null and b/assets/background.png differ diff --git a/assets/dummy.png b/assets/dummy.png new file mode 100644 index 0000000..7551ed1 Binary files /dev/null and b/assets/dummy.png differ diff --git a/assets/finalgui.jpg b/assets/finalgui.jpg new file mode 100644 index 0000000..eb806fd Binary files /dev/null and b/assets/finalgui.jpg differ diff --git a/assets/gui.jpg b/assets/gui.jpg index cf4630c..8d2dd97 100644 Binary files a/assets/gui.jpg and b/assets/gui.jpg differ diff --git a/assets/gun/classic/classicLeft.png b/assets/gun/classic/classicLeft.png new file mode 100644 index 0000000..09a8a3d Binary files /dev/null and b/assets/gun/classic/classicLeft.png differ diff --git a/assets/gun/classic/classicRight.png b/assets/gun/classic/classicRight.png new file mode 100644 index 0000000..0781505 Binary files /dev/null and b/assets/gun/classic/classicRight.png differ diff --git a/assets/jettDashing/JettDashBack.png b/assets/jettDashing/JettDashBack.png new file mode 100644 index 0000000..17d014e Binary files /dev/null and b/assets/jettDashing/JettDashBack.png differ diff --git a/assets/jettDashing/JettDashBackLeft.png b/assets/jettDashing/JettDashBackLeft.png new file mode 100644 index 0000000..7bfb726 Binary files /dev/null and b/assets/jettDashing/JettDashBackLeft.png differ diff --git a/assets/jettDashing/JettDashBackRight.png b/assets/jettDashing/JettDashBackRight.png new file mode 100644 index 0000000..f3f43f1 Binary files /dev/null and b/assets/jettDashing/JettDashBackRight.png differ diff --git a/assets/jettDashing/JettDashFront.png b/assets/jettDashing/JettDashFront.png new file mode 100644 index 0000000..5ec2b7c Binary files /dev/null and b/assets/jettDashing/JettDashFront.png differ diff --git a/assets/jettDashing/JettDashLeft.png b/assets/jettDashing/JettDashLeft.png new file mode 100644 index 0000000..f8ea38e Binary files /dev/null and b/assets/jettDashing/JettDashLeft.png differ diff --git a/assets/jettDashing/JettDashRight.png b/assets/jettDashing/JettDashRight.png new file mode 100644 index 0000000..e89d7cc Binary files /dev/null and b/assets/jettDashing/JettDashRight.png differ diff --git a/assets/jettSmoke/JettSmokeBack.png b/assets/jettSmoke/JettSmokeBack.png new file mode 100644 index 0000000..07a7156 Binary files /dev/null and b/assets/jettSmoke/JettSmokeBack.png differ diff --git a/assets/jettSmoke/JettSmokeBackLeft.png b/assets/jettSmoke/JettSmokeBackLeft.png new file mode 100644 index 0000000..1d29788 Binary files /dev/null and b/assets/jettSmoke/JettSmokeBackLeft.png differ diff --git a/assets/jettSmoke/JettSmokeBackRight.png b/assets/jettSmoke/JettSmokeBackRight.png new file mode 100644 index 0000000..e951e6b Binary files /dev/null and b/assets/jettSmoke/JettSmokeBackRight.png differ diff --git a/assets/jettSmoke/JettSmokeFront.png b/assets/jettSmoke/JettSmokeFront.png new file mode 100644 index 0000000..94fa842 Binary files /dev/null and b/assets/jettSmoke/JettSmokeFront.png differ diff --git a/assets/jettSmoke/JettSmokeLeft.png b/assets/jettSmoke/JettSmokeLeft.png new file mode 100644 index 0000000..c8168ca Binary files /dev/null and b/assets/jettSmoke/JettSmokeLeft.png differ diff --git a/assets/jettSmoke/JettSmokeRight.png b/assets/jettSmoke/JettSmokeRight.png new file mode 100644 index 0000000..7603ffc Binary files /dev/null and b/assets/jettSmoke/JettSmokeRight.png differ diff --git a/assets/jettSmoke/SmokeBall.png b/assets/jettSmoke/SmokeBall.png new file mode 100644 index 0000000..5e47005 Binary files /dev/null and b/assets/jettSmoke/SmokeBall.png differ diff --git a/assets/jettStanding/JettBack.png b/assets/jettStanding/JettBack.png new file mode 100644 index 0000000..ab0f506 Binary files /dev/null and b/assets/jettStanding/JettBack.png differ diff --git a/assets/jettStanding/JettBackLeft.png b/assets/jettStanding/JettBackLeft.png new file mode 100644 index 0000000..c42f0cc Binary files /dev/null and b/assets/jettStanding/JettBackLeft.png differ diff --git a/assets/jettStanding/JettBackRight.png b/assets/jettStanding/JettBackRight.png new file mode 100644 index 0000000..73912d8 Binary files /dev/null and b/assets/jettStanding/JettBackRight.png differ diff --git a/assets/jettStanding/JettFront.png b/assets/jettStanding/JettFront.png new file mode 100644 index 0000000..3dcc24a Binary files /dev/null and b/assets/jettStanding/JettFront.png differ diff --git a/assets/jettStanding/JettLeft.png b/assets/jettStanding/JettLeft.png new file mode 100644 index 0000000..3ff02f2 Binary files /dev/null and b/assets/jettStanding/JettLeft.png differ diff --git a/assets/jettStanding/JettRight.png b/assets/jettStanding/JettRight.png new file mode 100644 index 0000000..25f2a72 Binary files /dev/null and b/assets/jettStanding/JettRight.png differ diff --git a/assets/jettStandingGun/JettBackGun.png b/assets/jettStandingGun/JettBackGun.png new file mode 100644 index 0000000..1ab29aa Binary files /dev/null and b/assets/jettStandingGun/JettBackGun.png differ diff --git a/assets/jettStandingGun/JettBackLeftGun.png b/assets/jettStandingGun/JettBackLeftGun.png new file mode 100644 index 0000000..c42f0cc Binary files /dev/null and b/assets/jettStandingGun/JettBackLeftGun.png differ diff --git a/assets/jettStandingGun/JettBackRightGun.png b/assets/jettStandingGun/JettBackRightGun.png new file mode 100644 index 0000000..73912d8 Binary files /dev/null and b/assets/jettStandingGun/JettBackRightGun.png differ diff --git a/assets/jettStandingGun/JettFrontGun.png b/assets/jettStandingGun/JettFrontGun.png new file mode 100644 index 0000000..f40af58 Binary files /dev/null and b/assets/jettStandingGun/JettFrontGun.png differ diff --git a/assets/jettStandingGun/JettLeftGun.png b/assets/jettStandingGun/JettLeftGun.png new file mode 100644 index 0000000..df5fbd8 Binary files /dev/null and b/assets/jettStandingGun/JettLeftGun.png differ diff --git a/assets/jettStandingGun/JettRightGun.png b/assets/jettStandingGun/JettRightGun.png new file mode 100644 index 0000000..2903bc4 Binary files /dev/null and b/assets/jettStandingGun/JettRightGun.png differ diff --git a/assets/jettUpdraft/JettUpdraftLeft.png b/assets/jettUpdraft/JettUpdraftLeft.png new file mode 100644 index 0000000..b49d95b Binary files /dev/null and b/assets/jettUpdraft/JettUpdraftLeft.png differ diff --git a/assets/jettUpdraft/JettUpdraftRight.png b/assets/jettUpdraft/JettUpdraftRight.png new file mode 100644 index 0000000..0d02b5f Binary files /dev/null and b/assets/jettUpdraft/JettUpdraftRight.png differ diff --git a/assets/jettWalking/back left/JettBackLeftWalking1.png b/assets/jettWalking/back left/JettBackLeftWalking1.png new file mode 100644 index 0000000..107d49f Binary files /dev/null and b/assets/jettWalking/back left/JettBackLeftWalking1.png differ diff --git a/assets/jettWalking/back left/JettBackLeftWalking2.png b/assets/jettWalking/back left/JettBackLeftWalking2.png new file mode 100644 index 0000000..131d731 Binary files /dev/null and b/assets/jettWalking/back left/JettBackLeftWalking2.png differ diff --git a/assets/jettWalking/back left/JettBackLeftWalking3.png b/assets/jettWalking/back left/JettBackLeftWalking3.png new file mode 100644 index 0000000..c7d3522 Binary files /dev/null and b/assets/jettWalking/back left/JettBackLeftWalking3.png differ diff --git a/assets/jettWalking/back right/JettBackRightWalking1.png b/assets/jettWalking/back right/JettBackRightWalking1.png new file mode 100644 index 0000000..faece1e Binary files /dev/null and b/assets/jettWalking/back right/JettBackRightWalking1.png differ diff --git a/assets/jettWalking/back right/JettBackRightWalking2.png b/assets/jettWalking/back right/JettBackRightWalking2.png new file mode 100644 index 0000000..0f6726b Binary files /dev/null and b/assets/jettWalking/back right/JettBackRightWalking2.png differ diff --git a/assets/jettWalking/back right/JettBackRightWalking3.png b/assets/jettWalking/back right/JettBackRightWalking3.png new file mode 100644 index 0000000..500fe88 Binary files /dev/null and b/assets/jettWalking/back right/JettBackRightWalking3.png differ diff --git a/assets/jettWalking/back/JettBackWalking1.png b/assets/jettWalking/back/JettBackWalking1.png new file mode 100644 index 0000000..9e71b3a Binary files /dev/null and b/assets/jettWalking/back/JettBackWalking1.png differ diff --git a/assets/jettWalking/back/JettBackWalking2.png b/assets/jettWalking/back/JettBackWalking2.png new file mode 100644 index 0000000..468dfff Binary files /dev/null and b/assets/jettWalking/back/JettBackWalking2.png differ diff --git a/assets/jettWalking/back/JettBackWalking3.png b/assets/jettWalking/back/JettBackWalking3.png new file mode 100644 index 0000000..56ea722 Binary files /dev/null and b/assets/jettWalking/back/JettBackWalking3.png differ diff --git a/assets/jettWalking/front/JettFrontWalking1.png b/assets/jettWalking/front/JettFrontWalking1.png new file mode 100644 index 0000000..8a7928e Binary files /dev/null and b/assets/jettWalking/front/JettFrontWalking1.png differ diff --git a/assets/jettWalking/front/JettFrontWalking2.png b/assets/jettWalking/front/JettFrontWalking2.png new file mode 100644 index 0000000..b7def83 Binary files /dev/null and b/assets/jettWalking/front/JettFrontWalking2.png differ diff --git a/assets/jettWalking/front/JettFrontWalking3.png b/assets/jettWalking/front/JettFrontWalking3.png new file mode 100644 index 0000000..09cc59e Binary files /dev/null and b/assets/jettWalking/front/JettFrontWalking3.png differ diff --git a/assets/jettWalking/left/JettLeftWalking1.png b/assets/jettWalking/left/JettLeftWalking1.png new file mode 100644 index 0000000..7c15cb0 Binary files /dev/null and b/assets/jettWalking/left/JettLeftWalking1.png differ diff --git a/assets/jettWalking/left/JettLeftWalking2.png b/assets/jettWalking/left/JettLeftWalking2.png new file mode 100644 index 0000000..fd4ac8a Binary files /dev/null and b/assets/jettWalking/left/JettLeftWalking2.png differ diff --git a/assets/jettWalking/left/JettLeftWalking3.png b/assets/jettWalking/left/JettLeftWalking3.png new file mode 100644 index 0000000..96e8b78 Binary files /dev/null and b/assets/jettWalking/left/JettLeftWalking3.png differ diff --git a/assets/jettWalking/right/JettRightWalking1.png b/assets/jettWalking/right/JettRightWalking1.png new file mode 100644 index 0000000..01c83aa Binary files /dev/null and b/assets/jettWalking/right/JettRightWalking1.png differ diff --git a/assets/jettWalking/right/JettRightWalking2.png b/assets/jettWalking/right/JettRightWalking2.png new file mode 100644 index 0000000..d40954a Binary files /dev/null and b/assets/jettWalking/right/JettRightWalking2.png differ diff --git a/assets/jettWalking/right/JettRightWalking3.png b/assets/jettWalking/right/JettRightWalking3.png new file mode 100644 index 0000000..78fc747 Binary files /dev/null and b/assets/jettWalking/right/JettRightWalking3.png differ diff --git a/assets/jettWalkingGun/back left/JettBackLeftWalkingGun1.png b/assets/jettWalkingGun/back left/JettBackLeftWalkingGun1.png new file mode 100644 index 0000000..107d49f Binary files /dev/null and b/assets/jettWalkingGun/back left/JettBackLeftWalkingGun1.png differ diff --git a/assets/jettWalkingGun/back left/JettBackLeftWalkingGun2.png b/assets/jettWalkingGun/back left/JettBackLeftWalkingGun2.png new file mode 100644 index 0000000..131d731 Binary files /dev/null and b/assets/jettWalkingGun/back left/JettBackLeftWalkingGun2.png differ diff --git a/assets/jettWalkingGun/back left/JettBackLeftWalkingGun3.png b/assets/jettWalkingGun/back left/JettBackLeftWalkingGun3.png new file mode 100644 index 0000000..c7d3522 Binary files /dev/null and b/assets/jettWalkingGun/back left/JettBackLeftWalkingGun3.png differ diff --git a/assets/jettWalkingGun/back right/JettBackRightWalkingGun1.png b/assets/jettWalkingGun/back right/JettBackRightWalkingGun1.png new file mode 100644 index 0000000..faece1e Binary files /dev/null and b/assets/jettWalkingGun/back right/JettBackRightWalkingGun1.png differ diff --git a/assets/jettWalkingGun/back right/JettBackRightWalkingGun2.png b/assets/jettWalkingGun/back right/JettBackRightWalkingGun2.png new file mode 100644 index 0000000..0f6726b Binary files /dev/null and b/assets/jettWalkingGun/back right/JettBackRightWalkingGun2.png differ diff --git a/assets/jettWalkingGun/back right/JettBackRightWalkingGun3.png b/assets/jettWalkingGun/back right/JettBackRightWalkingGun3.png new file mode 100644 index 0000000..500fe88 Binary files /dev/null and b/assets/jettWalkingGun/back right/JettBackRightWalkingGun3.png differ diff --git a/assets/jettWalkingGun/back/JettBackWalkingGun1.png b/assets/jettWalkingGun/back/JettBackWalkingGun1.png new file mode 100644 index 0000000..8347c1d Binary files /dev/null and b/assets/jettWalkingGun/back/JettBackWalkingGun1.png differ diff --git a/assets/jettWalkingGun/back/JettBackWalkingGun2.png b/assets/jettWalkingGun/back/JettBackWalkingGun2.png new file mode 100644 index 0000000..30fa833 Binary files /dev/null and b/assets/jettWalkingGun/back/JettBackWalkingGun2.png differ diff --git a/assets/jettWalkingGun/back/JettBackWalkingGun3.png b/assets/jettWalkingGun/back/JettBackWalkingGun3.png new file mode 100644 index 0000000..c21a8d0 Binary files /dev/null and b/assets/jettWalkingGun/back/JettBackWalkingGun3.png differ diff --git a/assets/jettWalkingGun/front/JettFrontWalkingGun1.png b/assets/jettWalkingGun/front/JettFrontWalkingGun1.png new file mode 100644 index 0000000..3990727 Binary files /dev/null and b/assets/jettWalkingGun/front/JettFrontWalkingGun1.png differ diff --git a/assets/jettWalkingGun/front/JettFrontWalkingGun2.png b/assets/jettWalkingGun/front/JettFrontWalkingGun2.png new file mode 100644 index 0000000..78b4f97 Binary files /dev/null and b/assets/jettWalkingGun/front/JettFrontWalkingGun2.png differ diff --git a/assets/jettWalkingGun/front/JettFrontWalkingGun3.png b/assets/jettWalkingGun/front/JettFrontWalkingGun3.png new file mode 100644 index 0000000..5bf0acc Binary files /dev/null and b/assets/jettWalkingGun/front/JettFrontWalkingGun3.png differ diff --git a/assets/jettWalkingGun/left/JettLeftWalkingGun1.png b/assets/jettWalkingGun/left/JettLeftWalkingGun1.png new file mode 100644 index 0000000..ee391b8 Binary files /dev/null and b/assets/jettWalkingGun/left/JettLeftWalkingGun1.png differ diff --git a/assets/jettWalkingGun/left/JettLeftWalkingGun2.png b/assets/jettWalkingGun/left/JettLeftWalkingGun2.png new file mode 100644 index 0000000..a9a6da4 Binary files /dev/null and b/assets/jettWalkingGun/left/JettLeftWalkingGun2.png differ diff --git a/assets/jettWalkingGun/left/JettLeftWalkingGun3.png b/assets/jettWalkingGun/left/JettLeftWalkingGun3.png new file mode 100644 index 0000000..d701f23 Binary files /dev/null and b/assets/jettWalkingGun/left/JettLeftWalkingGun3.png differ diff --git a/assets/jettWalkingGun/right/JettRightWalkingGun1.png b/assets/jettWalkingGun/right/JettRightWalkingGun1.png new file mode 100644 index 0000000..c95a5ee Binary files /dev/null and b/assets/jettWalkingGun/right/JettRightWalkingGun1.png differ diff --git a/assets/jettWalkingGun/right/JettRightWalkingGun2.png b/assets/jettWalkingGun/right/JettRightWalkingGun2.png new file mode 100644 index 0000000..5bb93cc Binary files /dev/null and b/assets/jettWalkingGun/right/JettRightWalkingGun2.png differ diff --git a/assets/jettWalkingGun/right/JettRightWalkingGun3.png b/assets/jettWalkingGun/right/JettRightWalkingGun3.png new file mode 100644 index 0000000..46aa114 Binary files /dev/null and b/assets/jettWalkingGun/right/JettRightWalkingGun3.png differ diff --git a/assets/room/backgroundRoom1.png b/assets/room/backgroundRoom1.png new file mode 100644 index 0000000..bf9fa3d Binary files /dev/null and b/assets/room/backgroundRoom1.png differ diff --git a/assets/room/backgroundRoom2.png b/assets/room/backgroundRoom2.png new file mode 100644 index 0000000..87ea49b Binary files /dev/null and b/assets/room/backgroundRoom2.png differ diff --git a/assets/room/backgroundRoom3.png b/assets/room/backgroundRoom3.png new file mode 100644 index 0000000..d6a0523 Binary files /dev/null and b/assets/room/backgroundRoom3.png differ diff --git a/assets/room/backgroundRoom4.png b/assets/room/backgroundRoom4.png new file mode 100644 index 0000000..6d3a318 Binary files /dev/null and b/assets/room/backgroundRoom4.png differ diff --git a/assets/room/backgroundRoom5.png b/assets/room/backgroundRoom5.png new file mode 100644 index 0000000..14a92cd Binary files /dev/null and b/assets/room/backgroundRoom5.png differ diff --git a/assets/room/sign.png b/assets/room/sign.png new file mode 100644 index 0000000..46ec099 Binary files /dev/null and b/assets/room/sign.png differ diff --git a/assets/text/agentSelectionJett.png b/assets/text/agentSelectionJett.png new file mode 100644 index 0000000..236113c Binary files /dev/null and b/assets/text/agentSelectionJett.png differ diff --git a/assets/text/agentSelectionText.png b/assets/text/agentSelectionText.png new file mode 100644 index 0000000..97b7b4c Binary files /dev/null and b/assets/text/agentSelectionText.png differ diff --git a/assets/text/room1Text.png b/assets/text/room1Text.png new file mode 100644 index 0000000..9daf947 Binary files /dev/null and b/assets/text/room1Text.png differ diff --git a/assets/text/room2Text.png b/assets/text/room2Text.png new file mode 100644 index 0000000..ec06916 Binary files /dev/null and b/assets/text/room2Text.png differ diff --git a/assets/text/room3Text.png b/assets/text/room3Text.png new file mode 100644 index 0000000..7e1dee5 Binary files /dev/null and b/assets/text/room3Text.png differ diff --git a/assets/text/room4Text.png b/assets/text/room4Text.png new file mode 100644 index 0000000..69dcc58 Binary files /dev/null and b/assets/text/room4Text.png differ diff --git a/assets/text/room5Text.png b/assets/text/room5Text.png new file mode 100644 index 0000000..629a906 Binary files /dev/null and b/assets/text/room5Text.png differ diff --git a/main.py b/main.py index a5c44c6..20f86e2 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,10 @@ import pygame -#import your controller +from src.controller import Controller def main(): pygame.init() - #Create an instance on your controller object - #Call your mainloop - - ###### NOTHING ELSE SHOULD GO IN main(), JUST THE ABOVE 3 LINES OF CODE ###### - -# https://codefather.tech/blog/if-name-main-python/ + game_controller = Controller() + game_controller.mainloop() if __name__ == '__main__': main() + main() \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..0b657ed Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/__pycache__/controller.cpython-310.pyc b/src/__pycache__/controller.cpython-310.pyc new file mode 100644 index 0000000..d2c570a Binary files /dev/null and b/src/__pycache__/controller.cpython-310.pyc differ diff --git a/src/__pycache__/gun.cpython-310.pyc b/src/__pycache__/gun.cpython-310.pyc new file mode 100644 index 0000000..47fad5a Binary files /dev/null and b/src/__pycache__/gun.cpython-310.pyc differ diff --git a/src/__pycache__/jett.cpython-310.pyc b/src/__pycache__/jett.cpython-310.pyc new file mode 100644 index 0000000..568bc66 Binary files /dev/null and b/src/__pycache__/jett.cpython-310.pyc differ diff --git a/src/__pycache__/room.cpython-310.pyc b/src/__pycache__/room.cpython-310.pyc new file mode 100644 index 0000000..da9e5bd Binary files /dev/null and b/src/__pycache__/room.cpython-310.pyc differ diff --git a/src/controller.py b/src/controller.py new file mode 100644 index 0000000..35004c1 --- /dev/null +++ b/src/controller.py @@ -0,0 +1,290 @@ +import pygame +from src.jett import Jett +from src.room import gameController + +class Controller: + def __init__(self): + pygame.init() + self.screen_width = 1000 + self.screen_height = 600 + self.screen = pygame.display.set_mode((self.screen_width, self.screen_height)) + pygame.display.set_caption("Enter Valorant") + self.clock = pygame.time.Clock() + self.current_state = "menu" + self.jett = None + + self.dash_cooldown = 500 + self.smoke_cooldown = 600 + self.updraft_cooldown = 2000 + + self.last_dash_time = 0 + self.last_smoke_time = 0 + self.last_updraft_time = 0 + + self.game_controller = gameController() + self.current_room = self.game_controller.current_room.background_image + + self.start_time = 0 + self.best_times = [999,999.0] + + def mainloop(self): + while True: + if self.current_state == "menu": + self.menuloop() + elif self.current_state == "agent selection": + self.agentloop() + elif self.current_state == "game": + self.gameloop() + elif self.current_state == "gameover": + self.gameoverloop() + + def menuloop(self): + background_image = pygame.image.load("assets/background.png").convert() + background_image = pygame.transform.scale(background_image, (self.screen_width, self.screen_height)) + background_rect = background_image.get_rect() + + show_text = True + last_toggle_time = pygame.time.get_ticks() + blink_interval = 500 + + while self.current_state == "menu": + current_time = pygame.time.get_ticks() + if current_time - last_toggle_time >= blink_interval: + show_text = not show_text + last_toggle_time = current_time + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_SPACE: + self.current_state = "agent selection" + elif event.key == pygame.K_ESCAPE: + pygame.quit() + + self.screen.blit(background_image, background_rect) + + if show_text: + font = pygame.font.Font(None, 36) + text = font.render("Press SPACE to Start", True, "white") + text2 = font.render("Press ESCAPE to Quit", True, "white") + text_rect = text.get_rect(center=(200, 500)) + text2_rect = text2.get_rect(center = (200, 550)) + self.screen.blit(text, text_rect) + self.screen.blit(text2, text2_rect) + + pygame.display.flip() + self.clock.tick(60) + + def agentloop(self): + background_image = pygame.image.load("assets/agentSelection.png").convert() + background_image = pygame.transform.scale(background_image, (self.screen_width, self.screen_height)) + + text_box = pygame.image.load("assets/text/agentSelectionJett.png").convert() + sign_image = pygame.image.load("assets/room/sign.png").convert() + sign_image = pygame.transform.scale(sign_image, (sign_image.get_width() * 3, sign_image.get_height() * 3)) + sign_rect = sign_image.get_rect(center = (800, 250)) + + room_left = 20 + room_top = 0 + room_right = self.screen_width - 70 + room_bottom = self.screen_height - 90 + + self.enable_movement = False + + self.jett = Jett(speed = 3.5) + self.jett.x = 475 + self.jett.y = 250 + + while self.current_state == "agent selection": + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_RETURN: + self.enable_movement = True + elif event.key == pygame.K_ESCAPE: + self.current_state = "menu" + + if self.jett.x < room_left: + self.jett.x = room_left + if self.jett.x > room_right and self.jett.y < 200: + self.jett.x = room_right + if self.jett.x > room_right and self.jett.y > 275: + self.jett.x = room_right + if self.jett.y < room_top: + self.jett.y = room_top + if self.jett.y > room_bottom: + self.jett.y = room_bottom + + if self.jett.x > 950 and self.jett.y > 200 and self.jett.y < 275: + self.current_state = "game" + + if self.enable_movement: + self.jett.move() + self.jett.update_animation() + + self.screen.blit(background_image, (0,0)) + + sign_text = pygame.image.load("assets/text/agentSelectionText.png") + self.screen.blit(sign_image,sign_rect) + + if sign_rect.colliderect(self.jett.rect): + self.screen.blit(sign_text, (200, 475)) + + self.jett.drawCharacter(self.screen) + if not self.enable_movement: + self.screen.blit(text_box, (262.5, 450)) + pygame.display.flip() + self.clock.tick(60) + + def gameloop(self): + self.start_time = pygame.time.get_ticks() + + self.jett = Jett(speed=5) + + bullets = [] + + draw_gun = False + + self.game_controller.change_room(0) + current_room = self.game_controller.get_current_room() + + while self.current_state == "game": + for bullet in bullets: + for dummy_image, (dummy_x, dummy_y) in current_room.dummies: + dummy_rect = pygame.Rect(dummy_x, dummy_y, dummy_image.get_width(), dummy_image.get_height()) + if dummy_rect.colliderect(bullet.rect): + current_room.dummies.remove((dummy_image, (dummy_x, dummy_y))) + bullets.remove(bullet) + break + + for i in range(len(current_room.boundaries)): + start_pos = current_room.boundaries[i] + end_pos = current_room.boundaries[(i + 1) % len(current_room.boundaries)] + pygame.draw.line(self.screen, "black", start_pos, end_pos) + + background_image = pygame.image.load(current_room.background_image + ".png").convert() + screen_width, screen_height = self.screen.get_size() + scaled_background_image = pygame.transform.scale(background_image, (screen_width, screen_height)) + self.screen.blit(scaled_background_image, (0,0)) + + room_left = 20 + room_top = 20 + room_right = self.screen_width - 70 + room_bottom = self.screen_height - 90 + + if self.jett.x < room_left: + self.jett.x = room_left + if self.jett.x > room_right and self.jett.y < 200: + self.jett.x = room_right + if self.jett.x > room_right and self.jett.y > 275: + self.jett.x = room_right + if self.jett.y < room_top: + self.jett.y = room_top + if self.jett.y > room_bottom: + self.jett.y = room_bottom + + self.game_controller.update(self.jett) + self.game_controller.draw(self.screen, self.jett) + + if self.jett.updraft_timer: + self.jett.speed = 2 + + if self.jett.x + self.jett.width >= screen_width and self.jett.y > current_room.boundaries[1][1] and self.jett.y < current_room.boundaries[3][1]: + next_room_index = (self.game_controller.current_room_index + 1) % len(self.game_controller.rooms) + if next_room_index != self.game_controller.current_room_index: + self.game_controller.change_room(next_room_index) + current_room = self.game_controller.get_current_room() + self.jett.x = 0 + self.jett.reset_smoke_particles() + if next_room_index == len(self.game_controller.rooms) - 1: + self.current_state = "gameover" + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + elif event.type == pygame.KEYDOWN: + current_time = pygame.time.get_ticks() + if event.key == pygame.K_ESCAPE: + self.current_state = "agent selection" + elif event.key == pygame.K_e: + if current_time - self.last_dash_time >= self.dash_cooldown: + self.jett.dash() + self.last_dash_time = current_time + elif event.key == pygame.K_q: + current_time = pygame.time.get_ticks() + if current_time - self.last_updraft_time >= self.updraft_cooldown: + self.jett.updraft() + self.last_updraft_time = current_time + elif event.key == pygame.K_c: + current_time = pygame.time.get_ticks() + if current_time - self.last_smoke_time >= self.smoke_cooldown: + mouse_position = pygame.mouse.get_pos() + self.jett.smoke(mouse_position) + self.last_smoke_time = current_time + elif event.key == pygame.K_2: + draw_gun = True + self.jett.images = {key:[pygame.image.load(path) for path in paths] for key, paths in self.jett.image_paths_gun.items()} + self.jett.speed = 4.5 + elif event.key == pygame.K_3: + draw_gun = False + self.jett.images = {key: [pygame.image.load(path) for path in paths] for key, paths in self.jett.image_paths.items()} + self.jett.speed = 5 + elif event.type == pygame.MOUSEBUTTONDOWN: + if draw_gun and not self.jett.is_dashing and not self.jett.updraft_timer and current_time - self.last_smoke_time >= 500: + mouse_position = pygame.mouse.get_pos() + self.jett.look(mouse_position) + bullet = self.jett.shoot(mouse_position) + if bullet is not None: + bullets.append(bullet) + + self.jett.move() + self.jett.update(self.screen) + self.jett.drawCharacter(self.screen, draw_gun) + self.jett.draw_smoke(self.screen) + + for bullet in bullets: + bullet.move() + bullet.draw(self.screen) + + pygame.display.flip() + self.clock.tick(60) + + def gameoverloop(self): + end_time = pygame.time.get_ticks() + elapsed_time = float((end_time - self.start_time) // 1000) + + if elapsed_time < min(self.best_times): + self.best_times.append(elapsed_time) + + shortest_time = min(self.best_times) + + while self.current_state == "gameover": + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_RETURN: + self.current_state = "game" + elif event.key == pygame.K_ESCAPE: + self.current_state = "menu" + + self.screen.fill("black") + font = pygame.font.Font(None, 36) + text = font.render("Course Completed! Press ENTER to Restart, Press ESCAPE to Quit", True, "white") + time = font.render("Time: {} seconds".format(elapsed_time), True, "white") + + self.best_times.append(elapsed_time) + shortest_time = min(self.best_times) + + best = font.render("Best Time: {} seconds".format(shortest_time), True, "white") + text_rect = text.get_rect(center=(self.screen_width // 2, self.screen_height // 2)) + time_rect = time.get_rect(center=(self.screen_width // 2, self.screen_height // 2 + 25)) + best_rect = best.get_rect(center=(self.screen_width // 2, self.screen_height // 2 + 45)) + self.screen.blit(text, text_rect) + self.screen.blit(time, time_rect) + self.screen.blit(best, best_rect) + + pygame.display.flip() + self.clock.tick(60) \ No newline at end of file diff --git a/src/gun.py b/src/gun.py new file mode 100644 index 0000000..80a90cb --- /dev/null +++ b/src/gun.py @@ -0,0 +1,47 @@ +import pygame +import math + +class Classic: + def __init__(self): + self.damage = 26 + self.ammo = 12 + self.shooting_speed = 0.25 + self.last_shot_time = 0 + self.bullet_speed = 0 + + self.image = { + 'front' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'back' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'right' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'left' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'back right' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'back left' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'front right' : pygame.image.load("assets/gun/classic/classicRight.png"), + 'front left' : pygame.image.load("assets/gun/classic/classicRight.png") + } + + def shoot_bullet(self, start_pos, target_pos): + current_time = pygame.time.get_ticks() + if current_time - self.last_shot_time >= self.shooting_speed * 1000: + bullet = Bullet(start_pos, target_pos, self.damage) + self.last_shot_time = current_time + return bullet + return None + +class Bullet: + def __init__(self, start_pos, target_pos, damage): + self.x, self.y = start_pos + self.target_x, self.target_y = target_pos + self.damage = damage + self.speed = 20 + self.direction = math.atan2(self.target_y - self.y, self.target_x - self.x) + self.radius = 7.5 + self.rect = pygame.Rect(self.x - self.radius, self.y - self.radius, self.radius * 2, self.radius *2) + + def move(self): + self.x += self.speed * math.cos(self.direction) + self.y += self.speed * math.sin(self.direction) + self.rect.center = (self.x, self.y) + + def draw(self, screen): + pygame.draw.circle(screen, "white", (int(self.x), int(self.y)), self.radius) \ No newline at end of file diff --git a/src/jett.py b/src/jett.py new file mode 100644 index 0000000..19e25ea --- /dev/null +++ b/src/jett.py @@ -0,0 +1,325 @@ +import pygame +import math +from src.gun import Classic + +class Jett: + def __init__(self, speed): + self.speed = speed + self.gun = Classic() + self.gun_offset = (20, 0) + self.gun_angle = 270 + self.width = 16 + self.height = 24 + self.x = 25 + self.y = 250 + self.rect = pygame.Rect(self.x, self.y, self.width, self.height) + self.image_paths = { + 'front': ["assets/jettStanding/JettFront.png", "assets/jettWalking/front/JettFrontWalking1.png", "assets/jettWalking/front/JettFrontWalking2.png", "assets/jettWalking/front/JettFrontWalking3.png"], + 'back': ["assets/jettStanding/JettBack.png", "assets/jettWalking/back/JettBackWalking1.png", "assets/jettWalking/back/JettBackWalking2.png", "assets/jettWalking/back/JettBackWalking3.png"], + 'left': ["assets/jettStanding/JettLeft.png", "assets/jettWalking/left/JettLeftWalking1.png", "assets/jettWalking/left/JettLeftWalking2.png", "assets/jettWalking/left/JettLeftWalking3.png"], + 'right': ["assets/jettStanding/JettRight.png", "assets/jettWalking/right/JettRightWalking1.png", "assets/jettWalking/right/JettRightWalking2.png", "assets/jettWalking/right/JettRightWalking3.png"], + 'back right': ["assets/jettStanding/JettBackRight.png", "assets/jettWalking/back right/JettBackRightWalking1.png", "assets/jettWalking/back right/JettBackRightWalking2.png", "assets/jettWalking/back right/JettBackRightWalking3.png"], + 'back left': ["assets/jettStanding/JettBackLeft.png", "assets/jettWalking//back left/JettBackLeftWalking1.png", "assets/jettWalking//back left/JettBackLeftWalking2.png", "assets/jettWalking//back left/JettBackLeftWalking3.png"], + 'front right': ["assets/jettStanding/JettFront.png", "assets/jettWalking/front/JettFrontWalking1.png", "assets/jettWalking/front/JettFrontWalking2.png", "assets/jettWalking/front/JettFrontWalking3.png"], + 'front left': ["assets/jettStanding/JettFront.png", "assets/jettWalking/front/JettFrontWalking1.png", "assets/jettWalking/front/JettFrontWalking2.png", "assets/jettWalking/front/JettFrontWalking3.png"] + } + + self.images = {key: [pygame.image.load(path) for path in paths] for key, paths in self.image_paths.items()} + + self.direction = 'front' + self.is_walking = False + self.is_dashing = False + self.dash_distance = 30 + self.dash_speed = 100 + self.dash_timer = 0 + + self.dash_images = { + 'front': pygame.image.load("assets/jettDashing/JettDashFront.png"), + 'back': pygame.image.load("assets/jettDashing/JettDashBack.png"), + 'left': pygame.image.load("assets/jettDashing/JettDashLeft.png"), + 'right': pygame.image.load("assets/jettDashing/JettDashRight.png"), + 'back right': pygame.image.load("assets/jettDashing/JettDashBackRight.png"), + 'back left': pygame.image.load("assets/jettDashing/JettDashBackLeft.png"), + 'front right': pygame.image.load("assets/jettDashing/JettDashRight.png"), + 'front left': pygame.image.load("assets/jettDashing/JettDashLeft.png") + } + + self.updraft_images = { + 'front': pygame.image.load("assets/jettUpdraft/JettUpdraftRight.png"), + 'back' : pygame.image.load("assets/jettUpdraft/JettUpdraftRight.png"), + 'left': pygame.image.load("assets/jettUpdraft/JettUpdraftLeft.png"), + 'right': pygame.image.load("assets/jettUpdraft/JettUpdraftRight.png"), + 'back right': pygame.image.load("assets/jettUpdraft/JettUpdraftRight.png"), + 'back left': pygame.image.load("assets/jettUpdraft/JettUpdraftLeft.png"), + 'front right': pygame.image.load("assets/jettUpdraft/JettUpdraftRight.png"), + 'front left': pygame.image.load("assets/jettUpdraft/JettUpdraftLeft.png") + } + + self.throw_smoke_images = { + 'front': pygame.image.load("assets/jettSmoke/JettSmokeFront.png"), + 'back' : pygame.image.load("assets/jettSmoke/JettSmokeBack.png"), + 'left': pygame.image.load("assets/jettSmoke/JettSmokeLeft.png"), + 'right': pygame.image.load("assets/jettSmoke/JettSmokeRight.png"), + 'back right': pygame.image.load("assets/jettSmoke/JettSmokeBackRight.png"), + 'back left': pygame.image.load("assets/jettSmoke/JettSmokeBackLeft.png"), + 'front right': pygame.image.load("assets/jettSmoke/JettSmokeRight.png"), + 'front left': pygame.image.load("assets/jettSmoke/JettSmokeLeft.png") + } + + self.image_paths_gun = { + 'front': ["assets/jettStandingGun/JettFrontGun.png", "assets/jettWalkingGun/front/JettFrontWalkingGun1.png", "assets/jettWalkingGun/front/JettFrontWalkingGun2.png", "assets/jettWalkingGun/front/JettFrontWalkingGun3.png"], + 'back': ["assets/jettStandingGun/JettBackGun.png", "assets/jettWalkingGun/back/JettBackWalkingGun1.png", "assets/jettWalkingGun/back/JettBackWalkingGun2.png", "assets/jettWalkingGun/back/JettBackWalkingGun3.png"], + 'left': ["assets/jettStandingGun/JettLeftGun.png", "assets/jettWalkingGun/left/JettLeftWalkingGun1.png", "assets/jettWalkingGun/left/JettLeftWalkingGun2.png", "assets/jettWalkingGun/left/JettLeftWalkingGun3.png"], + 'right': ["assets/jettStandingGun/JettRightGun.png", "assets/jettWalkingGun/right/JettRightWalkingGun1.png", "assets/jettWalkingGun/right/JettRightWalkingGun2.png", "assets/jettWalkingGun/right/JettRightWalkingGun3.png"], + 'back right': ["assets/jettStandingGun/JettBackRightGun.png", "assets/jettWalkingGun/back right/JettBackRightWalkingGun1.png", "assets/jettWalkingGun/back right/JettBackRightWalkingGun2.png", "assets/jettWalkingGun/back right/JettBackRightWalkingGun3.png"], + 'back left': ["assets/jettStandingGun/JettBackLeftGun.png", "assets/jettWalkingGun//back left/JettBackLeftWalkingGun1.png", "assets/jettWalkingGun/back left/JettBackLeftWalkingGun2.png", "assets/jettWalkingGun/back left/JettBackLeftWalkingGun3.png"], + 'front right': ["assets/jettStandingGun/JettFrontGun.png", "assets/jettWalkingGun/front/JettFrontWalkingGun1.png", "assets/jettWalkingGun/front/JettFrontWalkingGun2.png", "assets/jettWalkingGun/front/JettFrontWalkingGun3.png"], + 'front left': ["assets/jettStandingGun/JettFrontGun.png", "assets/jettWalkingGun/front/JettFrontWalkingGun1.png", "assets/jettWalkingGun/front/JettFrontWalkingGun2.png", "assets/jettWalkingGun/front/JettFrontWalkingGun3.png"] + } + + self.gun_offset = { + 'front': (45, 60), + 'back': (40, 40), + 'left': (0, 55), + 'right': (45,55), + 'back right': (15, 50), + 'back left': (40, 50), + 'front right': (20, 0), + 'front left': (20,0) + } + + self.smoke_image = pygame.image.load("assets/jettSmoke/SmokeBall.png") + self.smoke_speed = 10 + self.smoke_particles = [] + self.last_smoke_trigger_time = 0 + + self.current_frame = 0 + self.animation_speed = 0.25 + self.last_update_time = pygame.time.get_ticks() + + self.updraft_timer = None + + def drawCharacter(self, screen, draw_gun = False): + current_time = pygame.time.get_ticks() + keys = pygame.key.get_pressed() + + is_any_movement_key_pressed = any(keys[key] for key in [pygame.K_a, pygame.K_d, pygame.K_w, pygame.K_s]) + + if self.is_dashing: + if self.direction in self.dash_images: + dash_image = self.dash_images[self.direction] + scaled_dash_image = pygame.transform.scale(dash_image, (self.width * 3, self.height * 2.5)) + screen.blit(scaled_dash_image, (self.x, self.y)) + elif self.updraft_timer: + updraft_sprite = self.updraft_images[self.direction] + scaled_sprite = pygame.transform.scale(updraft_sprite, (self.width * 3, self.height * 2.5)) + screen.blit(scaled_sprite, (self.x, self.y)) + elif is_any_movement_key_pressed: + current_image_list = self.images.get(self.direction) + if current_image_list: + current_image = current_image_list[self.current_frame] + scaled_image = pygame.transform.scale(current_image, (self.width * 3, self.height * 3)) + screen.blit(scaled_image, (self.x, self.y)) + elif current_time - self.last_smoke_trigger_time < 500: + if self.smoke_particles: + smoke_image = self.throw_smoke_images[self.direction] + scaled_smoke_image = pygame.transform.scale(smoke_image, (self.width * 3, self.height * 3)) + screen.blit(scaled_smoke_image, (self.x, self.y)) + + else: + current_image_list = self.images.get(self.direction) + if current_image_list: + current_image = current_image_list[0] + scaled_image = pygame.transform.scale(current_image, (self.width * 3, self.height * 3)) + screen.blit(scaled_image, (self.x, self.y)) + + if draw_gun and not self.is_dashing and not self.updraft_timer and not (current_time - self.last_smoke_trigger_time < 500): + gun_image = pygame.transform.rotate(self.gun.image[self.direction], -self.gun_angle) + if self.direction in ['left', 'back left', 'front left']: + gun_image = pygame.transform.rotate(pygame.transform.flip(pygame.image.load("assets/gun/classic/classicLeft.png"), True, True), -self.gun_angle) + gun_rect = gun_image.get_rect(center = (self.x + self.gun_offset.get(self.direction, (0,0))[0], self.y + self.gun_offset.get(self.direction, (0,0))[1])) + screen.blit(gun_image, gun_rect) + + def move(self): + keys = pygame.key.get_pressed() + + is_any_movement_key_pressed = any(keys[key] for key in [pygame.K_a, pygame.K_d, pygame.K_w, pygame.K_s]) + + self.is_walking = is_any_movement_key_pressed + + if not self.is_dashing: + if keys[pygame.K_a]: + self.x -= self.speed + self.direction = 'left' + if keys[pygame.K_d]: + self.x += self.speed + self.direction = 'right' + if keys[pygame.K_w]: + self.y -= self.speed + self.direction = 'back' + if keys[pygame.K_s]: + self.y += self.speed + self.direction = 'front' + + if keys[pygame.K_w] and keys[pygame.K_d]: + self.direction = 'back right' + if keys[pygame.K_w] and keys[pygame.K_a]: + self.direction = 'back left' + if keys[pygame.K_s] and keys[pygame.K_a]: + self.direction = 'front left' + if keys[pygame.K_s] and keys[pygame.K_d]: + self.direction = 'front right' + + self.rect = pygame.Rect(self.x, self.y, self.width, self.height) + + def look(self, mouse_position): + dx = mouse_position[0] - (self.x + self.gun_offset.get(self.direction, (0, 0))[0]) + dy = mouse_position[1] - (self.y + self.gun_offset.get(self.direction, (0, 0))[1]) + self.gun_angle = math.degrees(math.atan2(dy,dx)) + angle = math.atan2(dy, dx) + angle_degrees = math.degrees(angle) + + if -22.5 < angle_degrees <= 45: + self.direction = 'right' + elif 45 < angle_degrees <= 135: + self.direction = 'front' + elif 135 < angle_degrees <= 202.5: + self.direction = 'left' + elif -157.5 < angle_degrees <= -112.5: + self.direction = 'back left' + elif -112.5 < angle_degrees <= -67.5: + self.direction = 'back' + elif -67.5 < angle_degrees <= -22.5: + self.direction = 'back right' + + def shoot(self, mouse_position): + start_pos = (self.x + self.gun_offset.get(self.direction, (0, 0))[0], self.y + self.gun_offset.get(self.direction, (0, 0))[1]) + target_pos = mouse_position + bullet = self.gun.shoot_bullet(start_pos, target_pos) + return bullet + + def dash(self): + if not self.is_dashing: + self.is_dashing = True + self.dash_timer = pygame.time.get_ticks() + + def updraft(self): + if not self.updraft_timer: + self.is_dashing = False + self.updraft_timer = pygame.time.get_ticks() + + def smoke(self, mouse_position): + current_time = pygame.time.get_ticks() + if current_time - self.last_smoke_trigger_time >= 500: + self.last_smoke_trigger_time = current_time + + click_x, click_y = mouse_position + start_pos = (self.x, self.y) + + dx = click_x - start_pos[0] + dy = click_y - start_pos[1] + distance = math.sqrt(dx ** 2 + dy ** 2) + + unit_x = dx / distance + unit_y = dy / distance + + target_pos = (start_pos[0] + unit_x * 250, start_pos[1] + unit_y * 250) + + self.smoke_particles.append({ + "position": start_pos, + "target": target_pos, + "velocity": (unit_x * self.smoke_speed, unit_y * self.smoke_speed), + "scale_factor": 1.0, + "max_scale_factor": 2.0, + "lifespan": 300 + }) + + self.look(target_pos) + + def update(self, screen): + self.rect = pygame.Rect(self.x, self.y, self.width, self.height) + current_time = pygame.time.get_ticks() + if current_time - self.last_update_time > self.animation_speed * 1000: + self.last_update_time = current_time + self.current_frame = (self.current_frame + 1) % len(self.images[self.direction]) + + if self.is_dashing: + current_time = pygame.time.get_ticks() + elapsed_time = current_time - self.dash_timer + + if elapsed_time < self.dash_distance / self.dash_speed * 1000: + move_distance = self.dash_speed * (elapsed_time / 1000) + + if self.direction == 'front': + self.y += move_distance + elif self.direction == 'back': + self.y -= move_distance + elif self.direction == 'left': + self.x -= move_distance + elif self.direction == 'right': + self.x += move_distance + elif self.direction == 'back left': + self.x -= move_distance / math.sqrt(2) + self.y -= move_distance / math.sqrt(2) + elif self.direction == 'back right': + self.x += move_distance / math.sqrt(2) + self.y -= move_distance / math.sqrt(2) + elif self.direction == 'front left': + self.x -= move_distance / math.sqrt(2) + self.y += move_distance / math.sqrt(2) + elif self.direction == 'front right': + self.x += move_distance / math.sqrt(2) + self.y += move_distance / math.sqrt(2) + else: + self.is_dashing = False + elif self.updraft_timer: + current_time = pygame.time.get_ticks() + elapsed_time = current_time - self.updraft_timer + if elapsed_time < 400: + self.y -= 4 + elif elapsed_time < 2000: + self.y += 1 + else: + self.speed = 5 + self.is_dashing = False + self.updraft_timer = None + for smoke_particle in self.smoke_particles: + if smoke_particle["lifespan"] > 0: + if not smoke_particle.get("stopped", False): + smoke_particle["position"] = (smoke_particle["position"][0] + smoke_particle["velocity"][0], + smoke_particle["position"][1] + smoke_particle["velocity"][1]) + smoke_particle["lifespan"] -= 1 + + if math.hypot(smoke_particle["position"][0] - smoke_particle["target"][0], + smoke_particle["position"][1] - smoke_particle["target"][1]) < 5: + smoke_particle["stopped"] = True + smoke_particle["velocity"] = (0, 0) + else: + if smoke_particle["scale_factor"] < smoke_particle["max_scale_factor"]: + smoke_particle["scale_factor"] = min(smoke_particle["scale_factor"] + 0.02, + smoke_particle["max_scale_factor"]) + + scaled_smoke_image = pygame.transform.scale(self.smoke_image, + (int(self.smoke_image.get_width() * smoke_particle["scale_factor"]), + int(self.smoke_image.get_height() * smoke_particle["scale_factor"]))) + screen.blit(scaled_smoke_image, smoke_particle["position"]) + + smoke_particle["lifespan"] -= 1 + if smoke_particle["lifespan"] <= 0: + self.smoke_particles.remove(smoke_particle) + + def draw_smoke(self, screen): + for smoke_particle in self.smoke_particles: + scaled_smoke_image = pygame.transform.scale(self.smoke_image, + (int(self.smoke_image.get_width() * smoke_particle["scale_factor"]), + int(self.smoke_image.get_height() * smoke_particle["scale_factor"]))) + screen.blit(scaled_smoke_image, smoke_particle["position"]) + + def update_animation(self): + current_time = pygame.time.get_ticks() + if current_time - self.last_update_time > self.animation_speed * 1000: + self.last_update_time = current_time + self.current_frame = (self.current_frame + 1) % len(self.images[self.direction]) + + def reset_smoke_particles(self): + self.smoke_particles = [] \ No newline at end of file diff --git a/src/room.py b/src/room.py new file mode 100644 index 0000000..cc49c64 --- /dev/null +++ b/src/room.py @@ -0,0 +1,117 @@ +import pygame +import random + +class Room: + def __init__(self, background_image, boundaries, obstacles = None, signs = None, text_image = None, dummy = None): + self.background_image = background_image + self.boundaries = boundaries + self.obstacles = obstacles if obstacles else [] + self.signs = signs if signs else [] + self.text_image = text_image + self.dummy = dummy + self.collision_rects = [] + self.dummies = [] + + for obstacle in self.obstacles: + if obstacle == "pit": + self.collision_rects.append(pygame.Rect(760, 20, 130, 560)) + if obstacle == "wall": + self.collision_rects.append(pygame.Rect(820, 20, 40, 560)) + if obstacle == "big pit": + self.collision_rects.append(pygame.Rect(520, 20, 300, 560)) + + for start_pos, end_pos in zip(boundaries, boundaries[1:] + [boundaries[0]]): + self.collision_rects.append(pygame.Rect(start_pos[0], start_pos[1], end_pos[0] - start_pos[0], end_pos[1] - start_pos[1])) + +class gameController: + def __init__(self): + self.current_room = None + self.rooms = [ + Room(background_image="assets/room/backgroundRoom1", boundaries=[(0, 0), (1000, 0), (1000, 600), (0, 600)], obstacles = ["pit"], signs = [pygame.Rect(650, 200, 50, 100)], text_image="assets/text/room1Text.png"), + Room(background_image="assets/room/backgroundRoom2", boundaries=[(0, 0), (1000, 0), (1000, 600), (0, 600)], obstacles = ["wall"], signs = [pygame.Rect(750, 200, 50, 100)], text_image="assets/text/room2Text.png"), + Room(background_image="assets/room/backgroundRoom3", boundaries=[(0, 0), (1000, 0), (1000, 600), (0, 600)], obstacles = ["big pit"], signs = [pygame.Rect(450, 200, 50, 100)], text_image="assets/text/room3Text.png"), + Room(background_image="assets/room/backgroundRoom4", boundaries=[(0, 0), (1000, 0), (1000, 600), (0, 600)], signs = [pygame.Rect(150, 200, 50, 100)], text_image="assets/text/room4Text.png"), + Room(background_image="assets/room/backgroundRoom5", boundaries=[(0, 0), (1000, 0), (1000, 600), (0, 600)], signs = [pygame.Rect(150, 200, 50, 100)], text_image="assets/text/room5Text.png", dummy = "assets/dummy.png"), + Room(background_image="assets/room/backgroundRoom1", boundaries=[(0, 0), (1000, 0), (1000, 600), (0, 600)]) + ] + + self.current_room_index = 0 # Start with the first room + self.change_room(0) + + def change_room(self, room_index): + self.current_room_index = room_index + self.current_room = self.rooms[room_index] + + if room_index == 4: + self.spawn_dummies(3) + + def get_current_room(self): + return self.current_room + + def spawn_dummies(self, num_dummies): + current_room = self.get_current_room() + dummy_images = [] + dummy_positions = [] + + dummy_image = pygame.image.load(current_room.dummy) + dummy_width = dummy_image.get_width() + dummy_height = dummy_image.get_height() + scaled_width = dummy_width * 2 + scaled_height = dummy_height * 2 + + available_area = (current_room.boundaries[1][0] - dummy_width, current_room.boundaries[2][1] - dummy_height) + + for i in range(num_dummies): + x = random.randint(current_room.boundaries[0][0], available_area[0]) + y = random.randint(current_room.boundaries[0][1], available_area[1]) + dummy_positions.append((x,y)) + scaled_dummy_image = pygame.transform.scale(dummy_image, (scaled_width, scaled_height)) + dummy_images.append(scaled_dummy_image) + + current_room.dummies = list(zip(dummy_images, dummy_positions)) + + def update(self, jett): + current_room = self.get_current_room() + + if current_room.dummies: + if jett.x > 950: + jett.x = 950 + + for obstacle_rect in current_room.collision_rects: + if obstacle_rect.colliderect(jett.rect): + if "pit" in current_room.obstacles and not jett.is_dashing and not jett.updraft_timer: + jett.x = 25 + jett.y = 250 + elif "wall" in current_room.obstacles and not jett.updraft_timer: + if jett.direction == 'right': + jett.x = 800 + elif jett.direction == 'left': + jett.x = 865 + elif "big pit" in current_room.obstacles and not jett.is_dashing and not jett.updraft_timer: + jett.x = 25 + jett.y = 250 + break + + def draw(self, screen, jett): + current_room = self.get_current_room() + + for sign_rect in current_room.signs: + sign_image = pygame.image.load("assets/room/sign.png") + sign_image = pygame.transform.scale(sign_image, (sign_image.get_width() * 3, sign_image.get_height() * 3)) + screen.blit(sign_image, sign_rect) + + for dummy_image, (x, y) in current_room.dummies: + screen.blit(dummy_image, (x, y)) + + for sign_rect in current_room.signs: + if sign_rect.colliderect(jett.rect): + if current_room.text_image: + text_image = pygame.image.load(current_room.text_image) + screen.blit(text_image, (175, 425)) + break + + def main_loop(self): + while True: + self.handle_input() + self.update() + self.draw() \ No newline at end of file diff --git a/src/sample_controller.py b/src/sample_controller.py deleted file mode 100644 index 665b6ca..0000000 --- a/src/sample_controller.py +++ /dev/null @@ -1,33 +0,0 @@ - -class Controller: - - def __init__(self): - #setup pygame data - - def mainloop(self): - #select state loop - - - ### below are some sample loop states ### - - def menuloop(self): - - #event loop - - #update data - - #redraw - - def gameloop(self): - #event loop - - #update data - - #redraw - - def gameoverloop(self): - #event loop - - #update data - - #redraw