火爆全网的"人生重开模拟器",10分钟轻松帮你搭建

火爆全网的"人生重开模拟器",10分钟轻松帮你搭建

编程文章jaq1232025-06-21 20:31:109A+A-

人生重开模拟器是最近爆火的一款非常好玩的模拟游戏,会带你走入一个有趣的世界,开启全新的人生旅程,即"人生重开"。

然而实际上,这款游戏短短在3天内上线,在百度贴吧、朋友圈、QQ群、微博等各大平台纷纷刷屏。

在最开始,我们需要在系统随机给出的10个天赋中选3个,如图所示:

比如你可以选桃花连连(可提升恋爱机会)、佛宗(可提高考上哈佛大学的几率)、足量(身高不矮)......

需要注意的是,每次重开的天赋选项都不是相同的

游戏后续的发展也都会根据我们的选项进行调整,小伙伴们可以亲自去尝试一下。

记得回来告诉小编活到了多少岁!下面附上小编的:

咳咳,回到正题,如此简单、好玩的游戏,是如何搭建出来的呢?

1、下载代码(如果下载失败,请查看文章结处);2、部署环境;3、运行起来;4、静态化(Nginx)运行;5、调试。

#01 下载代码 
##
git clone 
https://github.com/VickScarlet/lifeRestart.git 
/app/liferestart-src/ 

#02 部署环境 
#人生重启项目是js+css+html,使用的是node框架,这里需要安装 nodejs 

##下载nodejs 
wget -P /server/tools 
https://nodejs.org/dist/v14.17.6/node-v14.17.6-linux- x64.tar.xz 
tar xf /server/tools/node-v14.17.6-linux-x64.tar.xz - C /app/ 
ln -s /app/node-v14.17.6-linux-x64 /app/node 

##配置nodejs 
echo 'export PATH=/app/node/bin/:$PATH #oldboylidao' >>/etc/profile 
source /etc/profile 

##检查环境 
[root@nfs ~]# node -v 
v14.17.6 
[root@nfs ~]# npm -v 
6.14.15 

#03 运行起来 
cd /app/liferestart-src/ 
npm install 
npm run dev 
#检查是否有8080端口,然后通过浏览器访问即可.
http://10.0.0.31:8080/view/  
#后面有了nginx也可以用域名访 问 #10.0.0.31是你本机ip地址


#04 静态化 
#node直接运行效率还是比较低,一般用于测试环境 
#需要静态化然后扔给nginx处理. 
##静态化 
npm run build 
##把静态目录拷到 nginx站点目录下面 这里设置 为/app/liferestart/ 
yum install -y nginx #无法安装nginx请配置epel源 ubt debian用户直接apt install 即可 
systemctl enable nginx 
systemctl start nginx 
#注意nginx.conf并没有修改与配置 
[root@oldboy-life ~# cat 
/etc/nginx/conf.d/liferestart.conf 
server { 
    listen 80; 
    server_name liferestart.oldboyedu.com; 
    set $lidao_root "/app/liferestart"; 
    root $lidao_root/view; 
    access_log 
/var/log/nginx/access_liferestart.oldboyedu.com.log main; 
    error_log 
/var/log/nginx/error_liferestart.oldboyedu.com.log error;
    location / { 
    index index.html ; 
    }
    location /data { 
    alias $lidao_root/data; 
    }
    location /public { 
    alias $lidao_root/public; 
    } 
}

#05 运行与测试 
通过浏览器使用域名访问,liferestart.oldboyedu.com


做下课后总结:

1) 此次小游戏主要涉及到的是前端技术,即node.js;

2) 对于从事运维工作的小伙伴,只需要Nginx运行即可,简单粗暴;

3) 对于无法下载资源的小伙伴,请关注公众号【老男孩Linux】即可获取大礼包!

点击这里复制本文地址 以上内容由jaq123整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

苍茫编程网 © All Rights Reserved.  蜀ICP备2024111239号-21