remove config excess, add projectiles folder and temp classes

This commit is contained in:
Lief9100
2020-04-20 02:58:32 -07:00
committed by Cameron Smart
parent b06fcaf0f8
commit c051414870
3 changed files with 43 additions and 10 deletions

View File

@@ -29,7 +29,6 @@ class Config(object):
# Constants used to scale our sprites from their original size
CHARACTER_SCALING = 1
TILE_SCALING = 2
BULLET_SCALING = 0.8
# The number of pixels across the level
LEVEL_SIZE = 10 * TILE_SCALING * TILE_WIDTH
@@ -42,9 +41,6 @@ class Config(object):
RIGHT_VIEWPORT_MARGIN = 250
BOTTOM_VIEWPORT_MARGIN = 50
TOP_VIEWPORT_MARGIN = 100
#Bullet constants TEMP change to speed factor in projectiles.py
BULLET_SPEED = 5

View File

@@ -10,8 +10,9 @@ import math
from config import Config
from map import Dungeon
from mobs import Player
from mobs import Player, Enemy
from config import Config, Sprites
from projectiles import Temp
class Game(arcade.Window):
"""
@@ -125,8 +126,7 @@ class Game(arcade.Window):
Called whenever the mouse is clicked.
"""
# Create a bullet TEMP SPRITE, currently wielding frog slingshot
bullet = arcade.Sprite("resources/images/monsters/frog/frog1.png", Config.BULLET_SCALING)
bullet = Temp()
# Position the bullet at the player's current location
start_x = self.player_list.center_x
start_y = self.player_list.center_y
@@ -149,8 +149,8 @@ class Game(arcade.Window):
# Taking into account the angle, calculate our change_x
# and change_y. Velocity is how fast the bullet travels.
bullet.change_x = math.cos(angle) * Config.BULLET_SPEED
bullet.change_y = math.sin(angle) * Config.BULLET_SPEED
bullet.change_x = math.cos(angle) * bullet.speed
bullet.change_y = math.sin(angle) * bullet.speed
# Add the bullet to the appropriate lists
self.bullet_list.append(bullet)

View File

@@ -0,0 +1,37 @@
"""
projectiles.py
Organizes classes related to projectiles
"""
import arcade
from config import Config, Sprites
class Projectile(arcade.Sprite):
"""
Represents a Projectile. Damage, sprite, speed, range, collision list?
"""
def __init__(self, speed=7, damage=0, range=100, *args, **kwargs) -> None:
# Set up parent class
super().__init__()
self.speed = speed
self.damage = damage #unimplemented
self.texture = None
self.range = range #unimplemented
self.collision_list = []
class Temp(Projectile):
"""
Temporary extension of projectile to demonstrate usage
"""
def __init__(self, *args, **kwargs) -> None:
super(Temp, self).__init__(*args, **kwargs)
self.texture = arcade.load_texture("resources/images/monsters/frog/frog1.png")
self.speed = 12
self.scale = 2
#collision list for who/what to collide with: wall, player, enemy
#Can place function for starting on player or enemy