generated from acm-ndsu/byte_le_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created moving object * Added number checking to moving object, and tests. Fixed from_json for moving object * Added some comments * add player object * added proper super init call and finish to and from json methods * reformatting code to align with pep8 * reformatting more code to align with pep8 * changed player to shooter, added list generation for visible and inventory to_json * add to_json call for visible list in to_json() * change to collidable = True upon further thought, it's better than a comment Co-authored-by: Sean Hagen <[email protected]>
- Loading branch information
1 parent
bafc387
commit a7da072
Showing
5 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from game.common.moving.moving_object import MovingObject | ||
from game.common.stats import GameStats | ||
from game.common.enums import * | ||
|
||
|
||
class Shooter(MovingObject): | ||
def __init__(self, heading=0, speed=0, coordinates=GameStats.player_stats['starting_coordinates']): | ||
super().__init__( | ||
heading, | ||
speed, | ||
GameStats.player_stats['starting_health'], | ||
coordinates, | ||
GameStats.player_stats['hitbox'], | ||
collidable = True | ||
) | ||
self.object_type = ObjectType.shooter | ||
self.inventory = [] | ||
self.money = GameStats.player_stats['starting_money'] | ||
self.armor = None | ||
self.visible = [] | ||
self.view_radius = GameStats.player_stats['view_radius'] | ||
self.moving = False | ||
|
||
# set the heading and direction in a controlled way, might need to add distance attribute later | ||
def move(self, heading): | ||
super().set_heading(heading) | ||
super().set_speed(GameStats.player_stats['move_speed']) | ||
self.moving = True | ||
|
||
def stop(self): | ||
super().set_speed(0) | ||
self.moving = False | ||
|
||
def to_json(self): | ||
data = super().to_json() | ||
|
||
data['inventory'] = [item.to_json() for item in self.inventory] | ||
data['visible'] = [obj.to_json() for obj in self.visible] | ||
|
||
data['money'] = self.money | ||
data['armor'] = self.armor | ||
data['view_radius'] = self.view_radius | ||
data['moving'] = self.moving | ||
|
||
return data | ||
|
||
def from_json(self, data): | ||
super().from_json(data) | ||
self.inventory = data['inventory'] | ||
self.money = data['money'] | ||
self.armor = data['armor'] | ||
self.visible = data['visible'] | ||
self.view_radius = data['view_radius'] | ||
self.moving = data['moving'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters