目录
1 秋水黛眉
当女朋友心情不好时,应该给她准备一个小惊喜,让她开心。现送她一首情诗,然后写一个小游戏送给她,用Python实现。
秋水黛眉
未曾谋面已相知,倾谈无止夜迟迟。
忆昔宝剑未得鞘 , 尘染锋刃无人识。
对影空饮千杯酒,终逢红颜一知己。
迎春花前人俏立,目如秋水黛眉低。
2 关于”美”的哲思
画家齐白石说,”美”的意境全在似与不似之间。”似”则流于眉俗,”不似”又流于欺世。可这两者之间如何度量,又如何让人立足呢?看来,”美”实在是一种恼人的迷恋,它越是扑朔迷离就越显得美,由此造成了不可企及的无限追求——是困顿,还是陶醉?是明白,还是迷茫?是收获,还是失却?是欣赏还是占有?
此乃永恒的两难,又是无尽的焦灼。所以 培根说,形体之美胜于颜色之美,而优雅之美又胜于形体之美。那是由于颜色之美尽在眼前,形体之美已有些难于描述,而优雅之美纯属精神化的幻觉,因而它美不胜收。
也所以, 最深刻的三位大哲,即柏拉图、康德和黑格尔都要把美的渊源归于”理念”,那是由于客观的东西你尽可信手拈来,获得的瞬间便丢失了美感,唯有其画为意蕴,涵蓄心田,美的芬芳才会弥漫开来。
以上是我对”美”的思考。
3 保卫森林
送给女朋友的保卫森林
4 Python实现
#==============导入相关库===================#
import cfg
import pygame
from modules import *
#==============主函数=====================#
def main():
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(cfg.AUDIOPATHS['bgm'])
pygame.mixer.music.play(-1, 0.0)
pygame.mixer.music.set_volume(0.25)
screen = pygame.display.set_mode(cfg.SCREENSIZE)
pygame.display.set_caption("送给女朋友的游戏")
#=========调用游戏开始界面================#
start_interface = StartInterface(cfg)
is_play = start_interface.update(screen)
if not is_play:
return
#=========调用游戏界面==================#
while True:
choice_interface = ChoiceInterface(cfg)
map_choice, difficulty_choice = choice_interface.update(screen)
game_interface = GamingInterface(cfg)
game_interface.start(screen, map_path=cfg.MAPPATHS[str(map_choice)], difficulty_path=cfg.DIFFICULTYPATHS[str(difficulty_choice)])
end_interface = EndInterface(cfg)
end_interface.update(screen)
#============运行======================#
if __name__ == '__main__':
main()
cfg库:
#=======配置文件==========#
import os
#======屏幕大小==========#
SCREENSIZE = (800, 600)
#=====图片路径==========#
IMAGEPATHS = {
'choice': {
'load_game': os.path.join(os.getcwd(), 'resources/images/choice/load_game.png'),
'map1': os.path.join(os.getcwd(), 'resources/images/choice/map1.png'),
'map1_black': os.path.join(os.getcwd(), 'resources/images/choice/map1_black.png'),
'map1_red': os.path.join(os.getcwd(), 'resources/images/choice/map1_red.png'),
'map2': os.path.join(os.getcwd(), 'resources/images/choice/map2.png'),
'map2_black': os.path.join(os.getcwd(), 'resources/images/choice/map2_black.png'),
'map2_red': os.path.join(os.getcwd(), 'resources/images/choice/map2_red.png'),
'map3': os.path.join(os.getcwd(), 'resources/images/choice/map3.png'),
'map3_black': os.path.join(os.getcwd(), 'resources/images/choice/map3_black.png'),
'map3_red': os.path.join(os.getcwd(), 'resources/images/choice/map3_red.png'),
},
'end': {
'gameover': os.path.join(os.getcwd(), 'resources/images/end/gameover.png'),
'continue_red': os.path.join(os.getcwd(), 'resources/images/end/continue_red.png'),
'continue_black': os.path.join(os.getcwd(), 'resources/images/end/continue_black.png'),
},
'game': {
'arrow1': os.path.join(os.getcwd(), 'resources/images/game/arrow1.png'),
'arrow2': os.path.join(os.getcwd(), 'resources/images/game/arrow2.png'),
'arrow3': os.path.join(os.getcwd(), 'resources/images/game/arrow3.png'),
'basic_tower': os.path.join(os.getcwd(), 'resources/images/game/basic_tower.png'),
'boulder': os.path.join(os.getcwd(), 'resources/images/game/boulder.png'),
'bush': os.path.join(os.getcwd(), 'resources/images/game/bush.png'),
'cave': os.path.join(os.getcwd(), 'resources/images/game/cave.png'),
'dirt': os.path.join(os.getcwd(), 'resources/images/game/dirt.png'),
'enemy_blue': os.path.join(os.getcwd(), 'resources/images/game/enemy_blue.png'),
'enemy_pink': os.path.join(os.getcwd(), 'resources/images/game/enemy_pink.png'),
'enemy_red': os.path.join(os.getcwd(), 'resources/images/game/enemy_red.png'),
'enemy_yellow': os.path.join(os.getcwd(), 'resources/images/game/enemy_yellow.png'),
'godark': os.path.join(os.getcwd(), 'resources/images/game/godark.png'),
'golight': os.path.join(os.getcwd(), 'resources/images/game/golight.png'),
'grass': os.path.join(os.getcwd(), 'resources/images/game/grass.png'),
'healthfont': os.path.join(os.getcwd(), 'resources/images/game/healthfont.png'),
'heavy_tower': os.path.join(os.getcwd(), 'resources/images/game/heavy_tower.png'),
'med_tower': os.path.join(os.getcwd(), 'resources/images/game/med_tower.png'),
'nexus': os.path.join(os.getcwd(), 'resources/images/game/nexus.png'),
'othergrass': os.path.join(os.getcwd(), 'resources/images/game/othergrass.png'),
'path': os.path.join(os.getcwd(), 'resources/images/game/path.png'),
'rock': os.path.join(os.getcwd(), 'resources/images/game/rock.png'),
'tiles': os.path.join(os.getcwd(), 'resources/images/game/tiles.png'),
'unitfont': os.path.join(os.getcwd(), 'resources/images/game/unitfont.png'),
'water': os.path.join(os.getcwd(), 'resources/images/game/water.png'),
'x': os.path.join(os.getcwd(), 'resources/images/game/x.png'),
},
'pause': {
'gamepaused': os.path.join(os.getcwd(), 'resources/images/pause/gamepaused.png'),
'resume_black': os.path.join(os.getcwd(), 'resources/images/pause/resume_black.png'),
'resume_red': os.path.join(os.getcwd(), 'resources/images/pause/resume_red.png'),
},
'start': {
'play_black': os.path.join(os.getcwd(), 'resources/images/start/play_black.png'),
'play_red': os.path.join(os.getcwd(), 'resources/images/start/play_red.png'),
'quit_black': os.path.join(os.getcwd(), 'resources/images/start/quit_black.png'),
'quit_red': os.path.join(os.getcwd(), 'resources/images/start/quit_red.png'),
'start_interface': os.path.join(os.getcwd(), 'resources/images/start/start_interface.png'),
},
}
#=================地图路径================================#
MAPPATHS = {
'1': os.path.join(os.getcwd(), 'resources/maps/1.map'),
'2': os.path.join(os.getcwd(), 'resources/maps/2.map'),
'3': os.path.join(os.getcwd(), 'resources/maps/3.map'),
}
#==============字体路径==================================#
FONTPATHS = {
'Calibri': os.path.join(os.getcwd(), 'resources/fonts/Calibri.ttf'),
'm04': os.path.join(os.getcwd(), 'resources/fonts/m04.ttf'),
'Microsoft Sans Serif': os.path.join(os.getcwd(), 'resources/fonts/Microsoft Sans Serif.ttf'),
}
#============不同难度的settings========================#
DIFFICULTYPATHS = {
'easy': os.path.join(os.getcwd(), 'resources/difficulties/easy.json'),
'hard': os.path.join(os.getcwd(), 'resources/difficulties/hard.json'),
'medium': os.path.join(os.getcwd(), 'resources/difficulties/medium.json'),
}
#============音频路径=================================#
AUDIOPATHS = {
'bgm': os.path.join(os.getcwd(), 'resources/audios/bgm.mp3'),
}
5 资源获取——百度网盘
链接:https://pan.baidu.com/s/1rHmzM-TN1elDXErbcS3S-A
提取码:5kbh
Original: https://blog.csdn.net/weixin_46039719/article/details/122849346
Author: 荔枝科研社
Title: 目如秋水黛眉低——游戏保卫森林(Python实现)
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/781285/
转载文章受原作者版权保护。转载请注明原作者出处!