Compare commits

..

2 Commits

Author SHA1 Message Date
xy 27bfce04e0 update Super Mario
6 months ago
xy dd0548a82d 这是一个聪明哥改的代码
6 months ago

@ -0,0 +1 @@
mario_level_1.py

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -133,7 +133,6 @@ class Brick(pg.sprite.Sprite):
class BrickPiece(pg.sprite.Sprite): class BrickPiece(pg.sprite.Sprite):
"""Pieces that appear when bricks are broken"""
def __init__(self, x, y, xvel, yvel): def __init__(self, x, y, xvel, yvel):
super(BrickPiece, self).__init__() super(BrickPiece, self).__init__()
self.sprite_sheet = setup.GFX['item_objects'] self.sprite_sheet = setup.GFX['item_objects']

@ -6,9 +6,8 @@ from .. import constants as c
class Flag(pg.sprite.Sprite): class Flag(pg.sprite.Sprite):
"""Flag on the castle"""
def __init__(self, x, y): def __init__(self, x, y):
"""Initialize object"""
super(Flag, self).__init__() super(Flag, self).__init__()
self.sprite_sheet = setup.GFX['item_objects'] self.sprite_sheet = setup.GFX['item_objects']
self.image = self.get_image(129, 2, 14, 14) self.image = self.get_image(129, 2, 14, 14)
@ -21,7 +20,7 @@ class Flag(pg.sprite.Sprite):
def get_image(self, x, y, width, height): def get_image(self, x, y, width, height):
"""Extracts image from sprite sheet"""
image = pg.Surface([width, height]) image = pg.Surface([width, height])
rect = image.get_rect() rect = image.get_rect()
@ -40,11 +39,11 @@ class Flag(pg.sprite.Sprite):
self.resting() self.resting()
def rising(self): def rising(self):
"""State when flag is rising to be on the castle"""
self.rect.y += self.y_vel self.rect.y += self.y_vel
if self.rect.bottom <= self.target_height: if self.rect.bottom <= self.target_height:
self.state = 'resting' self.state = 'resting'
def resting(self): def resting(self):
"""State when the flag is stationary doing nothing"""
pass pass

@ -5,8 +5,7 @@ from .. import constants as c
class Checkpoint(pg.sprite.Sprite): class Checkpoint(pg.sprite.Sprite):
"""Invisible sprite used to add enemies, special boxes
and trigger sliding down the flag pole"""
def __init__(self, x, name, y=0, width=10, height=600): def __init__(self, x, name, y=0, width=10, height=600):
super(Checkpoint, self).__init__() super(Checkpoint, self).__init__()
self.image = pg.Surface((width, height)) self.image = pg.Surface((width, height))

@ -1,15 +1,8 @@
SCREEN_HEIGHT = 600 SCREEN_HEIGHT = 600
SCREEN_WIDTH = 800 SCREEN_WIDTH = 800
SCREEN_SIZE = (SCREEN_WIDTH,SCREEN_HEIGHT) SCREEN_SIZE = (SCREEN_WIDTH,SCREEN_HEIGHT)
ORIGINAL_CAPTION = "Super Mario Bros 1-1" ORIGINAL_CAPTION = "Super Mario Bros 1-1"
## COLORS ##
# R G B
GRAY = (100, 100, 100) GRAY = (100, 100, 100)
NAVYBLUE = ( 60, 60, 100) NAVYBLUE = ( 60, 60, 100)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
@ -26,31 +19,22 @@ BLACK = ( 0, 0, 0)
NEAR_BLACK = ( 19, 15, 48) NEAR_BLACK = ( 19, 15, 48)
COMBLUE = (233, 232, 255) COMBLUE = (233, 232, 255)
GOLD = (255, 215, 0) GOLD = (255, 215, 0)
BGCOLOR = WHITE BGCOLOR = WHITE
SIZE_MULTIPLIER = 2.5 SIZE_MULTIPLIER = 2.5
BRICK_SIZE_MULTIPLIER = 2.69 BRICK_SIZE_MULTIPLIER = 2.69
BACKGROUND_MULTIPLER = 2.679 BACKGROUND_MULTIPLER = 2.679
GROUND_HEIGHT = SCREEN_HEIGHT - 62 GROUND_HEIGHT = SCREEN_HEIGHT - 62
#MARIO FORCES
WALK_ACCEL = .15 WALK_ACCEL = .15
RUN_ACCEL = 20 RUN_ACCEL = 20
SMALL_TURNAROUND = .35 SMALL_TURNAROUND = .35
GRAVITY = 1.01 GRAVITY = 1.01
JUMP_GRAVITY = .31 JUMP_GRAVITY = .31
JUMP_VEL = -10 JUMP_VEL = -10
FAST_JUMP_VEL = -12.5 FAST_JUMP_VEL = -12.5
MAX_Y_VEL = 11 MAX_Y_VEL = 11
MAX_RUN_SPEED = 800 MAX_RUN_SPEED = 800
MAX_WALK_SPEED = 6 MAX_WALK_SPEED = 6
#Mario States
STAND = 'standing' STAND = 'standing'
WALK = 'walk' WALK = 'walk'
JUMP = 'jump' JUMP = 'jump'
@ -61,21 +45,17 @@ BIG_TO_SMALL = 'big to small'
FLAGPOLE = 'flag pole' FLAGPOLE = 'flag pole'
WALKING_TO_CASTLE = 'walking to castle' WALKING_TO_CASTLE = 'walking to castle'
END_OF_LEVEL_FALL = 'end of level fall' END_OF_LEVEL_FALL = 'end of level fall'
#GOOMBA Stuff #GOOMBA Stuff
LEFT = 'left' LEFT = 'left'
RIGHT = 'right' RIGHT = 'right'
JUMPED_ON = 'jumped on' JUMPED_ON = 'jumped on'
DEATH_JUMP = 'death jump' DEATH_JUMP = 'death jump'
#KOOPA STUFF #KOOPA STUFF
SHELL_SLIDE = 'shell slide' SHELL_SLIDE = 'shell slide'
#BRICK STATES #BRICK STATES
RESTING = 'resting' RESTING = 'resting'
BUMPED = 'bumped' BUMPED = 'bumped'
@ -83,42 +63,28 @@ BUMPED = 'bumped'
OPENED = 'opened' OPENED = 'opened'
#MUSHROOM STATES #MUSHROOM STATES
REVEAL = 'reveal' REVEAL = 'reveal'
SLIDE = 'slide' SLIDE = 'slide'
#COIN STATES #COIN STATES
SPIN = 'spin' SPIN = 'spin'
#STAR STATES #STAR STATES
BOUNCE = 'bounce' BOUNCE = 'bounce'
#FIRE STATES #FIRE STATES
FLYING = 'flying' FLYING = 'flying'
BOUNCING = 'bouncing' BOUNCING = 'bouncing'
EXPLODING = 'exploding' EXPLODING = 'exploding'
#Brick and coin box contents #Brick and coin box contents
MUSHROOM = 'mushroom' MUSHROOM = 'mushroom'
STAR = 'star' STAR = 'star'
FIREFLOWER = 'fireflower' FIREFLOWER = 'fireflower'
SIXCOINS = '6coins' SIXCOINS = '6coins'
COIN = 'coin' COIN = 'coin'
LIFE_MUSHROOM = '1up_mushroom' LIFE_MUSHROOM = '1up_mushroom'
FIREBALL = 'fireball' FIREBALL = 'fireball'
#LIST of ENEMIES #LIST of ENEMIES
GOOMBA = 'goomba' GOOMBA = 'goomba'
KOOPA = 'koopa' KOOPA = 'koopa'
#LEVEL STATES #LEVEL STATES
FROZEN = 'frozen' FROZEN = 'frozen'
NOT_FROZEN = 'not frozen' NOT_FROZEN = 'not frozen'
IN_CASTLE = 'in castle' IN_CASTLE = 'in castle'

@ -2,9 +2,7 @@
import pygame as pg import pygame as pg
from . import setup from . import setup
from . import constants as c from . import constants as c
class Sound(object): class Sound(object):
"""Handles all sound for the game"""
def __init__(self, overhead_info): def __init__(self, overhead_info):
"""Initialize the class""" """Initialize the class"""
self.sfx_dict = setup.SFX self.sfx_dict = setup.SFX
@ -13,8 +11,6 @@ class Sound(object):
self.game_info = overhead_info.game_info self.game_info = overhead_info.game_info
self.set_music_mixer() self.set_music_mixer()
def set_music_mixer(self): def set_music_mixer(self):
"""Sets music for level""" """Sets music for level"""
if self.overhead_info.state == c.LEVEL: if self.overhead_info.state == c.LEVEL:
@ -25,8 +21,6 @@ class Sound(object):
pg.mixer.music.load(self.music_dict['game_over']) pg.mixer.music.load(self.music_dict['game_over'])
pg.mixer.music.play() pg.mixer.music.play()
self.state = c.GAME_OVER self.state = c.GAME_OVER
def update(self, game_info, mario): def update(self, game_info, mario):
"""Updates sound object with game info""" """Updates sound object with game info"""
self.game_info = game_info self.game_info = game_info

@ -1,13 +1,8 @@
"""
This module initializes the display and creates dictionaries of resources.
"""
import os import os
import pygame as pg import pygame as pg
from . import tools from . import tools
from .import constants as c from .import constants as c
ORIGINAL_CAPTION = c.ORIGINAL_CAPTION ORIGINAL_CAPTION = c.ORIGINAL_CAPTION

@ -97,7 +97,6 @@ class _State(object):
def startup(self, current_time, persistant): def startup(self, current_time, persistant):
self.persist = persistant self.persist = persistant
self.start_time = current_time self.start_time = current_time
def cleanup(self): def cleanup(self):
self.done = False self.done = False
return self.persist return self.persist
@ -105,8 +104,6 @@ class _State(object):
def update(self, surface, keys, current_time): def update(self, surface, keys, current_time):
pass pass
def load_all_gfx(directory, colorkey=(255,0,255), accept=('.png', 'jpg', 'bmp')): def load_all_gfx(directory, colorkey=(255,0,255), accept=('.png', 'jpg', 'bmp')):
graphics = {} graphics = {}
for pic in os.listdir(directory): for pic in os.listdir(directory):

@ -1 +1 @@
__author__ = 'justinarmstrong'

@ -1 +1 @@
__author__ = 'justinarmstrong'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Loading…
Cancel
Save