Eternal Nigh是本人独立编写18天完成的游戏,本品尚未完结,请各位大佬多多指教(发私信给我),谢谢!
点个关注吧,关注必互关注
👩💻博客主页:孤雪落尘风的博客主页
✨欢迎关注🖱点赞🎀收藏⭐留言✒
🔮本文由孤雪落尘风原创,csdn首发!
😘系列专栏:pygame zero特训
🎨你的收入跟你的不可替代成正比
🀄如果觉得博主的文章还不错的话,请三连支持一下博主哦
(游戏名Eternal Nigh是《永夜》的英文)
注意:本游戏内为全英文。
以下是效果图
内置服务系统命令大全
help
帮助
system-information
获取系统信息
game keyboard
游戏键位介绍
game rules
游戏规则
achievement
成就
player_information
玩家信息
项目结构图
Eternal Night
-game.py
-index.html
-images
-sound
-data
game_data.json
-Update Log
-ul1.py
-il2.py
-package
-__init__.py
-func1_talk.py
-func2_move.py
-func3_dialogue.py
-func4_tools
-func5_set_time
代码部分
game.py
# writer:gxlcf
# email:
# telephone number:
# Blog: https://blog.csdn.net/gxlcf_516312?type=sub&subType=fans
import time
import json
import random
import pgzrun
import pakage.func1_talk
import pakage.func2_move
import pakage.func3_dialogue
import pakage.func4_tools
import pakage.func5_set_time
import pakage.func6_service_system
WIDTH = 1000
HEIGHT = 660
with open("buff.json","r") as f:
buff = json.load(f)
with open("list_sd.json","r") as f:
list_sd = json.load(f)
with open("list_sx.json","r") as f:
list_sx = json.load(f)
start = False
tree_on = False
tree_choose = False
blood_volume = 1000
update_time = 60
ready = Actor('ready',(WIDTH/2,HEIGHT/2+20))
person = Actor('person',(WIDTH/2,HEIGHT/2))
gui = [Actor('gui_up_1', (260,15)),Actor('gui_up_1', (780,15)),Actor('gui_up_1', (260, 645)),Actor('gui_up_1', (780, 645))]
anu = [Actor("gn", (50, 15)),Actor("qd", (200, 15)),Actor("ggl", (350, 15)),Actor("dzp", (500, 15)),Actor("wqk", (650, 15)),Actor("zyk", (800, 15)),Actor("hy", (950, 15)),Actor("wd", (50,645)),Actor('bc',(950,645))]
sd = [Actor('sd',(2080,100)),Actor('sd',(2080,200)),Actor('sd',(2080,300)),Actor('sd',(2080,400)),Actor('sd',(2080,500))]
sx = [Actor('sx',(2200,100)),Actor('sx',(2200,200)),Actor('sx',(2200,300))]
print(pakage.func3_dialogue.dialogue_start.__doc__)
# 显示
def draw():
global start,gui,anu,tree_on
screen.fill('grey')
ready.draw()
person.draw()
for j in range(3):
sx[j].draw()
for j in range(5):
sd[j].draw()
for j in range(4):
gui[j].draw()
for j in range(9):
anu[j].draw()
#接收键盘
def update():
global start,buff,blood_volume,update_time,tree_on,tree_choose
if (update_time == 60): # 血量提醒
update_time = 0
pakage.func4_tools.ab_blood_volume(blood_volume)
else:
update_time += 1
if (keyboard.w): #以下为角色移动
person.x += 3*buff["speed"]
if (keyboard.s):
person.x -= 3*buff["speed"]
if (keyboard.a):
person.y -= 3*buff["speed"]
if (keyboard.d):
person.y += 3*buff["speed"]
if (keyboard.r):
if tree_choose == False:
tree_choose = True
for j in range(5):
sd[j].x = 80
for j in range(3):
sx[j].x = 200
else:
tree_choose = False
for j in range(5):
sd[j].x = 2080
for j in range(3):
sx[j].x = 2200
if (keyboard.h):
pakage.func6_service_system.help_api()
def on_mouse_down(pos):
global start,gui,anu,list_sd,buff,list_sx
if (ready.collidepoint(pos)):
pakage.func2_move.go_var(ready)
for j in range(4):
pakage.func2_move.go_var(gui[j])
for j in range(9):
pakage.func2_move.go_var(anu[j])
if sd[0].collidepoint(pos):
if list_sd[0] == True:
print("Already")
buff["speed"] += 0.3
else:
print("You cannot")
for j in range(4):
if sd[j+1].collidepoint(pos):
if list_sd[j] == True:
print("Already")
list_sd[j+1] = True
buff["speed"] += (j+1)*0.3
else:
print("You cannot")
if sx[0].collidepoint(pos):
if list_sx[0] == True:
print("Already")
buff["speed"] += 0.3
else:
print("You cannot")
for j in range(2):
if sx[j+1].collidepoint(pos):
if list_sx[j] == True:
print("Already")
list_sx[j+1] = True
buff["speed"] += (j+1)*0.3
else:
print("You cannot")
if (anu[0].collidepoint(pos)):
pass
if (anu[1].collidepoint(pos)):
pass
if (anu[2].collidepoint(pos)):
pass
if (anu[3].collidepoint(pos)):
pass
if (anu[4].collidepoint(pos)):
pass
if (anu[5].collidepoint(pos)):
pass
if (anu[6].collidepoint(pos)):
pass
if (anu[7].collidepoint(pos)):
pass
if (anu[8].collidepoint(pos)):
with open("buff.json", "w") as f:
json.dump(buff, f)
with open("list_sd.json", "w") as f:
json.dump(list_sd, f)
with open("list_sx.json", "w") as f:
json.dump(list_sx, f)
pgzrun.go()
with open("buff.json","w") as f:
json.dump(buff,f)
with open("list_sd.json","w") as f:
json.dump(list_sd,f)
with open("list_sx.json","w") as f:
json.dump(list_sx,f)
pakage.func1.talk
right_in = False
def nap():
global right_in
while right_in == False:
try:
name = str(input())
password = int(input())
right_in = True
except Exception as e:
print('用户名和密码必须为数字')
name = str(input())
password = int(input())
return name,password
pakage.func2.move
def go_var(obj):
obj.x += 2000
def come_var(obj):
obj.x -= 2000
pakage.func3.dialogue
def dialogue_start():
"""
Welcome to Future Night, please login,.Thank you.
"""
def game_start():
"""
The game start.
"""
def ab_blood_volume(blood_volume):
if (blood_volume<100):
print("You maybe die")
if (blood_volume<30):
print("You will die")
if (blood_volume == 0):
print("You are die")
if (blood_volume < 30):
print("You will die")
if (blood_volume == 0):
print("You are die")
def elevator_radio_broadcast(energy,player_level,elevator_level):
"""
The elevator has been reopened.
"""
if energy/player_level >= elevator_level:
print("""
RUN!!!
Be faster!!!""")
def notice_radio_broadcast1():
"""
The night is coming.
Hhhhhhh
Ohh
Helppp... Meeee...
"""
def notice_radio_broadcast2():
"""
No!!!
He's coming.
Run!!!
"""
def notice_radio_broadcast3():
"""
I'm coming
Hhhhaa...
"""
def pet1():
"""
I feel a little bit wrong.
"""
def npc_oldman1():
"""
Please Be Careful.
"""
def die():
"""
You are die.
"""
def end_say(player):
"""
I see the player you mean.
PLAYERNAME
Yes. Take care. It has reached a higher level now. It can read our thoughts.
That doesn't matter. It thinks we are part of the game.
I like this player. It played well. It did not give up.
It is reading our thoughts as though they were words on a screen.
That is how it chooses to imagine many things, when it is deep in the dream of a game.
Words make a wonderful interface. Very flexible. And less terrifying than staring at the reality behind the screen.
They used to hear voices. Before players could read. Back in the days when those who did not play called the players witches, and warlocks. And players dreamed they flew through the air, on sticks powered by demons.
What did this player dream?
This player dreamed of sunlight and trees. Of fire and water. It dreamed it created. And it dreamed it destroyed. It dreamed it hunted, and was hunted. It dreamed of shelter.
Hah, the original interface. A million years old, and it still works. But what true structure did this player create, in the reality behind the screen?
It worked, with a million others, to sculpt a true world in a fold of the , and created a for , in the .
It cannot read that thought.
No. It has not yet achieved the highest level. That, it must achieve in the long dream of life, not the short dream of a game.
Does it know that we love it? That the universe is kind?
Sometimes, through the noise of its thoughts, it hears the universe, yes.
But there are times it is sad, in the long dream. It creates worlds that have no summer, and it shivers under a black sun, and it takes its sad creation for reality.
To cure it of sorrow would destroy it. The sorrow is part of its own private task. We cannot interfere.
Sometimes when they are deep in dreams, I want to tell them, they are building true worlds in reality. Sometimes I want to tell them of their importance to the universe. Sometimes, when they have not made a true connection in a while, I want to help them to speak the word they fear.
It reads our thoughts.
Sometimes I do not care. Sometimes I wish to tell them, this world you take for truth is merely and , I wish to tell them that they are in the . They see so little of reality, in their long dream.
And yet they play the game.
But it would be so easy to tell them...
Too strong for this dream. To tell them how to live is to prevent them living.
I will not tell the player how to live.
The player is growing restless.
I will tell the player a story.
But not the truth.
No. A story that contains the truth safely, in a cage of words. Not the naked truth that can burn over any distance.
Give it a body, again.
Yes. Player...
Use its name.
PLAYERNAME. Player of games.
Good.
Take a breath, now. Take another. Feel air in your lungs. Let your limbs return. Yes, move your fingers. Have a body again, under gravity, in air. Respawn in the long dream. There you are. Your body touching the universe again at every point, as though you were separate things. As though we were separate things.
Who are we? Once we were called the spirit of the mountain. Father sun, mother moon. Ancestral spirits, animal spirits. Jinn. Ghosts. The green man. Then gods, demons. Angels. Poltergeists. Aliens, extraterrestrials. Leptons, quarks. The words change. We do not change.
We are the universe. We are everything you think isn't you. You are looking at us now, through your skin and your eyes. And why does the universe touch your skin, and throw light on you? To see you, player. To know you. And to be known. I shall tell you a story.
Once upon a time, there was a player.
The player was you, PLAYERNAME.
Sometimes it thought itself human, on the thin crust of a spinning globe of molten rock. The ball of molten rock circled a ball of blazing gas that was three hundred and thirty thousand times more massive than it. They were so far apart that light took eight minutes to cross the gap. The light was information from a star, and it could burn your skin from a hundred and fifty million kilometres away.
Sometimes the player dreamed it was a miner, on the surface of a world that was flat, and infinite. The sun was a square of white. The days were short; there was much to do; and death was a temporary inconvenience.
Sometimes the player dreamed it was lost in a story.
Sometimes the player dreamed it was other things, in other places. Sometimes these dreams were disturbing. Sometimes very beautiful indeed. Sometimes the player woke from one dream into another, then woke from that into a third.
Sometimes the player dreamed it watched words on a screen.
Let's go back.
The atoms of the player were scattered in the grass, in the rivers, in the air, in the ground. A woman gathered the atoms; she drank and ate and inhaled; and the woman assembled the player, in her body.
And the player awoke, from the warm, dark world of its mother's body, into the long dream.
And the player was a new story, never told before, written in letters of DNA. And the player was a new program, never run before, generated by a sourcecode a billion years old. And the player was a new human, never alive before, made from nothing but milk and love.
You are the player. The story. The program. The human. Made from nothing but milk and love.
Let's go further back.
The seven billion billion billion atoms of the player's body were created, long before this game, in the heart of a star. So the player, too, is information from a star. And the player moves through a story, which is a forest of information planted by a man called Julian, on a flat, infinite world created by a man called Markus, that exists inside a small, private world created by the player, who inhabits a universe created by...
Shush. Sometimes the player created a small, private world that was soft and warm and simple. Sometimes hard, and cold, and complicated. Sometimes it built a model of the universe in its head; flecks of energy, moving through vast empty spaces. Sometimes it called those flecks "electrons" and "protons".
Sometimes it called them "planets" and "stars".
Sometimes it believed it was in a universe that was made of energy that was made of offs and ons; zeros and ones; lines of code. Sometimes it believed it was playing a game. Sometimes it believed it was reading words on a screen.
You are the player, reading words...
Shush... Sometimes the player read lines of code on a screen. Decoded them into words; decoded words into meaning; decoded meaning into feelings, emotions, theories, ideas, and the player started to breathe faster and deeper and realised it was alive, it was alive, those thousand deaths had not been real, the player was alive
You. You. You are alive.
and sometimes the player believed the universe had spoken to it through the sunlight that came through the shuffling leaves of the summer trees
and sometimes the player believed the universe had spoken to it through the light that fell from the crisp night sky of winter, where a fleck of light in the corner of the player's eye might be a star a million times as massive as the sun, boiling its planets to plasma in order to be visible for a moment to the player, walking home at the far side of the universe, suddenly smelling food, almost at the familiar door, about to dream again
and sometimes the player believed the universe had spoken to it through the zeros and ones, through the electricity of the world, through the scrolling words on a screen at the end of a dream
and the universe said I love you
and the universe said you have played the game well
and the universe said everything you need is within you
and the universe said you are stronger than you know
and the universe said you are the daylight
and the universe said you are the night
and the universe said the darkness you fight is within you
and the universe said the light you seek is within you
and the universe said you are not alone
and the universe said you are not separate from every other thing
and the universe said you are the universe tasting itself, talking to itself, reading its own code
and the universe said I love you because you are love.
And the game was over and the player woke up from the dream. And the player began a new dream. And the player dreamed again, dreamed better. And the player was the universe. And the player was love.
"""
pakage.func4_tools
import random
def ab_blood_volume(blood_volume):
if (blood_volume<100):
print("You maybe die")
if (blood_volume<30):
print("You will die")
if (blood_volume == 0):
print("You are die")
if (blood_volume < 30):
print("You will die")
if (blood_volume == 0):
pass
def elevator_radio_broadcast(energy,player_level,elevator_level):
"""
The elevator has been reopened.
"""
if energy/player_level >= elevator_level:
print("""
RUN!!!
Be faster!!!""")
def ran_finter():
W = ''
abz = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
L = random.randint(1,26)
for j in range(L):
W = W+abz[j]
dict_z = dict(zip(W,range(L)))
pakage.func5_set_time
import time
def mom_time():
return time.strftime('%m-%d', time.localtime())
def af_time():
return time.strftime('%m-%d', time.localtime())
def c_time(a,b,c):
c = b - a
return c
pakage.func6_service_system
import platform
h_time = 0
asn = ''
money = 0
def showinfo(tip, info):
print("{}:{}".format(tip, info))
def help_api():
global h_time,asn,money
h_time = int(input('Help times'))
for j in range(h_time):
asn = input()
if asn == 'system-information':
showinfo("Operating system and version information", platform.platform())
showinfo('System bits', platform.architecture())
showinfo('Computer type', platform.machine())
showinfo('Computer name', platform.node())
showinfo('Processor type', platform.processor())
elif asn == 'exit service':
break
else:
continue
print("Time is stop")