游戏网站开发学习笔记(二)
这两天进度有些慢,一直在忙着看闲书了。赶紧赶上,闲话少说,言归正传。
学习js,我个人认为,重要的是与用户的交互性要强,否则感觉就和单纯的html页面没区别了。针对用户与机器交互内容的不同,页面做出相应的、不同的反应,增强灵活性,考虑到各种情况,就能作出不同的反应。
最近,做了一个填字游戏,就是根据用户输入的条件,生成一个简单的小故事。
上代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Gregs' Gambits|Greg's Tales</title>
<link rel="stylesheet" href="../carla/carla.css" />
<script type="text/javascript">
function startGame(){
var gender="boy";
var city=" ";
var monster=" ";
var food=" ";
var drink=" ";
numYears=prompt("Enter a number greater than 0:");
gender=prompt("Is the story about a boy or a girl?");
letter=gender.charAt(0);
gender=(letter=="b"||letter=="B")?"boy":"girl";
pronoun=(gender=="boy")?"he":"she";
name=prompt("Enter the hero's name:");
city=prompt("Enter a name of the city:");
monster=prompt("Enter a type of a monster:");
food=prompt("Enter a food of you like:");
drink=prompt("Enter a drink of you like:");
document.getElementById("content").innerHTML=("Once up a time,about"+numYears+"years ago,therre was a"+gender+" named "+name+"." +name+"lived in a small carbin in the woods just outside"+city+" limits.</p> <p>"
+name+" enjoy walking in the woods every day until... One day "+pronoun+" come upon a "+monster+" sitting on a log eating a "+food+" .</p> <p>The"
+monster+" jumped up,spilling his "+drink+" ."+name+" ran home as fast as"
+pronoun+" could but the "+monster+" followed and ...</p><h3>What happed? you decide!</h3><p>Ending 1:The "
+monster+" and "+name+" became the best friends.</p><p>Ending 2:The "+monster+" overpowered "+name+" and gobbled down all the "+food+" and "
+drink+" in "+name+" 's refrigerator.</p> <p>Ending 3:"+name+" screaming mean things at the "+monster+" ,casuing the "
+monster+" to turn and run back to the woods,never to be seen again.</p>");
}
</script>
</head>
<body>
<div id="container">
<img src="../images/superhero.jpg" class="floatleft" />
<h1><em>Greg's tales</em></h1>
<h3>
For this game, you will create a story by entering words as prompted.
The story will change each time you run this game,as you enter different words.
</h3>
<div id="nav">
<p><a href="index.html">Home</a>
<a href="greg.html">About Greg</a>
<a href="greg-table.html">Play a Game</a>
<a href="sign.html">Sign In</a>
<a href="contact.html">Contact Us</a>
<a href="aboutme.html">Tell me about you</a>
</p>
</div>
<div id="content">
<p> </p>
<input type="button"value="click to begin"οnclick="startGame()" /></div>
<div id="footer">Copyright © 2018 Greg's Gambits<br />
<a href="mailto:yourfirstname@yourlastname.com">登陆邮箱</a></div>
</div>
</body>
</html>
好了,今天分享到这儿,希望各位大神能够多多指教,欢迎留言。
再续。。。
游戏网站开发学习笔记(二)相关推荐
- 游戏网站开发学习笔记(一)
已经好久没有更新博客了,现在是寒假时间,在家无聊准备学习JS. 哈哈,很佩服自己.其实也是借助写博客督促自己,希望我能够这个寒假坚持下去.毕竟我也认识到了自己有很多的不足,时间紧迫,只能加油啊. 话不 ...
- Polyworks脚本开发学习笔记(二十)-补充几个常见操作指令的使用
Polyworks脚本开发学习笔记(二十)-补充几个常见操作指令的使用 大概要写到结尾了,最后几篇就将手册的各常用命令再看一遍,组合一下,并列举出常见的一些有用的操作. DATA_COLOR_MAP数 ...
- Polyworks脚本开发学习笔记(二)-TREEVIEW基本操作
Polyworks脚本开发学习笔记(二)-TREEVIEW对象基本操作 TREEVIEW对象选择 选择/不选对象 TREEVIEW OBJECT SELECT ALL 全部对象选择,包括参考/数据/对 ...
- Polyworks脚本开发学习笔记(二二)-调取视角用脚本自动生成报告
Polyworks脚本开发学习笔记(二二)-调取视角用脚本自动生成报告 Polyworks中,3D场景的视图可用标准视角及等轴侧视角.项目视角等方式调用,也可以用txt格式保存下来调用,如果以脚本的形 ...
- 毕业设计网站开发学习笔记(一)
毕业设计是基于C#和HTML5的在线音乐网站设计,下载了visual studio 2017准备开发.这个软件可以写页面也可以开发后台,很方便了. 项目的创建: ASP.NET WEB,visual ...
- 龙芯1C300B主板V3.4嵌入式开发学习笔记二
1 PMON更新 接着笔记一:https://blog.csdn.net/weixin_38709708/article/details/81271493 笔者手中的开发板一开始就烧写了PMON,当是 ...
- iOS开发学习笔记二:UITableView(1)
一:TableViewController 1:删掉默认的ViewController 拖动一个TableViewController 2:新建一个Cocoa Touch Class,命名为:Tabl ...
- linux驱动开发学习笔记二十一:异步通知
一.异步通知简介 我们首先来回顾一下"中断",中断是处理器提供的一种异步机制,我们配置好中断以后就可以让处理器去处理其他的事情了,当中断发生以后会触发我们事先设置好的中断服务函数, ...
- 微信平台开发学习笔记二(翻译功能的实现)
参考http://www.cnblogs.com/mchina/p/3170565.html 不过看看这些前辈写这些东西的时间,就是感慨啊,13年我还没用微信呢 这里只是简单的实现有道的翻译功能,并且 ...
最新文章
- gcc 从5.3升级到6.1之后 openwrt pkg-config glib编译报错修复办法
- mysqldump备份数据库时出现when using LOCK TABLES
- windows server 2008R2 上安装配置freesshd
- centos下docker1.7 上传文件到容器报错 Error: Path not specified
- 整数因子分解c语言递归,整数因子分解:计算一个整数所有的分解式(递归实现)...
- String Table MFC
- 读书笔记_打开量化投资的黑箱01
- python积分计算_fx-CG系列图形计算器CAS应用程序Khicasen
- 学习总结 java Iterator迭代器练习
- Pandas标签统计
- web端常用手机号,邮箱,税号,组织机构代码,银行卡号等JS正则校验表达式总结
- 生信可视化(part2)--箱线图
- 埃尔米特多项式 (Hermite Polynomials)简介(2)
- Android集成微信支付SDK,实现支付功能
- css简单样式(旋转正方形、纸片旋转、轮播图3D、简单轮播图)
- 对View的onMeasure方法理解
- 无广告,小体积,实用性拉满的5款软件
- 使用计算机提高办公效率,掌握这四个电脑办公小技巧,你的工作效率至少提升3倍!要高调使用...
- 什么知识库工具适合小团队?看看文档管理系统+NAS的最新解决方案
- 打印从1到最大的n位数——《剑指offer》