<head>
<meta charset="UTF-8">
<title>Text Animation</title>
<style>
.text {
font-size: 26px;
color: red; /* 设置文本颜色为红色 */
}
</style>
</head>
<body>
<p>
<center>
<div class="text" style="display: inline;"></div>
</center>
</p>
</body>
<style>
.text {
font-size: 26px;
}
</style>
<script type="text/javascript">
obfu_data = {
"delay":0,
"start_time":40,
"end_time":40,
"disp_time":2000,
"loop":true,
"obfu_chars":"░▒▓▖▗▘▙▚▛▜▝▞▟",
"phrases":[
"这文超棒的<br>换行",
'真的超棒的',
'来个UV求求了',
'或者让作者把这玩意当bug修了吧',
'否则真要穷死了',
'来自https://scp-wiki-cn.wikidot.com/cn40raphmandas,又名“今天你领工资了吗”'
]
}
</script>
<script type="text/javascript" src="https://backrooms-wiki.wikidot.com/local--files/level-404/obfuscator.js"></script>
下面是C语言版本:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
struct Text_Animation{
char obfu_chars[20]; //过渡用乱码字符串
int start_tim; //多少帧后开始渐变
int end_tim; //多少帧后结束渐变
int disp_time; //每句话显示帧数
int loop; //是否循环显示
int idx; //当前显示的是第几句话
int fram; //当前是第几帧
char phrases[10][100]; //要显示的话
char showstr[100]; //当前显示的内容
};
struct task{
char from; //原字符
char to; //目标字符
int start; //开始时间
int end; //结束时间
};
struct task tasks[100];
struct Text_Animation t={
.obfu_chars = "asdfghjklqwertyuiop",
.start_tim = 0,
.end_tim = 40,
.disp_time = 80,
.loop = 1,
.idx = 0,
.fram = 0,
.phrases = {"Hello, world!\0", "This is a test1.", "dkajhsgdfkjhgasdfash2.", "我也不知道我要说什么.", "This is a test4.\0", "This is a test5.\0", "This is a test6.\0", "This is a test7.\0", "This is a test8.\0", "This is a test9.\0"},
.showstr = {'1','3','2','1','1','1','1','1',},
};
int Random(int n) { //以当前时间(秒为单位)为种子生成一个0~99的随机数
static unsigned int t = 0 ;
t++;
if(t>=9999)t=0;
srand((unsigned)time(NULL)+n+t);
return rand() % 100;
}
void set_tasks(struct Text_Animation text){//设置任务,比较两个字符串的不同字符,并记录下来,用于后面动画显示%text.end_tim
static int r =0;
int new_len = strlen(text.phrases[text.idx]);
int old_len = strlen(text.phrases[text.idx - 1]);
int lenth = new_len > old_len ? new_len : old_len;
for(int i=0;i<lenth;i++){
if(text.showstr[i] != text.phrases[text.idx][i]){
tasks[i].from = text.showstr[i];
tasks[i].to = text.phrases[text.idx][i];
tasks[i].start = Random(r++) % 10 ;
tasks[i].end = Random(r++) % text.end_tim;
}else{
tasks[i].from = text.showstr[i];
tasks[i].to = text.phrases[text.idx][i];
tasks[i].start = 0;
tasks[i].end = 0;
}
//printf("taks:%d\n",i);
}
tasks[lenth].from = '\0';
tasks[lenth].to = '\0';
tasks[lenth].start = 0;
tasks[lenth].end = 0;
}
void update_showstr(struct Text_Animation *text){//更新显示字符串
char new_str[100];
text->fram++;//更新帧数
//printf("%d\n",text->fram);
if(text->fram > text->disp_time){//如果超过显示时间,则切换到下一句话
text->fram = 0;
for(int i=strlen(text->phrases[text->idx]);i<100;i++){
text->showstr[i] =' ';
}
do{
text->idx++;
}while(text->phrases[text->idx][0] == '\0' && text->idx < 10);
if(text->idx >= 10){
if(text->loop){
text->idx = 0;
}else{
return;
}
}
set_tasks(*text);
}
int new_len = strlen(text->phrases[text->idx]);
int old_len = strlen(text->showstr);
int lenth = new_len > old_len ? new_len : old_len;
for(int i=0;i<100;i++){
new_str[i] = text->showstr[i];//复制当前显示字符串
}
for(int i=0;i<lenth;i++){//遍历任务数组,如果任务开始时间在当前帧数之前,且当前帧数在任务结束时间之前,则显示乱码字符
if(tasks[i].start <= text->fram && text->fram <= tasks[i].end){
if(Random(i+text->fram)<70){
new_str[i] = text->obfu_chars[Random(i+text->fram)%3];
}
}else if(tasks[i].end < text->fram){
new_str[i] = tasks[i].to;
}
}
for(int i=0;i<100;i++){
text->showstr[i] = new_str[i];//更新显示字符串
}
}
int main(){
set_tasks(t);
Random(5);
while(1){
system("cls");
update_showstr(&t);
printf("%s",t.showstr);
usleep(10);
}
return 0;
}
发表回复