first commit

main
夏铭 6 months ago
parent c8eec935b3
commit 14e475406e

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (pythonProject1)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject1)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject1.iml" filepath="$PROJECT_DIR$/.idea/pythonProject1.iml" />
</modules>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.12 (pythonProject1)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,23 @@
# 主界面
import pygame
from source import tools, setup
from source.states import main_menu,load_screen,level
def main():
state_dict = {
'main_menu':main_menu.MainMenu(),
'load_screen':load_screen.LoadScreen(),
'level':level.Level(),
}
game = tools.Game(state_dict,'main_menu')
game.run()
if __name__ == '__main__':
main()

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mario shucai.iml" filepath="$PROJECT_DIR$/.idea/mario shucai.iml" />
</modules>
</component>
</project>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="cf1875ec-62b8-4caf-a03c-fb7443117e1a" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 2
}]]></component>
<component name="ProjectId" id="2gVXdWkJBK6kyr8Ds8GTXvqHnwT" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"last_opened_file_path": "C:/Users/xm/PycharmProjects/pythonProject1",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-1d06a55b98c1-91d5c284f522-JavaScript-PY-241.15989.155" />
<option value="bundled-python-sdk-babbdf50b680-7c6932dee5e4-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-241.15989.155" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="cf1875ec-62b8-4caf-a03c-fb7443117e1a" name="Changes" comment="" />
<created>1715783805550</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1715783805550</updated>
<workItem from="1715783806575" duration="33000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

@ -0,0 +1,35 @@
import pygame
from .. import tools,setup
from .. import constants as C
class FlashingCoin(pygame.sprite.Sprite): # 继承pygame精灵类
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.frames = []
self.frame_index = 0
frame_rects = [(1,160,5,8),(9,160,5,8),(17,160,5,8),(9,160,5,8)] # 闪烁
self.load_frames(frame_rects)
self.image = self.frames[self.frame_index] # 使用图片第一帧数
self.rect = self.image.get_rect()
self.rect.x = 280
self.rect.y = 58
self.timer = 0 # 随游戏切换金币帧
def load_frames(self,frame_rects):
sheet = setup.GRAPHICS['item_objects']
for frame_rect in frame_rects:
self.frames.append(tools.get_image(sheet,*frame_rect,(0,0,0), C.BG_MULTI))
def update(self):
self.current_time = pygame.time.get_ticks()
frame_durations = [375,125,125,125] # 每图片帧数时间
if self.timer == 0:
self.timer = self.current_time # 如果初始时间为零改为当前时间
elif self.current_time - self.timer > frame_durations[self.frame_index]: # 此时时间-计时器时间>所在帧应有时间间隔
self.frame_index += 1
self.frame_index %= 4
self.timer = self.current_time # 没交换一次计时器时间调成当下时间
self.image = self.frames[self.frame_index]

@ -0,0 +1,57 @@
# 文字
import pygame
from .. import constants as C
from . import coin
from .. import setup, tools
pygame.font.init()
class Info:
def __init__(self,state):
self.state = state
self.create_state_labels() # 创造某个阶段特有文字
self.create_info_labels() # 通用信息
self.flash_coin = coin.FlashingCoin()
def create_state_labels(self):
self.state_labels = []
if self.state == 'main_menu':
self.state_labels.append((self.create_label('1 PLAYER GAME'),(272,360)))
self.state_labels.append((self.create_label('2 PLAYER GAME'), (272, 405)))
self.state_labels.append((self.create_label('TOP - '), (290, 465)))
self.state_labels.append((self.create_label('00000'), (400, 465)))
elif self.state == 'load_screen':
self.state_labels.append((self.create_label('WORLD'), (280, 200)))
self.state_labels.append((self.create_label('1 - 1'), (430, 200)))
self.state_labels.append((self.create_label('X 3'), (380, 280)))
self.player_image = tools.get_image(setup.GRAPHICS['mario_bros'],178,32,12,16,(0,0,0), C.BG_MULTI)
def create_info_labels(self):
self.info_labels = []
self.info_labels.append((self.create_label('MARIO'), (75, 30)))
self.info_labels.append((self.create_label('WORLD'), (450, 30)))
self.info_labels.append((self.create_label('TIME'), (625, 30)))
self.info_labels.append((self.create_label('00000'), (75, 55)))
self.info_labels.append((self.create_label('x00'), (300, 55)))
self.info_labels.append((self.create_label('1 - 1'), (480, 55)))
def create_label(self,label,size=40,width_scale=1.25,height_scale=1):
font = pygame.font.SysFont('FixedSys.ttf',size)
label_image = font.render(label,1,(255,255,255)) # 文字渲染图片
rect = label_image.get_rect()
label_image = pygame.transform.scale(label_image,(int(rect.width*width_scale),int(rect.height*height_scale)))
return label_image
def update(self):
self.flash_coin.update()
def draw(self,surface):
for label in self.state_labels:
surface.blit(label[0],label[1])
for label in self.info_labels:
surface.blit(label[0],label[1])
surface.blit(self.flash_coin.image, self.flash_coin.rect)
if self.state == 'load_screen':
surface.blit(self.player_image,(300,270))

@ -0,0 +1,185 @@
import pygame
from .. import tools,setup
from .. import constants as C
import json
import os
class Player(pygame.sprite.Sprite):
def __init__(self,name):
pygame.sprite.Sprite.__init__(self)
self.name = name
self.load_data()
self.setup_states() # 状态
self.setup_velocities() # 速度
self.setup_timer() # 一系列计时器
self.load_images() # 帧造型
def load_data(self):
file_name = self.name + '.json'
file_path = os.path.join('source/data/player', file_name) # 拼接文件路径
with open(file_path) as f:
self.player_data = json.load(f) # 打开加载文件
def setup_states(self):
self.state = 'stand' # 初始状态
self.face_right = True
self.dead = False
self.big = False
def setup_velocities(self):
speed = self.player_data['speed'] # 读出速度数据
self.x_vel = 0
self.y_vel = 0
self.max_walk_vel = speed['max_walk_speed'] # 记录速度属性 v速度 a加速 t转身
self.max_run_vel = speed['max_run_speed']
self.max_y_vel = speed['max_y_velocity']
self.walk_accel = speed['walk_accel']
self.run_accel = speed['run_accel']
self.turn_accel = speed['turn_accel']
self.gravity = C.GRAVITY
self.max_y_vel = self.max_walk_vel
self.x_accel = self.walk_accel
def setup_timer(self):
self.walking_timer = 0
self.transition_timer = 0
def load_images(self):
sheet = setup.GRAPHICS['mario_bros']
frame_rects = self.player_data['image_frames']
self.right_small_normal_frames = []
self.right_big_normal_frames = []
self.right_big_fire_frames = []
self.left_small_normal_frames = []
self.left_big_normal_frames = []
self.left_big_fire_frames = [] # 底层分类
self.small_normal_frames = [self.right_small_normal_frames,self.left_small_normal_frames]
self.big_normal_frames = [self.right_big_normal_frames,self.left_big_normal_frames]
self.big_fire_frames = [self.right_big_fire_frames,self.left_big_fire_frames] #归纳
self.all_frames = [
self.right_small_normal_frames,
self.right_big_normal_frames,
self.right_big_fire_frames,
self.left_small_normal_frames,
self.left_big_normal_frames,
self.left_big_fire_frames, # 全体集合
]
self.right_frames = self.right_small_normal_frames
self.left_frames = self.left_small_normal_frames # 设置默认左右帧库
for group,group_frame_rects in frame_rects.items():
for frame_rect in group_frame_rects:
right_image = tools.get_image(sheet, frame_rect['x'],frame_rect['y'],
frame_rect['width'],frame_rect['height'],(0, 0, 0), C.PLAYER_MULTI)
left_image = pygame.transform.flip(right_image, True, False)
if group == 'right_small_normal':
self.right_small_normal_frames.append(right_image)
self.left_small_normal_frames.append(left_image)
if group == 'right_big_normal':
self.right_big_normal_frames.append(right_image)
self.left_big_normal_frames.append(left_image)
if group == 'right_big_fire':
self.right_big_fire_frames.append(right_image)
self.left_big_fire_frames.append(left_image) # 遍历
self.frame_index = 0
self.frames = self.right_frames
self.image = self.frames[self.frame_index]
self.rect = self.image.get_rect()
def update(self,keys):
if self.state == 'stand':
self.stand(keys)
elif self.state == 'walk':
self.walk(keys)
elif self.state == 'jump':
self.jump(keys)
elif self.state == 'basketball':
self.play_basketball(keys)
if self.face_right:
self.image = self.right_frames[self.frame_index]
else:
self.image = self.left_frames[self.frame_index]
def stand(self,keys):
self.frame_index = 0
self.x_vel = 0
self.y_vel = 0 # 初速度等都为0
if keys[pygame.K_RIGHT]: # 朝向
self.face_right = True
self.state = 'walk'
if keys[pygame.K_LEFT]:
self.face_right = False
self.state = 'walk'
def walk(self,keys):
self.current_time = pygame.time.get_ticks()
if keys[pygame.K_s]:
self.max_x_vel = self.max_run_vel
self.x_accel = self.run_accel
else:
self.max_x_vel = self.max_walk_vel
self.x_accel = self.walk_accel
if self.current_time - self.walking_timer > self.calc_frame_duration():
if self.frame_index < 3:
self.frame_index += 1
else:
self.frame_index = 1
self.walking_timer = self.current_time
if keys[pygame.K_RIGHT]:
self.face_right = True
if self.x_vel < 0:
self.frame_index = 5
self.x_accel = self.turn_accel
self.x_vel = self.calc_vel(self.x_vel,self.x_accel,self.max_x_vel,True)
elif keys[pygame.K_LEFT]:
self.face_right = False
if self.x_vel > 0:
self.frame_index = 5
self.x_accel = self.turn_accel
self.x_vel = self.calc_vel(self.x_vel, self.x_accel, self.max_x_vel, False)
else:
if self.face_right:
self.x_vel -= self.x_accel
if self.x_vel < 0:
self.x_vel = 0
self.state = 'stand'
else:
self.x_vel += self.x_accel
if self.x_vel > 0:
self.x_vel = 0
self.state = 'stand'
def jump(self,keys):
pass
def play_basketball(self,keys):
pass
def calc_vel(self,vel,accel,max_vel,is_positive=True): # 求速度
if is_positive:
return min(vel + accel, max_vel)
else:
return max(vel - accel, -max_vel) # 反之加负
def calc_frame_duration(self):
duration = -60 / self.max_run_vel *abs(self.x_accel) + 80
return duration

@ -0,0 +1,9 @@
SCREEN_W,SCREEN_H = 800,600
SCREEN_SIZE = (SCREEN_W, SCREEN_H)
BG_MULTI = 2.68
PLAYER_MULTI = 2.9
GRAVITY = 1.0
FONT = 'FixedSys.ttf'

@ -0,0 +1,208 @@
{
"image_name":"level_1",
"maps":[
{"start_x": 0, "end_x": 9086, "player_x": 110, "player_y":538},
{"start_x":9090, "end_x": 9890, "player_x": 80, "player_y": 60},
{"start_x":6740, "end_x": 9086, "player_x": 270, "player_y":450}
],
"ground":[
{"x": 0, "y":538, "width":2953, "height":60},
{"x":3048, "y":538, "width": 635, "height":60},
{"x":3819, "y":538, "width":2735, "height":60},
{"x":6647, "y":538, "width":3250, "height":60}
],
"pipe":[
{"x":1201, "y":451, "width": 83, "height": 84, "type":0},
{"x":1629, "y":409, "width": 83, "height":126, "type":0},
{"x":1972, "y":366, "width": 83, "height":170, "type":0},
{"x":2444, "y":366, "width": 83, "height":170, "type":1},
{"x":6987, "y":451, "width": 83, "height": 84, "type":0},
{"x":7673, "y":451, "width": 83, "height": 84, "type":0},
{"x":9724, "y":451, "width": 40, "height": 84, "type":2}
],
"step":[
{"x":5745, "y":495, "width": 40, "height": 44},
{"x":5788, "y":452, "width": 40, "height": 44},
{"x":5831, "y":409, "width": 40, "height": 44},
{"x":5874, "y":366, "width": 40, "height":176},
{"x":6001, "y":366, "width": 40, "height":176},
{"x":6044, "y":408, "width": 40, "height": 44},
{"x":6087, "y":452, "width": 40, "height": 44},
{"x":6130, "y":495, "width": 40, "height": 44},
{"x":6345, "y":495, "width": 40, "height": 44},
{"x":6388, "y":452, "width": 40, "height": 44},
{"x":6431, "y":409, "width": 40, "height": 44},
{"x":6474, "y":366, "width": 40, "height": 44},
{"x":6517, "y":366, "width": 40, "height":176},
{"x":6644, "y":366, "width": 40, "height":176},
{"x":6687, "y":408, "width": 40, "height": 44},
{"x":6728, "y":452, "width": 40, "height": 44},
{"x":6771, "y":495, "width": 40, "height": 44},
{"x":7760, "y":495, "width": 40, "height": 44},
{"x":7803, "y":452, "width": 40, "height": 44},
{"x":7845, "y":409, "width": 40, "height": 44},
{"x":7888, "y":366, "width": 40, "height": 44},
{"x":7931, "y":323, "width": 40, "height": 44},
{"x":7974, "y":280, "width": 40, "height": 44},
{"x":8017, "y":237, "width": 40, "height": 44},
{"x":8060, "y":194, "width": 40, "height": 44},
{"x":8103, "y":194, "width": 40, "height":360},
{"x":8488, "y":495, "width": 40, "height": 44},
{"x":9821, "y": 64, "width": 70, "height":530}
],
"coin":[
{"x":9318, "y":369},
{"x":9318, "y":369},
{"x":9362, "y":369},
{"x":9406, "y":369},
{"x":9450, "y":369},
{"x":9494, "y":369},
{"x":9538, "y":369},
{"x":9582, "y":369},
{"x":9318, "y":284},
{"x":9362, "y":284},
{"x":9406, "y":284},
{"x":9450, "y":284},
{"x":9494, "y":284},
{"x":9538, "y":284},
{"x":9582, "y":284},
{"x":9362, "y":198},
{"x":9406, "y":198},
{"x":9450, "y":198},
{"x":9494, "y":198},
{"x":9538, "y":198}
],
"brick":[
{"x": 858, "y":365, "type":0},
{"x": 944, "y":365, "type":0},
{"x":1030, "y":365, "type":0},
{"x":3299, "y":365, "type":0},
{"x":3385, "y":365, "type":0},
{"x":3430, "y":193, "type":0},
{"x":3473, "y":193, "type":0},
{"x":3473, "y":193, "type":0},
{"x":3516, "y":193, "type":0},
{"x":3559, "y":193, "type":0},
{"x":3602, "y":193, "type":0},
{"x":3645, "y":193, "type":0},
{"x":3688, "y":193, "type":0},
{"x":3731, "y":193, "type":0},
{"x":3901, "y":193, "type":0},
{"x":3944, "y":193, "type":0},
{"x":3987, "y":193, "type":0},
{"x":4030, "y":365, "type":1},
{"x":4287, "y":365, "type":0},
{"x":4330, "y":365, "type":2},
{"x":5058, "y":365, "type":0},
{"x":5187, "y":193, "type":0},
{"x":5230, "y":193, "type":0},
{"x":5273, "y":193, "type":0},
{"x":5488, "y":193, "type":0},
{"x":5574, "y":193, "type":0},
{"x":5617, "y":193, "type":0},
{"x":5531, "y":365, "type":0},
{"x":5574, "y":365, "type":0},
{"x":7202, "y":365, "type":0},
{"x":7245, "y":365, "type":0},
{"x":7331, "y":365, "type":0},
{"x":9090, "y": 64, "type":0, "color":1,"brick_num":11, "direction":1},
{"x":9310, "y": 64, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":9310, "y":406, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":9310, "y":449, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":9310, "y":492, "type":0, "color":1,"brick_num":7, "direction":0}
],
"box":[
{"x": 685, "y":365, "type":1},
{"x": 901, "y":365, "type":3},
{"x": 987, "y":365, "type":1},
{"x": 943, "y":193, "type":1},
{"x":3342, "y":365, "type":4},
{"x":4030, "y":193, "type":1},
{"x":4544, "y":365, "type":1},
{"x":4672, "y":365, "type":1},
{"x":4672, "y":193, "type":4},
{"x":4800, "y":365, "type":1},
{"x":5531, "y":193, "type":1},
{"x":7288, "y":365, "type":1}
],
"enemy":[
{"0":[
{"x":1120, "y":538, "direction":0, "type":0, "color":0}
]},
{"1":[
{"x":1920, "y":538, "direction":0, "type":0, "color":0}
]},
{"2":[
{"x":2320, "y":538, "direction":0, "type":0, "color":0},
{"x":2380, "y":538, "direction":0, "type":0, "color":0}
]},
{"3":[
{"x":3640, "y":193, "direction":0, "type":0, "color":0},
{"x":3700, "y":193, "direction":0, "type":0, "color":0}
]},
{"4":[
{"x":4270, "y":538, "direction":0, "type":0, "color":0},
{"x":4330, "y":538, "direction":0, "type":0, "color":0}
]},
{"5":[
{"x":4700, "y":538, "direction":0, "type":1, "color":1}
]},
{"6":[
{"x":4900, "y":538, "direction":0, "type":0, "color":0},
{"x":4960, "y":538, "direction":0, "type":0, "color":0}
]},
{"7":[
{"x":5300, "y":538, "direction":0, "type":0, "color":0},
{"x":5360, "y":538, "direction":0, "type":0, "color":0}
]},
{"8":[
{"x":5600, "y":538, "direction":0, "type":0, "color":0},
{"x":5660, "y":538, "direction":0, "type":0, "color":0}
]},
{"9":[
{"x":7550, "y":538, "direction":0, "type":0, "color":0},
{"x":7610, "y":538, "direction":0, "type":0, "color":0}
]}
],
"checkpoint":[
{"x": 510, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":0},
{"x":1400, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":1},
{"x":1740, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":2},
{"x":3050, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":3},
{"x":3750, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":4},
{"x":4100, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":5},
{"x":4300, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":6},
{"x":4700, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":7},
{"x":5000, "y": 0, "width":10, "height":600, "type":0, "enemy_groupid":8},
{"x":6940, "y": 0, "width":100, "height":600, "type":0, "enemy_groupid":9},
{"x":2460, "y":439, "width":50, "height": 10, "type":6, "map_index":1},
{"x":8504, "y":-10, "width": 6, "height":600, "type":1},
{"x":8780, "y": 0, "width":10, "height":600, "type":2},
{"x":2740, "y":360, "width":40, "height": 12, "type":3},
{"x":9731, "y":458, "width":10, "height": 70, "type":4},
{"x":9800, "y":458, "width":10, "height": 70, "type":5, "map_index":2}
],
"flagpole":[
{"x":8470, "y":116, "type":0},
{"x":8505, "y": 97, "type":1},
{"x":8505, "y":137, "type":1},
{"x":8505, "y":177, "type":1},
{"x":8505, "y":217, "type":1},
{"x":8505, "y":257, "type":1},
{"x":8505, "y":297, "type":1},
{"x":8505, "y":337, "type":1},
{"x":8505, "y":377, "type":1},
{"x":8505, "y":417, "type":1},
{"x":8505, "y":450, "type":1},
{"x":8497, "y": 97, "type":2}
]
}

@ -0,0 +1,261 @@
{
"image_name":"level_2",
"maps":[
{"start_x": 0, "end_x": 8232, "player_x":110, "player_y": 0},
{"start_x":8233, "end_x": 9860, "player_x":150, "player_y":451},
{"start_x":9862, "end_x":10662, "player_x": 50, "player_y": 0}
],
"ground":[
{"x": 0, "y":540, "width":3426, "height": 60},
{"x":3560, "y":540, "width":1582, "height": 60},
{"x":5230, "y":410, "width": 86, "height":190},
{"x":5404, "y":540, "width": 510, "height": 60},
{"x":6218, "y":540, "width": 340, "height": 60},
{"x":6860, "y":540, "width": 730, "height":190},
{"x":7590, "y":540, "width": 642, "height": 60},
{"x":8233, "y":540, "width":1627, "height": 60},
{"x":9862, "y":540, "width": 800, "height": 60}
],
"pipe":[
{"x":4415, "y":410, "width": 82, "height":130, "type":0},
{"x":4672, "y":367, "width": 82, "height":170, "type":0},
{"x":4929, "y":453, "width": 82, "height": 86, "type":0},
{"x":7114, "y":325, "width":104, "height": 86, "type":2},
{"x":7632, "y":410, "width": 82, "height":130, "type":1},
{"x":7802, "y":410, "width":104, "height":130, "type":1},
{"x":7974, "y":410, "width":104, "height":130, "type":1},
{"x":8360, "y":453, "width": 82, "height": 86, "type":0},
{"x":10500, "y":453, "width":104, "height": 86, "type":2}
],
"step":[
{"x": 730, "y":495, "width": 40, "height": 44},
{"x": 816, "y":451, "width": 40, "height": 88},
{"x": 900, "y":410, "width": 40, "height":132},
{"x": 986, "y":367, "width": 40, "height":176},
{"x":1072, "y":367, "width": 40, "height":176},
{"x":1158, "y":410, "width": 40, "height":132},
{"x":1330, "y":410, "width": 40, "height":132},
{"x":1416, "y":451, "width": 40, "height": 88},
{"x":5702, "y":496, "width": 40, "height": 44},
{"x":5745, "y":452, "width": 40, "height": 88},
{"x":5788, "y":410, "width": 40, "height":132},
{"x":5831, "y":367, "width": 40, "height":176},
{"x":5874, "y":367, "width": 40, "height":176},
{"x":7208, "y": 66, "width": 74, "height":344},
{"x":8448, "y":496, "width": 40, "height": 44},
{"x":8491, "y":452, "width": 40, "height": 88},
{"x":8534, "y":410, "width": 40, "height":132},
{"x":8577, "y":367, "width": 40, "height":176},
{"x":8620, "y":324, "width": 40, "height":220},
{"x":8663, "y":281, "width": 40, "height":264},
{"x":8706, "y":237, "width": 40, "height":308},
{"x":8749, "y":194, "width": 40, "height":352},
{"x":8792, "y":194, "width": 40, "height":352},
{"x":9176, "y":496, "width": 40, "height": 44},
{"x":10593, "y":66, "width": 74, "height":474}
],
"slider":[
{"x":5994, "y": 0, "num":3, "direction":1, "range_start": -50, "range_end": 650, "velocity":1},
{"x":5994, "y":260, "num":3, "direction":1, "range_start": -50, "range_end": 650, "velocity":1},
{"x":6642, "y": 0, "num":3, "direction":1, "range_start": -50, "range_end": 650, "velocity":-1},
{"x":6642, "y":260, "num":3, "direction":1, "range_start": -50, "range_end": 650, "velocity":-1}
],
"coin":[
{"x":1724, "y":328},
{"x":1764, "y":200},
{"x":1808, "y":200},
{"x":1852, "y":200},
{"x":1896, "y":200},
{"x":1936, "y":328},
{"x":2494, "y":328},
{"x":2538, "y":328},
{"x":2580, "y":328},
{"x":2622, "y":328},
{"x":2924, "y":328},
{"x":3608, "y":200},
{"x":3650, "y":200},
{"x":3692, "y":200},
{"x":3734, "y":200},
{"x":3776, "y":200},
{"x":10126, "y":328},
{"x":10168, "y":328},
{"x":10210, "y":328},
{"x":10252, "y":328},
{"x":10294, "y":328},
{"x":10336, "y":328},
{"x":10378, "y":328},
{"x":10420, "y":328},
{"x":10084, "y":500},
{"x":10126, "y":500},
{"x":10168, "y":500},
{"x":10210, "y":500},
{"x":10252, "y":500},
{"x":10294, "y":500},
{"x":10336, "y":500},
{"x":10378, "y":500},
{"x":10420, "y":500}
],
"brick":[
{"x": 0, "y": 66, "type":0, "color":1,"brick_num":11, "direction":1},
{"x": 254, "y": 66, "type":0, "color":1,"brick_num":83, "direction":0},
{"x":3816, "y": 66, "type":6, "color":1},
{"x":3859, "y": 66, "type":0, "color":1,"brick_num":47, "direction":0},
{"x":1244, "y":324, "type":1, "color":1},
{"x":1672, "y":281, "type":0, "color":1,"brick_num":3, "direction":1},
{"x":1715, "y":367, "type":0, "color":1},
{"x":1758, "y":281, "type":0, "color":1,"brick_num":3, "direction":1},
{"x":1801, "y":281, "type":0, "color":1},
{"x":1844, "y":281, "type":0, "color":1},
{"x":1887, "y":281, "type":0, "color":1,"brick_num":3, "direction":1},
{"x":1930, "y":367, "type":0, "color":1},
{"x":1973, "y":367, "type":0, "color":1},
{"x":1973, "y":324, "type":0, "color":1},
{"x":1973, "y":281, "type":2, "color":1},
{"x":2230, "y":195, "type":0, "color":1,"brick_num":5, "direction":1},
{"x":2273, "y":195, "type":0, "color":1,"brick_num":5, "direction":1},
{"x":2316, "y":109, "type":0, "color":1,"brick_num":2, "direction":1},
{"x":2316, "y":367, "type":0, "color":1,"brick_num":3, "direction":1},
{"x":2359, "y":109, "type":0, "color":1,"brick_num":2, "direction":1},
{"x":2359, "y":367, "type":0, "color":1,"brick_num":3, "direction":1},
{"x":2487, "y":109, "type":0, "color":1,"brick_num":6, "direction":0},
{"x":2487, "y":152, "type":0, "color":1,"brick_num":6, "direction":0},
{"x":2659, "y":195, "type":0, "color":1,"brick_num":2, "direction":0},
{"x":2659, "y":238, "type":0, "color":1,"brick_num":2, "direction":0},
{"x":2659, "y":281, "type":0, "color":1,"brick_num":2, "direction":0},
{"x":2659, "y":324, "type":0, "color":1,"brick_num":2, "direction":0},
{"x":2487, "y":367, "type":0, "color":1,"brick_num":6, "direction":0},
{"x":2830, "y":109, "type":0, "color":1,"brick_num":3, "direction":0},
{"x":2830, "y":152, "type":0, "color":1,"brick_num":3, "direction":0},
{"x":2873, "y":195, "type":0, "color":1,"brick_num":5, "direction":1},
{"x":2916, "y":367, "type":0, "color":1},
{"x":2959, "y":367, "type":0, "color":1},
{"x":2958, "y":324, "type":4, "color":1},
{"x":3087, "y":195, "type":0, "color":1,"brick_num":5, "direction":1},
{"x":3130, "y":195, "type":0, "color":1,"brick_num":5, "direction":1},
{"x":3259, "y":195, "type":0, "color":1,"brick_num":4, "direction":0},
{"x":3259, "y":238, "type":0, "color":1,"brick_num":4, "direction":0},
{"x":3259, "y":367, "type":0, "color":1,"brick_num":4, "direction":0},
{"x":3602, "y":281, "type":0, "color":1,"brick_num":6, "direction":0},
{"x":3602, "y":324, "type":0, "color":1,"brick_num":6, "direction":0},
{"x":6218, "y":324, "type":0, "color":1,"brick_num":5, "direction":0},
{"x":6433, "y":324, "type":4, "color":1},
{"x":6860, "y":410, "type":0, "color":1,"brick_num":17, "direction":0},
{"x":6860, "y":453, "type":0, "color":1,"brick_num":17, "direction":0},
{"x":6860, "y":496, "type":0, "color":1,"brick_num":17, "direction":0},
{"x":6903, "y": 66, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y": 66, "type":0, "color":1,"brick_num":17, "direction":0},
{"x":7290, "y":109, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y":152, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y":195, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y":238, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y":281, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y":324, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":7290, "y":367, "type":0, "color":1,"brick_num":7, "direction":0},
{"x":8140, "y": 66, "type":0, "color":1,"brick_num":11, "direction":1},
{"x":8183, "y": 66, "type":0, "color":1,"brick_num":11, "direction":1},
{"x":9863, "y": 66, "type":0, "color":1,"brick_num":11, "direction":1},
{"x":9992, "y": 66, "type":0, "color":1,"brick_num":12, "direction":0},
{"x":9992, "y":109, "type":0, "color":1,"brick_num":12, "direction":0},
{"x":9992, "y":152, "type":0, "color":1,"brick_num":12, "direction":0},
{"x":9992, "y":195, "type":0, "color":1,"brick_num":12, "direction":0},
{"x":9992, "y":367, "type":0, "color":1,"brick_num":12, "direction":0},
{"x":10508, "y": 66, "type":0, "color":1,"brick_num":9, "direction":1},
{"x":10551, "y": 66, "type":0, "color":1,"brick_num":9, "direction":1}
],
"box":[
{"x": 426, "y":367, "type":3},
{"x": 470, "y":367, "type":1},
{"x": 514, "y":367, "type":1},
{"x": 556, "y":367, "type":1},
{"x": 598, "y":367, "type":1}
],
"enemy":[
{"0":[
{"x": 685, "y":540, "direction":0, "type":0, "color":1},
{"x": 730, "y":495, "direction":0, "type":0, "color":1}
]},
{"1":[
{"x":1260, "y":540, "direction":0, "type":0, "color":1}
]},
{"2":[
{"x":2040, "y":538, "direction":0, "type":1, "color":0},
{"x":2100, "y":538, "direction":0, "type":1, "color":0}
]},
{"3":[
{"x":2670, "y":538, "direction":0, "type":1, "color":0},
{"x":2800, "y":538, "direction":0, "type":0, "color":1},
{"x":2880, "y":538, "direction":0, "type":0, "color":1}
]},
{"4":[
{"x":3130, "y":195, "direction":0, "type":0, "color":1}
]},
{"5":[
{"x":3330, "y":367, "direction":0, "type":0, "color":1},
{"x":3400, "y":367, "direction":0, "type":0, "color":1}
]},
{"6":[
{"x":4246, "y":538, "direction":0, "type":0, "color":1},
{"x":4306, "y":538, "direction":0, "type":0, "color":1},
{"x":4366, "y":538, "direction":0, "type":0, "color":1}
]},
{"7":[
{"x":4440, "y":490, "direction":0, "type":3, "color":0, "range":1, "range_start":360, "range_end":490},
{"x":4696, "y":445, "direction":0, "type":3, "color":0, "range":1, "range_start":315, "range_end":445},
{"x":4954, "y":535, "direction":0, "type":3, "color":0, "range":1, "range_start":400, "range_end":535}
]},
{"8":[
{"x":4890, "y":538, "direction":0, "type":0, "color":1}
]},
{"9":[
{"x":5786, "y":410, "direction":0, "type":0, "color":1},
{"x":5846, "y":367, "direction":0, "type":0, "color":1}
]},
{"10":[
{"x":6500, "y":538, "direction":0, "type":1, "color":2, "range":1, "range_start":6220, "range_end":6755}
]},
{"11":[
{"x":8383, "y":535, "direction":0, "type":3, "color":0, "range":1, "range_start":400, "range_end":535}
]}
],
"checkpoint":[
{"x": 110, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":0},
{"x": 728, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":1},
{"x":1400, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":2},
{"x":2070, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":3},
{"x":2530, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":4},
{"x":2730, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":5},
{"x":3646, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":6},
{"x":3800, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":7},
{"x":4290, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":8},
{"x":5186, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":9},
{"x":5900, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":10},
{"x":8383, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":11},
{"x":7117, "y":330, "width":10, "height":80, "type":4},
{"x":7187, "y":330, "width":10, "height":80, "type":5, "map_index":1},
{"x":7634, "y":540, "width":78, "height":10, "type":6, "map_index":2},
{"x":7804, "y":540, "width":78, "height":10, "type":6, "map_index":2},
{"x":7976, "y":540, "width":78, "height":10, "type":6, "map_index":2},
{"x":9195, "y":-15, "width":5, "height":600, "type":1},
{"x":9470, "y":0, "width":10, "height":600, "type":2},
{"x":10502, "y":460, "width":10, "height":80, "type":4},
{"x":10572, "y":460, "width":10, "height":80, "type":5, "map_index":1}
],
"flagpole":[
{"x":9156, "y":116, "type":0}
]
}

@ -0,0 +1,121 @@
{
"image_name":"level_3",
"ground":[
{"x": 0, "y":538, "width": 686, "height": 60},
{"x": 774, "y":496, "width": 166, "height": 36},
{"x":1031, "y":368, "width": 340, "height": 36},
{"x":1074, "y":406, "width": 252, "height":194},
{"x":1118, "y":196, "width": 208, "height": 36},
{"x":1374, "y":496, "width": 126, "height": 36},
{"x":1504, "y":325, "width": 208, "height": 36},
{"x":1544, "y":360, "width": 126, "height":240},
{"x":1716, "y":153, "width": 296, "height": 36},
{"x":1760, "y":190, "width": 208, "height":410},
{"x":2146, "y":538, "width": 166, "height": 36},
{"x":2534, "y":538, "width": 208, "height": 36},
{"x":2574, "y":198, "width": 166, "height": 36},
{"x":2790, "y":538, "width": 208, "height": 36},
{"x":3002, "y":366, "width": 126, "height": 36},
{"x":3044, "y":406, "width": 40, "height":194},
{"x":3262, "y":238, "width": 252, "height": 36},
{"x":3304, "y":274, "width": 166, "height":326},
{"x":4204, "y":452, "width": 166, "height": 36},
{"x":4246, "y":488, "width": 84, "height":112},
{"x":4462, "y":282, "width": 338, "height": 36},
{"x":4502, "y":318, "width": 252, "height":282},
{"x":4847, "y":538, "width": 126, "height": 60},
{"x":4976, "y":368, "width": 166, "height": 36},
{"x":5018, "y":406, "width": 84, "height":194},
{"x":5232, "y":368, "width": 166, "height": 36},
{"x":5274, "y":406, "width": 84, "height":194},
{"x":5532, "y":538, "width":1508, "height": 60}
],
"step":[
{"x":5917, "y":366, "width": 80, "height":176},
{"x":6002, "y":280, "width": 80, "height":264},
{"x":6090, "y":194, "width": 80, "height":352},
{"x":6516, "y":495, "width": 40, "height": 44}
],
"slider":[
{"x":2400, "y":338, "num":3, "direction":1, "range_start": 238, "range_end": 560},
{"x":3590, "y":322, "num":3, "direction":0, "range_start":3590, "range_end":3750},
{"x":3790, "y":366, "num":3, "direction":0, "range_start":3790, "range_end":3950},
{"x":5440, "y":238, "num":3, "direction":0, "range_start":5440, "range_end":5600}
],
"coin":[
{"x":1166, "y":156},
{"x":1208, "y":156},
{"x":1250, "y":156},
{"x":1594, "y": 70},
{"x":1636, "y": 70},
{"x":2152, "y":240},
{"x":2194, "y":240},
{"x":2580, "y":156},
{"x":2622, "y":156},
{"x":2664, "y":156},
{"x":2706, "y":156},
{"x":3652, "y":198},
{"x":3694, "y":198},
{"x":3996, "y":156},
{"x":4038, "y":156},
{"x":4166, "y":156},
{"x":4208, "y":156},
{"x":4852, "y":496},
{"x":4894, "y":496},
{"x":4936, "y":496},
{"x":5154, "y":198},
{"x":5196, "y":198}
],
"box":[
{"x":2530, "y":408, "type":3}
],
"enemy":[
{"0":[
{"x":1284, "y":196, "direction":0, "type":1, "color":2, "range":1, "range_start":1114, "range_end":1324}
]},
{"1":[
{"x":1886, "y":152, "direction":0, "type":0, "color":0},
{"x":1946, "y":152, "direction":0, "type":0, "color":0}
]},
{"2":[
{"x":3160, "y":220, "direction":0, "type":2, "color":2, "range":1, "range_start":200, "range_end":440, "is_vertical":1}
]},
{"3":[
{"x":3458, "y":238, "direction":0, "type":0, "color":0, "range":1, "range_start":3262, "range_end":3508}
]},
{"4":[
{"x":4740, "y":282, "direction":0, "type":1, "color":2, "range":1, "range_start":4460, "range_end":4798}
]},
{"5":[
{"x":4880, "y":260, "direction":0, "type":2, "color":2, "range":1, "range_start":230, "range_end":490, "is_vertical":1}
]},
{"6":[
{"x":5836, "y":538, "direction":0, "type":1, "color":2, "range":1, "range_start":5530, "range_end":5908}
]}
],
"checkpoint":[
{"x": 690, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":0},
{"x":1292, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":1},
{"x":2300, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":2},
{"x":2870, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":3},
{"x":4154, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":4},
{"x":4466, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":5},
{"x":5246, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":6},
{"x":6536, "y":-15, "width": 6, "height":600, "type":1, "enemy_groupid":0},
{"x":6853, "y":0, "width":10, "height":600, "type":2, "enemy_groupid":0}
],
"flagpole":[
{"x":6497, "y":116, "type":0},
{"x":8505, "y": 97, "type":1},
{"x":8505, "y":137, "type":1},
{"x":8505, "y":177, "type":1},
{"x":8505, "y":217, "type":1},
{"x":8505, "y":257, "type":1},
{"x":8505, "y":297, "type":1},
{"x":8505, "y":337, "type":1},
{"x":8505, "y":377, "type":1},
{"x":8505, "y":417, "type":1},
{"x":8505, "y":450, "type":1},
{"x":8497, "y": 97, "type":2}
]
}

@ -0,0 +1,87 @@
{
"image_name":"level_4",
"maps":[
{"start_x": 0, "end_x": 6844, "player_x":110, "player_y": 275}
],
"ground":[
{"x": 0, "y":409, "width": 556, "height":191},
{"x": 0, "y":366, "width": 215, "height": 43},
{"x": 0, "y":323, "width": 172, "height": 43},
{"x": 0, "y":280, "width": 129, "height": 43},
{"x": 623, "y":409, "width": 470, "height":191},
{"x":1222, "y":409, "width": 129, "height":191},
{"x":1480, "y":409, "width":2956, "height":191},
{"x":1480, "y":366, "width":1584, "height": 43},
{"x":4436, "y":537, "width":1031, "height": 60},
{"x":4952, "y":409, "width": 170, "height":130},
{"x":5252, "y":409, "width": 213, "height":130},
{"x":6024, "y":366, "width": 126, "height":170},
{"x":6024, "y":537, "width": 820, "height": 60}
],
"step":[
{"x": 0, "y": 63, "width":1008, "height":127},
{"x": 966, "y":190, "width": 41, "height": 87},
{"x":1008, "y": 63, "width": 556, "height": 41},
{"x":1566, "y": 63, "width":1502, "height":170},
{"x":1566, "y":234, "width": 41, "height": 41},
{"x":2080, "y":234, "width": 41, "height": 43},
{"x":2552, "y":234, "width": 41, "height": 43},
{"x":2852, "y":234, "width": 41, "height": 43},
{"x":3066, "y": 63, "width":3778, "height": 40},
{"x":3238, "y":366, "width": 41, "height": 43},
{"x":3409, "y":104, "width": 41, "height": 86},
{"x":3581, "y":366, "width": 41, "height": 43},
{"x":3752, "y":104, "width": 41, "height": 86},
{"x":3924, "y":366, "width": 41, "height": 43},
{"x":3580, "y":366, "width": 41, "height": 43},
{"x":4138, "y":104, "width": 297, "height": 86},
{"x":5252, "y":104, "width": 213, "height": 86},
{"x":6067, "y":104 , "width": 84, "height":128},
{"x":5468, "y":409 , "width": 540, "height":44}
],
"slider":[
{"x":5750, "y":238, "num":2, "direction":0, "range_start":5720, "range_end":5930}
],
"box":[
{"x":1266, "y":236, "type":3}
],
"enemy":[
{"0":[
{"x":1275, "y":422, "direction":0, "type":4, "color":0, "num":6}
]},
{"1":[
{"x":2091, "y":249, "direction":0, "type":4, "color":0, "num":6}
]},
{"2":[
{"x":2562, "y":249, "direction":0, "type":4, "color":0, "num":6}
]},
{"3":[
{"x":2862, "y":249, "direction":0, "type":4, "color":0, "num":6}
]},
{"4":[
{"x":3250, "y":380, "direction":0, "type":4, "color":0, "num":6}
]},
{"5":[
{"x":3592, "y":380, "direction":0, "type":4, "color":0, "num":6}
]},
{"6":[
{"x":3762, "y":163, "direction":0, "type":4, "color":0, "num":6}
]},
{"7":[
{"x":5880, "y":405, "direction":0, "type":5, "color":0, "range":1, "range_start":5750, "range_end":5975}
]}
],
"checkpoint":[
{"x": 577, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":0},
{"x":1050, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":1},
{"x":1700, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":2},
{"x":2162, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":3},
{"x":2550, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":4},
{"x":2892, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":5},
{"x":3062, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":6},
{"x":3900, "y":0, "width":10, "height":600, "type":0, "enemy_groupid":7},
{"x":6026, "y":324, "width":40, "height":40, "type":7, "enemy_groupid":0},
{"x":6510, "y":0, "width":10, "height":600, "type":2, "enemy_groupid":0}
]
}

@ -0,0 +1,54 @@
{
"image_name":"mario_bros",
"image_frames":{
"right_small_normal":[
{"x":178, "y":128, "width":12, "height":16},
{"x": 80, "y":128, "width":15, "height":16},
{"x": 96, "y":128, "width":16, "height":16},
{"x":112, "y":128, "width":16, "height":16},
{"x":144, "y":128, "width":16, "height":16},
{"x":130, "y":128, "width":14, "height":16},
{"x":160, "y":128, "width":15, "height":16},
{"x":320, "y":105, "width":16, "height":24},
{"x":241, "y":129, "width":16, "height":16},
{"x":194, "y":128, "width":12, "height":16},
{"x":210, "y":129, "width":12, "height":16}
],
"right_big_normal":[
{"x":176, "y": 96, "width":16, "height":32},
{"x": 81, "y": 96, "width":16, "height":32},
{"x": 97, "y": 96, "width":15, "height":32},
{"x":113, "y": 96, "width":15, "height":32},
{"x":144, "y": 96, "width":16, "height":32},
{"x":128, "y": 96, "width":16, "height":32},
{"x":336, "y": 96, "width":16, "height":32},
{"x":160, "y":106, "width":16, "height":22},
{"x":272, "y": 98, "width":16, "height":29},
{"x":193, "y": 98, "width":16, "height":29},
{"x":209, "y": 98, "width":16, "height":29}
],
"right_big_fire":[
{"x":176, "y":192, "width":16, "height":32},
{"x": 81, "y":192, "width":16, "height":32},
{"x": 97, "y":192, "width":15, "height":32},
{"x":113, "y":192, "width":15, "height":32},
{"x":144, "y":192, "width":16, "height":32},
{"x":128, "y":192, "width":16, "height":32},
{"x":336, "y":192, "width":16, "height":32},
{"x":160, "y":202, "width":16, "height":22},
{"x":272, "y":194, "width":16, "height":29},
{"x":193, "y":194, "width":16, "height":29},
{"x":209, "y":194, "width":16, "height":29}
]
},
"speed":{
"max_walk_speed":6,
"max_run_speed":12,
"max_y_velocity":11,
"walk_accel":0.15,
"run_accel":0.3,
"turn_accel": 0.35,
"jump_velocity":-10.5
}
}

@ -0,0 +1,54 @@
{
"image_name":"mario_bros",
"image_frames":{
"right_small_normal":[
{"x":178, "y": 32, "width":12, "height":16},
{"x": 80, "y": 32, "width":15, "height":16},
{"x": 96, "y": 32, "width":16, "height":16},
{"x":112, "y": 32, "width":16, "height":16},
{"x":144, "y": 32, "width":16, "height":16},
{"x":130, "y": 32, "width":14, "height":16},
{"x":160, "y": 32, "width":15, "height":16},
{"x":320, "y": 8, "width":16, "height":24},
{"x":241, "y": 33, "width":16, "height":16},
{"x":194, "y": 32, "width":12, "height":16},
{"x":210, "y": 33, "width":12, "height":16}
],
"right_big_normal":[
{"x":176, "y": 0, "width":16, "height":32},
{"x": 81, "y": 0, "width":16, "height":32},
{"x": 97, "y": 0, "width":15, "height":32},
{"x":113, "y": 0, "width":15, "height":32},
{"x":144, "y": 0, "width":16, "height":32},
{"x":128, "y": 0, "width":16, "height":32},
{"x":336, "y": 0, "width":16, "height":32},
{"x":160, "y": 10, "width":16, "height":22},
{"x":272, "y": 2, "width":16, "height":29},
{"x":193, "y": 2, "width":16, "height":29},
{"x":209, "y": 2, "width":16, "height":29}
],
"right_big_fire":[
{"x":176, "y": 48, "width":16, "height":32},
{"x": 81, "y": 48, "width":16, "height":32},
{"x": 97, "y": 48, "width":15, "height":32},
{"x":113, "y": 48, "width":15, "height":32},
{"x":144, "y": 48, "width":16, "height":32},
{"x":128, "y": 48, "width":16, "height":32},
{"x":336, "y": 48, "width":16, "height":32},
{"x":160, "y": 58, "width":16, "height":22},
{"x":272, "y": 50, "width":16, "height":29},
{"x":193, "y": 50, "width":16, "height":29},
{"x":209, "y": 50, "width":16, "height":29}
]
},
"speed":{
"max_walk_speed":6,
"max_run_speed":12,
"max_y_velocity":11,
"walk_accel":0.15,
"run_accel":0.3,
"turn_accel": 0.35,
"jump_velocity":-10.5
}
}

@ -0,0 +1,8 @@
import pygame
from . import constants as C
from . import tools
pygame.init()
SCREEN = pygame.display.set_mode((C.SCREEN_W, C.SCREEN_H)) # 大小
GRAPHICS = tools.load_graphics('resources\graphics')

@ -0,0 +1,45 @@
from ..components import info
import pygame
from .. import tools, setup
from .. import constants as C
from .. components import player
class Level:
def __init__(self):
self.finished = False
self.next = None
self.info = info.Info('level')
self.setup_background()
self.setup_player()
def setup_background(self):
self.background = setup.GRAPHICS['level_1']
rect = self.background.get_rect()
self.background = pygame.transform.scale(self.background,(int(rect.width * C.BG_MULTI),
int(rect.height * C.BG_MULTI)))
self.background_rect = self.background.get_rect()
def setup_player(self):
self.player = player.Player('mario')
self.player.rect.x = 300
self.player.rect.y = 490
def update(self, surface, keys):
self.player.update(keys)
self.update_player_position()
self.draw(surface)
def update_player_position(self):
self.player.rect.x += self.player.x_vel
if self.player.rect.x < 0:
self.player.rect.x = 0
if self.player.rect.x > C.SCREEN_W -16*C.PLAYER_MULTI:
self.player.rect.x = C.SCREEN_W -16*C.PLAYER_MULTI
self.player.rect.y += self.player.y_vel
def draw(self, surface):
surface.blit(self.background,(0,0))
surface.blit(self.player.image, self.player.rect)
self.info.draw(surface)

@ -0,0 +1,21 @@
from .. components import info
import pygame
class LoadScreen:
def __init__(self):
self.finished = False
self.next = 'level'
self.timer = 0
self.info = info.Info('load_screen')
def update(self,surface,keys):
self.draw(surface)
if self.timer == 0:
self.timer = pygame.time.get_ticks() # 如果初始时间为零改为当前时间
elif pygame.time.get_ticks() - self.timer > 2000:
self.finished = True
self.timer = 0
def draw(self,surface):
surface.fill((0,0,0))
self.info.draw(surface)

@ -0,0 +1,60 @@
# 主菜单
import pygame
from .. import setup
from .. import tools
from .. import constants as C
from ..components import info
class MainMenu:
def __init__(self):
self.setup_background() # 设置底图
self.setup_player() # 设置玩家
self.setup_cursor() # 设置光标
self.info = info.Info('main_menu')
self.finished = False
self.next = 'load_screen'
def setup_background(self):
self.background = setup.GRAPHICS['level_1']
self.background_rect = self.background.get_rect()
self.background = pygame.transform.scale(self.background,(int(self.background_rect.width * C.BG_MULTI),
int(self.background_rect.height * C.BG_MULTI)))
self.viewport = setup.SCREEN.get_rect()
self.caption = tools.get_image(setup.GRAPHICS['title_screen'],1,60,176,88,(255,0,220),C.BG_MULTI)
def setup_player(self):
self.player_image = tools.get_image(setup.GRAPHICS['mario_bros'],178,32,12,16,(0,0,0),C.PLAYER_MULTI)
def setup_cursor(self):
self.cursor = pygame.sprite.Sprite()
self.cursor.image = tools.get_image(setup.GRAPHICS['item_objects'], 24, 160, 8, 8, (0, 0, 0), C.PLAYER_MULTI)
rect = self.cursor.image.get_rect()
rect.x,rect.y = (220,360)
self.cursor.rect = rect
self.cursor.state = '1p' # 状态机
def update_cursor(self,keys):
if keys[pygame.K_UP]:
self.cursor.state = '1p'
self.cursor.rect.y = 360
elif keys[pygame.K_DOWN]:
self.cursor.state = '2p'
self.cursor.rect.y = 405
elif keys[pygame.K_RETURN]:
if self.cursor.state == '1p':
self.finished = True
elif self.cursor.state == '2p':
self.finished = True
def update(self, surface,keys):
self.update_cursor(keys)
surface.blit(self.background, self.viewport)
surface.blit(self.caption,(170,100))
surface.blit(self.player_image,(110,490))
surface.blit(self.cursor.image,self.cursor.rect)
self.info.update()
self.info.draw(surface)

@ -0,0 +1,58 @@
# 游戏主控区域
import os
import pygame
import random
class Game:
def __init__(self,state_dict,start_state):
self.screen = pygame.display.get_surface() # 获取屏幕图层
self.clock = pygame.time.Clock()
self.keys = pygame.key.get_pressed()
self.state_dict = state_dict
self.state = self.state_dict[start_state]
def update(self):
if self.state.finished:
next_state = self.state.next
self.state.finished = False
self.state = self.state_dict[next_state]
self.state.update(self.screen, self.keys)
def run(self):
while True:
for event in pygame.event.get(): # 获取鼠标键盘事件
if event.type == pygame.QUIT:
pygame.display.quit() # 退出游戏
elif event.type == pygame.KEYDOWN: # 按键按下
self.keys = pygame.key.get_pressed() # 按键状态
elif event.type == pygame.KEYUP:
self.keys = pygame.key.get_pressed()
self.update()
pygame.display.update() # 更新屏幕
self.clock.tick(60)
def load_graphics(path,accept=(',jpg','.png','.bpm','.gis')): # 那些后缀允许读入
graphics = {} #新建空字典
for pic in os.listdir(path):
name,ext = os.path.splitext(pic) # 拆分文件名+后缀
if ext.lower() in accept: # 如果允许格式就允许使用pygame允许载入
img = pygame.image.load(os.path.join(path,pic))
if img.get_alpha():
img = img.convert_alpha()
else:
img = img.convert()
graphics[name] = img
return graphics
def get_image(sheet,x,y,width,height,colorkey,scale): #从已经加载好图片获取某部分
image = pygame.Surface((width,height))
image.blit(sheet,(0,0),(x,y,width,height)) # 00代表到哪个位置x,y,w,h表示取出区域
image.set_colorkey(colorkey)
image = pygame.transform.scale(image, (int(width*scale),int(height*scale)))
return image
Loading…
Cancel
Save