Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Main_char_jumping #13

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
10f8db3
Update game_state_manager.py
Mathuran-Mang Feb 4, 2021
6a08984
Merge pull request #1 from PHI-WLU/development
Mathuran-Mang Feb 28, 2021
27ef229
Merge pull request #1 from PHI-WLU/development
jon-obrien Feb 28, 2021
4b23e7b
Merge pull request #2 from PHI-WLU/development
brandencmw Mar 4, 2021
0efdb2d
Merge pull request #3 from brandencmw/development
brandencmw Mar 4, 2021
3785c9c
Update physics.py
brandencmw Mar 4, 2021
a96269e
Update physics.py
brandencmw Mar 4, 2021
c5920dc
Created Camera.py
NishTewari Mar 7, 2021
17d941a
Merge pull request #10 from brandencmw/physics-system
SherRao Mar 7, 2021
13d8c4f
Merge pull request #11 from XSilviaX/development
SherRao Mar 7, 2021
bb918bf
Merge pull request #2 from PHI-WLU/development
jon-obrien Mar 9, 2021
ce9dfb5
Merge pull request #3 from jobrien99/development
jon-obrien Mar 9, 2021
a2065d3
Tile and Level
jon-obrien Mar 9, 2021
a075453
Merge branch 'level' of https://github.com/jobrien99/PHI-Game into level
jon-obrien Mar 9, 2021
30d5e4b
Merge pull request #12 from jobrien99/level
SherRao Mar 14, 2021
163873c
Merge pull request #4 from PHI-WLU/development
brandencmw Mar 17, 2021
647bf8f
Merge pull request #2 from LaurierCS/development
Mathuran-Mang Mar 20, 2021
b3acdd3
Update physics.py
brandencmw Mar 20, 2021
4b4f25e
Merge pull request #5 from brandencmw/physics-methods
brandencmw Mar 20, 2021
8d41a6c
Merge pull request #14 from brandencmw/development
SherRao Mar 21, 2021
85b04aa
Added some player sprites
SherRao Mar 21, 2021
658a591
Merge branch 'development' of https://github.com/LaurierCS/PHI-Game i…
SherRao Mar 21, 2021
5f56e18
Merge pull request #6 from LaurierCS/development
brandencmw Mar 22, 2021
fdb98d7
Uploaded new main menu background images
SherRao Mar 24, 2021
22838c9
Merge pull request #3 from LaurierCS/development
Mathuran-Mang Mar 25, 2021
977fdb5
Update physics.py
Mathuran-Mang Mar 27, 2021
5253939
Merge pull request #18 from Mathuran-Mang/physics_system
SherRao Mar 28, 2021
790c778
Merge pull request #1 from LaurierCS/development
aidantrabs Mar 28, 2021
0ae7ac8
added enemy object and functionalities
aidantrabs Mar 28, 2021
9e912ba
Merge pull request #4 from LaurierCS/development
jon-obrien Mar 28, 2021
e4357ba
Merge pull request #5 from jobrien99/development
jon-obrien Mar 28, 2021
6167b01
Merge pull request #20 from aidantrabs/development
SherRao Mar 28, 2021
809c58e
Deleted compiled Python code
SherRao Mar 28, 2021
7d2d010
Added collision detection to player
brandencmw Mar 28, 2021
d3fe5d6
Merge pull request #7 from brandencmw/collision-detection
brandencmw Mar 28, 2021
00e7227
Merge pull request #6 from LaurierCS/development
jon-obrien Mar 28, 2021
f2700ec
Updated level class and tile class
jon-obrien Mar 28, 2021
59917bf
Updated the gun animation
SherRao Mar 29, 2021
fde97a1
Merge branch 'development' of https://github.com/LaurierCS/PHI-Game i…
SherRao Mar 29, 2021
4dde2c5
Merge pull request #22 from jobrien99/level
SherRao Apr 9, 2021
8e6acde
Merge pull request #21 from brandencmw/development
SherRao Apr 9, 2021
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
Binary file added assets/menu/background-1.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/menu/background-2.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/menu/background-3.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/player/jumping.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/player/walking.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/player/walking_gun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pygame

vec = pygame.math.Vector2 #vec 2 class from pygame.math
from abc import ABC #Abstract base class


class Camera:

def __init__(self, player):
self.player = player #Reference player
self.offset = vec(0,0) #Offset values to set the camera
self.offset_float = vec(0,0)
self.DISPLAY_width, self.DISPLAY_height = 100,100 # Height and Width displa [Numbers to be TBD]
self.CONST = vec(0,0) #TBD


def setmethod(self,method):
self.method = method

def scroll(self):
self.method.scroll()


def __init__(self, camera,player):
self.camera = camera
self.player = player

class CamScroll(ABC):
def __init__(self, camera,player):
self.camera = camera
self.player = player

@abstractmethod
def scroll(self):
pass


class Follow(CamScroll):
def __init__(self, camera, player):
CamScroll.__init__(self, camera, player)

def scroll(self):
self.camera.offset_float.x += (self.player.rect.x - self.camera.offset_float.x + self.camera.CONST.x)
self.camera.offset_float.y += (self.player.rect.y - self.camera.offset_float.y + self.camera.CONST.y)
self.camera.offset.x, self.camera.offset.y = int(self.camera.offset_float.x), int(self.camera.offset_float.y)

215 changes: 215 additions & 0 deletions enemy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import pygame
import level
import math

class Enemy(pygame.sprite.Sprite):

"""
Represents an Enemy within the Game State System.

Can move, jump, kill (soon), die; follows player

Attributes
----------
PyGame Sprite - controllable object


Methods
----------
__init__():
Program initialisation.

update():
Updates state.

draw():
Draws images onto game panel.

attack():
Attack method of enemy.

die():
Kills enemy based on health.

"""

def __init__(self):

"""
Initialization of all variables and Sprite.

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""

pygame.sprite.Sprite.__init__(self)

self.rect = self.image.get_rect()

self.rect.x = 0 #Adjust to spawn randomly - need screen size
self.rect.y = 0

#check level and adjust velocity and acceleration accordingly - static for now
self.xVel = 0
self.yVel = 0

#Implement acceleration based on levels eventually
self.xAccel = 0
self.yAccel = 0

self.jumping = False
self.falling = True

#Initializations to be implemented later on
self.health = 0
self.difficulty = 0


def follow_player(self, player):

"""
Basic algorithm to follow player
- ghetto version
- will implement a better one using vectors

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""

if self.rect.x >= player.x:
self.rect.x -= self.xVel

if self.rect.x < player.x:
self.rect.x += self.xVel

return

def load_images(self):

"""
Loads images onto frame to be drawn.

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""

return

def draw(self):

"""
Draws onto game panel and updates screen.

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""

return

def attack(self):

"""
Implements attack functionality for enemy.

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""

#Check proximity of player to enemy first

#Check level for attack attributes

#Determine damange level based on level

#Update weapon images

return

def die(self):

"""
Checks if enemy health is zero and updates sprite for level.

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""

if self.health < 1:
pass #To be implemented later on

return

def update(self):

"""
Updates game logic, enemy movement and mechanics.

Parameters
----------
None

Raises
----------
None

Authors
----------
Aidan Traboulay
"""


return
7 changes: 7 additions & 0 deletions game_state_manager.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
from state import State


def update(self):
self.current_state.update()
self.clock.tick(self.target_fps)


Loading