iceyellow
发表于 2019-3-11 10:34:49
第一次回帖,催更--,着急开发个网页
岁月忽已暮!
发表于 2019-3-12 23:34:49
JS几时更新
dandelion_boy
发表于 2019-3-13 16:08:59
更新
chenyiyun
发表于 2019-3-15 16:50:38
wow I love that
chenyiyun
发表于 2019-3-15 16:53:01
看看这个@小甲鱼:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>捕鱼达人</title>
</head>
<body>
<div id="container">
<div id="main">
<div id="stage" style="margin: 0 auto; width: 800px; height: 480px;text-align: center; vertical-align: middle" >
<canvas id="canvas"width="800" height="480">
不支持画板对象时能看到
</canvas>
</div>
</div>
</div>
<script type="text/javascript">
/*
*/
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext('2d');
var bg = new Image();
bg.src = "images/bg.jpg";
var allFish=[];
var score=0;
var money=5;
var net=new Net();
var p="PAUSE......";
var t;
var A=1;
var O=2;
t=A;
canvas.onclick=function(){
if(t==A){
money-=3;
for(var i=0;i<allFish.length;i++){
switchNetCatch(i);
}
bynetType(score);
}
}
function netCatch(i,n){
if((allFish.x>(net.x-50)&&allFish.x<(net.x+160))
&&(allFish.y>(net.y-48)&&allFish.y<(net.y+160))
&&Math.random()<n){
score=score+allFish.score;
remove(i);
money+=allFish.money;
}
}
function bynetType(score){
if(score>0){
nettype=1;
}else if(score>200){
nettype=2;
}else if(score>400){
nettype=3;
}
}
function switchNetCatch(i){
var n;
if(allFish.p<=5){
n=0.7;
netCatch(i,n);
}else if(allFish.p<=9){
n=0.5;
netCatch(i,n);
}else if(allFish.p==10){
n=0.1;
netCatch(i,n);
}else{
n=0.35;
netCatch(i,n);
}
}
canvas.onmouseout = function() {
if(t==A&&money!=0){
t=3;
};
};
canvas.onmouseover = function() {
if(t==3){
t=A;
};
}
setInterval(function() {
if(t==A){
w();
ctx.drawImage(bg,0,0);
for(var i=0;i<allFish.length;i++){
allFish.paint(ctx);
}
fillText(ctx,"red","SCORE:",score,10,20);
fillText(ctx,"red","MONEY:",money,650,20);
for(var i=0;i<allFish.length;i++){
allFish.step();
allFish.hit(i);
}
fishCount();
net.paint(ctx);
}else if(t==O){
ctx.drawImage(bg,0,0);
for(var i=0;i<allFish.length;i++){
allFish.paint(ctx);
}
fillText(ctx,"red","SCORE:",score,10,20);
fillText(ctx,"red","MONEY:",money,650,20);
for(var i=0;i<allFish.length;i++){
allFish.step();
}
fishCount();
ctx.font="70px Verdana";
ctx.fillStyle="red";
ctx.fillText("GAME OVER",180,300);
x();
}else{
ctx.drawImage(bg,0,0);
for(var i=0;i<allFish.length;i++){
allFish.paint(ctx);allFish.hit(i);
}
fillText(ctx,"red","SCORE:",score,10,20);
fillText(ctx,"red","MONEY:",money,650,20);
ctx.font="70px Verdana";
ctx.fillStyle="red";
ctx.fillText(p,180,300);
}
fillText(ctx,"red","FISHCOUNT:",allFish.length,10,40);
}, 10);
function w(){
if(money<1){
t=O;
money=0;
}
}
function remove(i){
allFish.splice(i,1);
}
function isActionTime(lastTime, interval) {
if (lastTime == 0) {
return true;
}
var currentTime = new Date().getTime();
return currentTime - lastTime >= interval;
}
function getPointOnCanvas(x, y) {
var bbox = canvas.getBoundingClientRect();
return {
x : x - bbox.left,
y : y - bbox.top
};
}
canvas.onmousemove = function(e) {
var mpoint = getPointOnCanvas(e.x, e.y);
net.x = mpoint.x - 80;
net.y = mpoint.y - 80;
};
var Time=0;
var interval=800;
function fishCount(){
if(!isActionTime(Time, interval)){
return
}
Time = new Date().getTime();
allFish=new Fish();
}
function fillText(ctx,color,Text,so,x,y){
ctx.font="20px Verdana";
ctx.fillText(Text+so,x,y);
}
function Fish(){
this.x=800;
this.life=0;
this.y=Math.random()*(480-100);
var randomFish=parseInt(Math.random()*11+1);
this.p=randomFish;
if(randomFish != 11){
this.money=randomFish%11;
this.score=randomFish%11;
}else{
this.money=randomFish-1;
this.score=randomFish-1;
}
var fish=[];
for(var i=0;i<10;i++){
var fishImage=new Image();
fishImage.src="images/fish"+randomFish+"_"+i+".png";
fish=fishImage;
};
this.frame=fish;
var interval = 70;
var lastTime = 0;
function timeOut() {
var current = new Date().getTime();
var t = current - lastTime;
if (t >= interval) {
lastTime = current;
return false;
}
return true;
};
var index=0;
this.step=function(){
if(!timeOut()){
this.x=this.x-2;
this.frame=fish;
index=index+1;
}
}
this.paint=function(ctx){
ctx.drawImage(this.frame,this.x,this.y);
}
this.hit=function(i){
if(this.x<-950){
allFish.splice(0,1);
}
}
}
function Net(){
var n=new Image();
n.src="images/net.png";
this.x=0;
this.y=0;
this.paint=function(ctx){
ctx.drawImage(n,this.x,this.y);
}
}
</script>
</body>
</html>
林鹿可爱
发表于 2019-3-16 10:52:18
这个javascript是还没出的意思吗
chenyiyun
发表于 2019-3-16 19:36:53
https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1552746070479&di=e326f295c4ed883f9444a2cd6aa5287d&imgtype=0&src=http%3A%2F%2Fstatic.makeru.com.cn%2Fupload%2Feduplat%2Farticle%2F20170718%2F1500346555206022274.jpg
支持鱼神!!支持鱼神!!
I love FishC.com
chenyiyun
发表于 2019-3-16 19:38:24
python和web都会了(^—^)
以后用python和web编个程序{:5_109:}
chenyiyun
发表于 2019-3-16 19:39:13
哇马一记!
lixiangyv
发表于 2019-3-17 09:01:49
回复
chenyiyun
发表于 2019-3-18 19:08:43
666
呆萌大花菜
发表于 2019-3-26 16:27:54
小甲鱼, web的啥时候更啊, 等了好久啦
zxzx5
发表于 2019-3-27 18:51:49
嘻嘻,哔哩哔哩网站自带播放器播放,贼舒畅!{:10_256:}
白居过隙
发表于 2019-3-31 14:32:44
更到多少集了?我看到25了
自导自演丶
发表于 2019-4-1 11:44:20
直接a站看的,也很清晰,讲的不错。
起子LL
发表于 2019-4-4 18:11:03
个为什么更新的这么慢啊 课后作业也没更新 55555
热水哥
发表于 2019-4-6 02:34:55
正在学习中
幻想de鱼
发表于 2019-4-6 08:35:11
小甲鱼还更新嘛??
呆萌大花菜
发表于 2019-4-12 15:39:06
确实更新, 更新,更。。。新。。。的好慢啊
by2014
发表于 2019-5-2 13:00:06
围观