($width) AND $width .= 'px';
$style = " style=\"width: $width\"";
}
$value = $value ? $value : date('H:i');
$s = "";
return $s;
}
// form_date('start', '2018-07-05') 为空则当前日期
function form_date($name, $value = 0, $width = FALSE)
{
$style = '';
if (FALSE !== $width) {
is_numeric($width) AND $width .= 'px';
$style = " style=\"width: $width\"";
}
$value = $value ? $value : date('Y-m-d');
$s = "";
return $s;
}
/**用法
*
* echo form_radio_yes_no('radio1', 0);
* echo form_checkbox('aaa', array('无', '有'), 0);
*
* echo form_radio_yes_no('aaa', 0);
* echo form_radio('aaa', array('无', '有'), 0);
* echo form_radio('aaa', array('a'=>'aaa', 'b'=>'bbb', 'c'=>'ccc', ), 'b');
*
* echo form_select('aaa', array('a'=>'aaa', 'b'=>'bbb', 'c'=>'ccc', ), 'a');
*/
?>组保留的标签 余下为需要删除的标签
unset($oldtag[$key]);
}
}
}
if (!empty($oldtag)) {
$tagids = array();
foreach ($oldtag as $tagid => $tagname) {
$tagids[] = $tagid;
}
well_oldtag_delete($tagids, $tid);
}
$r = well_tag_process($tid, $fid, $create_tag, $tagarr);
return $r;
}
// 删除标签和绑定的主题
function well_oldtag_delete($tagids, $tid)
{
$pagesize = count($tagids);
$arrlist = well_tag_find_by_tagids($tagids, 1, $pagesize);
$delete_tagids = array(); // 删除
$tagids = array();
$n = 0;
foreach ($arrlist as $val) {
++$n;
if (1 == $val['count']) {
// 只有一个主题
$delete_tagids[] = $val['tagid'];
} else {
$tagids[] = $val['tagid'];
}
}
!empty($delete_tagids) and well_tag_delete($delete_tagids);
$arlist = well_tag_thread_find_by_tid($tid, 1, $n);
if ($arlist) {
$ids = array();
foreach ($arlist as $val) $ids[] = $val['id'];
well_tag_thread_delete($ids);
}
!empty($tagids) and well_tag_update($tagids, array('count-' => 1));
}
// 标签数据处理 $arr=新提交的数组 $tagarr=保留的旧标签
function well_tag_process($tid, $fid, $new_tags = array(), $tagarr = array())
{
if (empty($tid)) return '';
// 新标签处理入库
if ($new_tags) {
$threadarr = array();
$tagids = array();
$i = 0;
$size = 5;
$n = count($tagarr);
$n = $n > $size ? $size : $size - $n;
foreach ($new_tags as $name) {
++$i;
$name = trim($name);
$name = stripslashes($name);
$name = strip_tags($name);
$name = str_replace(array(' ', '#', "@", "$", "%", "^", '&', '·', '<', '>', ';', '`', '~', '!', '¥', '……', ';', '?', '?', '-', '—', '_', '=', '+', '.', '{', '}', '|', ':', ':', '、', '/', '。', '[', ']', '【', '】', '‘', ' ', ' ', ' ', ' ', ' '), '', $name);
$name = htmlspecialchars($name, ENT_QUOTES);
if ($name && $i <= $n) {
// 查询标签
$read = well_tag_read_name($name);
if ($read) {
// 存在 count+1
$tagids[] = $read['tagid'];
} else {
// 入库
$arr = array('name' => $name, 'count' => 1);
$tagid = well_tag_create($arr);
FALSE === $tagid and message(-1, lang('create_failed'));
$read = array('tagid' => $tagid, 'name' => $name);
}
$tag_thread = array('tagid' => $read['tagid'], 'tid' => $tid);
$threadarr[] = $tag_thread;
$tagarr[$read['tagid']] = $read['name'];
}
}
!empty($threadarr) and tag_thread_big_insert($threadarr);
!empty($tagids) and well_tag_update($tagids, array('count+' => 1));
}
$json = empty($tagarr) ? '' : xn_json_encode($tagarr);
return $json;
}
?>return $r;
}
/**
* @param int $page 页数
* @param int $pagesize 每页显示数量
* @return mixed
*/
function link_find($page = 1, $pagesize = 100)
{
$arr = link__find($cond = array(), array('rank' => -1), $page, $pagesize);
return $arr;
}
/**
* @param $id
* @return bool 返回FALSE失败 TRUE成功
*/
function link_delete($id)
{
if (empty($id)) return FALSE;
$r = link__delete(array('id' => $id));
link_delete_cache();
return $r;
}
//--------------------------kv + cache--------------------------
/**
* @return mixed 返回全部友情链接
*/
function link_get($page = 1, $pagesize = 100)
{
$g_link = website_get('friends_link');
if (empty($g_link)) {
$g_link = link_find($page, $pagesize);
$g_link AND website_set('friends_link', $g_link);
}
return $g_link;
}
// delete kv and cache
function link_delete_cache()
{
website_set('friends_link', '');
return TRUE;
}
?> $v = implode(",", $v);
$temp[] = $v;
}
// 去掉重复的字符串,也就是重复的一维数组
$temp = array_unique($temp);
// 再将拆开的数组重新组装
$output = array();
foreach ($temp as $k => $v) {
if ($stkeep) $k = $starr[$k];
if ($ndformat) {
$temparr = explode(",", $v);
foreach ($temparr as $ndkey => $ndval) $output[$k][$ndarr[$ndkey]] = $ndval;
} else $output[$k] = explode(",", $v);
}
return $output;
}
// 合并二维数组 如重复 值以第一个数组值为准
function array2_merge($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array1 as $k => $v) {
isset($v[$key]) ? $arr[$v[$key]] = array_merge($v, $array2[$k]) : $arr[] = array_merge($v, $array2[$k]);
}
return $arr;
}
/*
* 对二维数组排序 两个数组必须有一个相同的键值
* $array1 需要排序数组
* $array2 按照该数组key排序
* */
function array2_sort_key($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array2 as $k => $v) {
if (isset($v[$key]) && $v[$key] == $array1[$v[$key]][$key]) {
$arr[$v[$key]] = $array1[$v[$key]];
} else {
$arr[] = $v;
}
}
return $arr;
}
?>
【趣味】斗破苍穹修炼文字游戏HTML,CSS,JS-软件玩家 - 软件改变生活!
【趣味】斗破苍穹修炼文字游戏HTML,CSS,JS
实现一个简单的斗破苍穹修炼文字游戏,你可以使用HTML、CSS和JavaScript结合来构建游戏的界面和逻辑。以下是一个简化版的游戏框架示例,其中包含玩家修炼的过程、增加修炼进度和显示经验值的基本功能。
图片展示
游戏功能
- 修炼进度:每点击一次“开始修炼”按钮,修炼进度会增加,直到达到100%。
- 经验值:修炼过程中玩家会获得经验值。
- 提升修炼速度:玩家可以使用经验提升修炼速度,使得进度增长更快,但需要10个经验值才能提升。
扩展功能
- 可以加入更多的功能,比如通过挑战敌人或修炼特定技能来获得额外奖励。
- 添加物品系统,玩家可以使用道具增加修炼效率。
- 引入等级系统,让玩家逐步解锁新的修炼方法或技能。
这个代码框架为你提供了一个基本的文字游戏结构,可以根据你的需求进行扩展或修改。
完整代码
代码语言:javascript
代码运行次数:0运行
复制
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>斗破苍穹修炼文字游戏</title>
<link rel="stylesheet" href="style.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.game-container {
text-align: center;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
}
h1 {
font-size: 24px;
color: #333;
}
button {
padding: 10px 20px;
font-size: 16px;
margin-top: 20px;
cursor: pointer;
border: none;
background-color: #4CAF50;
color: white;
border-radius: 5px;
transition: background-color 0.3s;
}
button:hover {
background-color: #45a049;
}
button:disabled {
background-color: #ddd;
cursor: not-allowed;
}
</style>
</head>
<body>
<div class="game-container">
<h1>斗破苍穹 修炼游戏</h1>
<p id="story">你是一名修炼者,踏上了修炼的道路。</p>
<p>修炼进度: <span id="progress">0</span>%</p>
<p>经验值: <span id="exp">0</span></p>
<button id="trainBtn">开始修炼</button>
<button id="upgradeBtn" disabled>提升修炼速度</button>
</div>
<script>
// 获取页面元素
const storyElement = document.getElementById('story');
const progressElement = document.getElementById('progress');
const expElement = document.getElementById('exp');
const trainBtn = document.getElementById('trainBtn');
const upgradeBtn = document.getElementById('upgradeBtn');
// 游戏状态
let progress = 0; // 修炼进度
let exp = 0; // 经验值
let trainingSpeed = 1; // 修炼速度
// 修炼按钮点击事件
trainBtn.addEventListener('click', () => {
if (progress < 100) {
// 增加修炼进度和经验
progress += trainingSpeed;
exp += Math.floor(trainingSpeed / 2);
// 更新页面显示
progressElement.textContent = progress;
expElement.textContent = exp;
// 更新故事内容
storyElement.textContent = `你正在修炼,进度已达到${progress}%`;
// 检查是否完成修炼
if (progress >= 100) {
storyElement.textContent = `修炼完成!你成功突破了瓶颈,修为大增!`;
trainBtn.disabled = true;
upgradeBtn.disabled = false;
}
}
});
// 提升修炼速度按钮点击事件
upgradeBtn.addEventListener('click', () => {
if (exp >= 10) {
// 提升修炼速度
trainingSpeed += 1;
exp -= 10; // 消耗经验
// 更新页面显示
expElement.textContent = exp;
storyElement.textContent = `你的修炼速度提升了!当前修炼速度:${trainingSpeed}`;
// 禁用提升按钮
if (exp < 10) {
upgradeBtn.disabled = true;
}
} else {
storyElement.textContent = '经验不足,无法提升修炼速度!';
}
});
</script>
</body>
</html>
嗨,我是命运之光。如果你觉得我的分享有价值,不妨通过以下方式表达你的支持:
本文标签:
趣味斗破苍穹修炼文字游戏HTMLcssJS
更多相关文章
【Node.js】Node 环境下载与安装教程(Windows系统)
前言 Node.js是一个基于Chrome V8引擎的JavaScript运行时环境,可以让你使用JavaScript进行服务器端编程。本教程将向你展示如何在Windows系统上下载和安装Node.js环境。 下载
关于Windows和Mac系统,node.js如何升级
最近研究ng2,懂ng2的肯定都知道,他要求node版本在5以上,npm的版本在3以上。所以,得先升级node。但是这里需要注意的是࿰
网页中引用两个css冲突怎么办
方法一 细化选择符 假如全局是这样来定义一个元素的样式的:.abc {background:#000},同时某个元素的子元素也应用了一个.abc的样式,比如下面这样的html
hide part of the text html, css, javascript - Stack Overflow
How to hide part of the text inside div or span ? I have a text of 160 characters but I would like to d
widgets - Include chat (HTML, js, css) in all pages of WordPress
I need to add a chat widget in HTML, css and js, on all WP website. I tried the following in local (functions.php) and i
Spring MVC, CSS, and JavaScript is not working properly - Stack Overflow
The CSS and JavaScript is not take effect on my page.I googled online, people saying this is the magic
js中keycode被弃用,怎么办?
直接用code方法,识别功能键和字符键,与keycode不同:keycode返回的是ascll值 document.addEventListener("keydo
How do I set the z-Index of my element? JQuery, Javascript, CSS, HTML - Stack Overflow
Been trying for hours, but can't seem to figure out why adjusting the z-index does not affect the
How to connect backend (python, flask) with frontend (html, css, javascript) - Stack Overflow
Info: for backend I'm using python with flask (for the moment it accepts http get methods) and for
javascript - Windows Scripting: VBScript, DOS, JS, Python,- Stack Overflow
Say you were mainly a C-syntax like programmer and Linux systems administrator, and you were tasked wit
javascript - Overlapping elements - HTML, CSS, and jQuery - Stack Overflow
I have elements which are overlapping and I would like to prevent this. Here is a picture: Also, here i
JS中阻止浏览器的默认行为
阻止浏览器的默认行为的三种方式 阻止浏览器的默认行为 浏览器常见默认行为:1-a标签的点击跳转 2-表单中提交按钮的转跳 3-浏览器页面右键出现菜单 阻止事件的默认行为 1 e.preventDefaul
微信提示打开浏览器js代码
话不多说,直接上代码 *核心css* .wxtip{background: rgba(0,0,0,0.8); text-align: center; position: fixed; left:0; top:
手机如何安装GreasyFork油猴js脚本?
文章目录 前言一、狐猴浏览器(安卓)(苹果)(谷歌微软插件)二、Iceraven浏览器(火狐)(安卓)三、Via浏览器(安卓)
javascript - HTTP to HTTPS (stylesheets, js, css-sprites, etc) reloading - Stack Overflow
This question has nothing to do with the mixed content error. About to launch a site. When i navigate f
发表评论