谁给洋大人的代码做个解释,我就给谁发奖金

2024-03-01 04:58

本文主要是介绍谁给洋大人的代码做个解释,我就给谁发奖金,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

地址在这里:https://code.sololearn.com/WR2ZwwSaXBF1/?ref=app

 

你运行的时候,发现是个游戏,小人在走,前面来了一群邪恶的龙,你要跳起来,否则你就狗带了,背景是火山,地狱般的黑夜

代码如下:

Author:Coder;
Name :Kill The Dragon;
FrameWork:P5.js;
-->    
<!DOCTYPE html>
<html>
    <head>    
    <div class="loader">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            
        </div>
        
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
     <meta name="viewport" charset="UTF-8" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <title>Page Title</title>
    </head>
    
     <body  onselectstart="return false" οnpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false" οncοntextmenu="return false">
        
        <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.js"></script>
        <script src =   "https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.js">
        </script>  
       <script src =   "https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.sketch.js">
        </script>
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" type="text/css">   
       
        <script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
     
  <script src ="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.0/addons/p5.sound.js"></script>
   <script src ="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.0/addons/p5.sound.min.js">

    </body>
</html>

 

再看看CSS部分


.loader{
    position:absolute;
    top:40%;
    left:40%;
    transform:translate (-50%, -50%);
    width:70px;
    display:flex;
}
.loader span{
    width:10px;
    height:60px;
    background:white;
    margin:0px 1px;
    animation:loading 800ms ease-in-out infinite;
}
.loader span:nth-child(1){
    background:#2eeca8;
    animation-delay:-700ms;
}
.loader span:nth-child(2){
    background:#eade3d;
    animation-delay:-600ms;
}
.loader span:nth-child(3){
    background:#55acee;
    animation-delay:-500ms;
}
.loader span:nth-child(4){
    background:#2eeca8;
    animation-delay:-400ms;
}
.loader span:nth-child(5){
    background:#09b7bf;
    animation-delay:-300ms;
}
.loader span:nth-child(6){
    background:#ea3d8c;
    animation-delay:-200ms;
}
.loader span:nth-child(7){
    background:orange;
    animation-delay:-100ms;
}

@keyframes loading{
    0%, 60%, 100%{
        transform:scaleY(0.01);
    }
    35%{
        transform:scale(1);
    }
}

还有JS部分

/*
Author:Coder;
Name :Kill The Dragon;
FrameWork:P5.js;
*/
console.log =()=>{}
var spriteSheet=[],Arrow_img;
var player;
var enemies = []
var fireball = []
/*window.οnclick= function(){
var audio= document.getElementById("audio_k");
audio.volume = 0.2;
audio.play();
}*/
var arrow=[];
var enemy=[];
var audio,audio1,audio2;
var score = 0;
var fire;
var Theme,theme;
var road;
var target = 10;
var points;
var dx;
var button,button1,button2;
var num;
function preload(){
/*spriteSheet =loadImage("https://image.ibb.co/e70vnq/sprite.png"); */
spriteSheet[0] = loadImage("https://image.ibb.co/mHccfL/download.png");
audio = loadSound("https://saantonandre.github.io/anotherSong.wav")
Arrow_img = loadImage("https://image.ibb.co/epXKvL/arrow-bow-PNG1.png");
enemy[0] = loadImage("https://image.ibb.co/ejbsh0/flying-dragon-gold.png");
enemy[1] = loadImage("https://image.ibb.co/hnmyS0/flying-twin-headed-dragon-blue.png")
Theme = loadImage("https://preview.ibb.co/gtT1sq/midnight-volcano-brad-simpson.jpg");
spriteSheet[1] = loadImage("https://image.ibb.co/e2Hw9f/download-2.png");
spriteSheet[2] = loadImage("https://image.ibb.co/kCx4vL/download-1.png");
spriteSheet[3] = loadImage("https://image.ibb.co/hS3gEf/download56.png");
fire = loadImage("https://image.ibb.co/iB6UJp/fireball-clipart-fiery-10.png");
audio1 = loadSound("https://saantonandre.github.io/sfx/player_buffed_shoot.wav");
audio2 = loadSound("https://saantonandre.github.io/sfx/player_damaged.wav");
}

function setup(){
createCanvas(windowWidth,windowHeight).position(0,0);
background(0);
 player = new Player();
 road = new Road();
 theme = new Background();
 audio.play();
 audio.setVolume(0.2);
 audio.loop();
 points = new Score()
 button = createButton("Next Level").class("btn btn-primary");
button.position(width/2-50,height-50);
button.mousePressed(difficult);
button.hide();

button1 = createButton("Restart").class("btn btn-primary");
button1.position(width/2-50,height-50);
button1.mousePressed(restart);
button1.hide();

button2 = createButton("Info").class("btn btn-primary");
button2.position(width-60,0);
button2.mouseClicked(info);
dx = 0.5;
}
function draw(){
 background(0);
 theme.show();
if(frameCount %250==0) {
  enemies.push(new Enemy())   
 }
 points.show()
  road.show();
  player.show();
  player.update();
   if(player.sx>player.sw*8){
         player.sx = 0;
       if(player.sy==64*19){
      player.sy = player.sw*11;
      arrow.push(new Arrow(player.x+player.w/2,player.y+player.h/2));
      audio1.play()
      
         }
     }
     for(var i =0;i<arrow.length;i++){
         arrow[i].show();
         arrow[i].update()
     }
     for(var i =0;i<enemies.length;i++){
         enemies[i].show();
         enemies[i].update();
     }
       for(var i =0;i<enemies.length;i++){
      if(enemies[i].x<-enemies[i].w){
          enemies.splice(i,1);
      }
      }
     for(var i =0;i<arrow.length;i++){
     if(arrow[i].x>width){
         arrow.splice(i,1);
     }
     }
    for(var i =0;i<arrow.length;i++){
    for(var j =0;j<enemies.length;j++){
   if(collision(arrow[i],enemies[j])){
       enemies.splice(j,1);
       //arrow.splice(i,1);
       audio2.play();
       //audio2.volume= 0.5;
       score++;
   }
   }  
    }
    if(score ==target){
        game_win();
   for(var i =0;i<arrow.length;i++){
 arrow.splice(i,1);
 }  
    }
for(var i =0;i<enemies.length;i++){
    if(collision(player,enemies[i])){
        game_over();
    }
}

}
function mouseClicked(){
if(mouseY<height-110){
   player.sy = 64*19;
   player.sx = 0;
   }
   
   
   
}

function mousePressed(){
if(mouseY>height-100){
  player.dy=-3;
 
  }  
 
}
function mouseReleased(){
    player.dy=1;
}
function Player(){
    this.x = 50;
    this.y = height-150;
    this.w = 50;
    this.h = 50;
    this.sx =  0;
    this.sy =  64*11;
    this.sw = 64;
    this.sh = 64;
    this.dy =0;
    this.r = floor(random(0,spriteSheet.length))
    this.img = spriteSheet[this.r];
    this.show = function(){
image(this.img,this.x,this.y,this.w,this.h,this.sx,this.sy,this.sw,this.sh);

    }
    this.update = function(){
    player.y+=this.dy;
     if(this.y>=height-150){
         this.y = height-150;
     }
     else if(this.y<height/2){
     this.y = height/2
     }
    if(frameCount%5==0){
     this.sx+=this.sw;
     }
     
     
    
     
 
    
    }
}
function Road(){
    this.x = 0;
    this.y = height-100;
    this.w = width;
    this.h = 100;
    this.show = function(){
    fill(0,50,250,50);
rect(this.x,this.y,this.w,this.h);
textAlign(CENTER);
textSize(20);
fill(250,0,0,100);
stroke(0)
text("Click Here To Jump",width/2,height-50);
    }
}
function Arrow(x,y){
    this.x = x;
    this.y = y;
    this.w = 50;
    this.h = 10;
    this.img = Arrow_img;
    this.show = function(){
image(this.img,this.x,this.y,this.w,this.h);
    }
    this.update = function(){
        this.x+=5;
    }
    
}
function Enemy(){
    this.x = width;
    this.y = random(height/2,height-150);
    this.w = 80;
    this.h = 80;
    this.sx = 0;
    this.sy = 64*6;
    this.sw = 64*2+20;
    this.sh = 64*2;
    this.dy= 0.5;
    this.r = floor(random(0,enemy.length));
    this.img = enemy[this.r]
    this.show = function(){
image(this.img,this.x,this.y,this.w,this.h,this.sx,this.sy,this.sw,this.sh);
    }
    this.update = function(){
        this.x-=dx;
        if(frameCount %10==0)
        this.sx+=this.sw;
        if(this.sx>this.sw*2){
            this.sx = 0;
        }
    }
}
function collision(a,b){
  return a.x < b.x + b.w/2 &&
         a.x + a.w/2 >b.x &&
         a.y < b.y + b.h &&
         a.y + a.h > b.y;
}
function Background(){
    this.x = -100;
    this.y = -20;
    this.w = width+100;
    this.h = height+20;
    this.img = Theme;
    this.show = function(){
    image(this.img,this.x,this.y,this.w,this.h);
    }
}
function Score(){
   this.x = width/2;
   this.y = 20;
   this.size = 20;
   this.show = function(){
    textAlign(CENTER);
    textSize(this.size);
    text("Score:"+score,this.x,this.y);
   }
}

function difficult(){
frameRate(255);
    score = 0;
  for(var j =0;j<enemies.length;j++){
  enemies.splice(j,3);
  }
  player = new Player() ;
  player.img = spriteSheet[player.r];
  target+=10;
  button.hide();
  dx+=2;
}
function game_win(){
  frameRate(0);
   fill(0);
   rect(0,0,width,height);
   textAlign(CENTER);
   textSize(30);
   fill("blue")
   text("You Win\nCongratulations",width/2,height/2);
   textSize(20);
   fill("red")
   text("Your Score:"+score,width/2,50);
    button.show();
}
function game_over(){
  frameRate(0);
   fill(0);
   rect(0,0,width,height);
   textAlign(CENTER);
   textSize(30);
   fill("blue")
   text("You Died",width/2,height/2);
   textSize(20);
   fill("red")
   text("Your Score:"+score,width/2,50);
    button1.show();
}
function restart(){
frameRate(255);
    score = 0;
  for(var j =0;j<enemies.length;j++){
  enemies.splice(j,3);
  }
  player = new Player();
  player.img = spriteSheet[player.r];
 target = 10;
 dx = 0.5;
 button1.hide()
}
/*
// https://image.ibb.co/e70vnq/sprite.png
// https://image.ibb.co/g17yH0/MSHWarofthe-Gems-hulk.gif
*/

function Fire(x,y){
    this.x = x;
    this.y = y;
    this.w = 50;
    this.h = 50;
    this.dx = 6;
    this.img = fire;
    this.show = function(){
image(this.img,this.x,this.y,this.w,this.h);
    }
    this.update = function(){
        this.x-=this.dx;
    }
}
function info(){
    alert(`To kill dragons you can shoot arrows by clicking on the screen.
You can dodge the dragons by jumping.`);
}

 

洋大人真是太聪明了,到底人家脑袋是长的,好使

谁能把代码看懂,就来告诉我,我发红包的,CDSN货币,转发给你

这篇关于谁给洋大人的代码做个解释,我就给谁发奖金的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/761289

相关文章

uniapp接入微信小程序原生代码配置方案(优化版)

uniapp项目需要把微信小程序原生语法的功能代码嵌套过来,无需把原生代码转换为uniapp,可以配置拷贝的方式集成过来 1、拷贝代码包到src目录 2、vue.config.js中配置原生代码包直接拷贝到编译目录中 3、pages.json中配置分包目录,原生入口组件的路径 4、manifest.json中配置分包,使用原生组件 5、需要把原生代码包里的页面修改成组件的方

公共筛选组件(二次封装antd)支持代码提示

如果项目是基于antd组件库为基础搭建,可使用此公共筛选组件 使用到的库 npm i antdnpm i lodash-esnpm i @types/lodash-es -D /components/CommonSearch index.tsx import React from 'react';import { Button, Card, Form } from 'antd'

17.用300行代码手写初体验Spring V1.0版本

1.1.课程目标 1、了解看源码最有效的方式,先猜测后验证,不要一开始就去调试代码。 2、浓缩就是精华,用 300行最简洁的代码 提炼Spring的基本设计思想。 3、掌握Spring框架的基本脉络。 1.2.内容定位 1、 具有1年以上的SpringMVC使用经验。 2、 希望深入了解Spring源码的人群,对 Spring有一个整体的宏观感受。 3、 全程手写实现SpringM

代码随想录算法训练营:12/60

非科班学习算法day12 | LeetCode150:逆波兰表达式 ,Leetcode239: 滑动窗口最大值  目录 介绍 一、基础概念补充: 1.c++字符串转为数字 1. std::stoi, std::stol, std::stoll, std::stoul, std::stoull(最常用) 2. std::stringstream 3. std::atoi, std

记录AS混淆代码模板

开启混淆得先在build.gradle文件中把 minifyEnabled false改成true,以及shrinkResources true//去除无用的resource文件 这些是写在proguard-rules.pro文件内的 指定代码的压缩级别 -optimizationpasses 5 包明不混合大小写 -dontusemixedcaseclassnames 不去忽略非公共

麻了!一觉醒来,代码全挂了。。

作为⼀名程序员,相信大家平时都有代码托管的需求。 相信有不少同学或者团队都习惯把自己的代码托管到GitHub平台上。 但是GitHub大家知道,经常在访问速度这方面并不是很快,有时候因为网络问题甚至根本连网站都打不开了,所以导致使用体验并不友好。 经常一觉醒来,居然发现我竟然看不到我自己上传的代码了。。 那在国内,除了GitHub,另外还有一个比较常用的Gitee平台也可以用于

众所周知,配置即代码≠基础设置即代码

​前段时间翻到几条留言,问: “配置即代码和基础设施即代码一样吗?” “配置即代码是什么?怎么都是基础设施即代码?” 我们都是知道,DevOp的快速发展,让服务器管理与配置的时间大大减少,配置即代码和基础设施即代码作为DevOps的重要实践,在其中起到了关键性作用。 不少人将二者看作是一件事,配置即大代码是关于管理特定的应用程序配置设置本身,而基础设施即代码更关注的是部署支持应用程序环境所需的

53、Flink Interval Join 代码示例

1、概述 interval Join 默认会根据 keyBy 的条件进行 Join 此时为 Inner Join; interval Join 算子的水位线会取两条流中水位线的最小值; interval Join 迟到数据的判定是以 interval Join 算子的水位线为基准; interval Join 可以分别输出两条流中迟到的数据-[sideOutputLeftLateData,

Git代码管理的常用操作

在VS022中,Git的管理要先建立本地或远程仓库,然后commit到本地,最后push到远程代码库。 或者不建立本地的情况,直接拉取已有的远程代码。 Git是一个分布式版本控制系统,用于跟踪和管理文件的变化。它可以记录文件的修改历史,并且可以轻松地回滚到任何历史版本。 Git的基本概念包括: 仓库(Repository):Git使用仓库来存储文件的版本历史。一个仓库可以包含多个文件

HTML文档插入JS代码的几种方法

在HTML文档里嵌入客户端JavaScript代码有4中方法: 1.内联,放置在< script>和标签对之间。 2.放置在由< script>标签的src属性指定的外部文件中。 3.放置在HTML事件处理程序中,该事件处理程序由onclick或onmouseover这样的HTML属性值指定。 4.放在一个URL里,这个URL使用特殊的“javascript:”协议。 在JS编程中,主张