zim_physics实现火把火苗点亮花灯游戏代码

代码语言:html

所属分类:游戏

代码描述:zim_physics实现火把火苗点亮花灯游戏代码,键盘上下左右键移动火把点亮花灯。

代码标签: zim_physics 火把 火苗 点亮 花灯 游戏 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  



</head>

<body  >

  
      <script type="module">
import zim from "//repo.bfw.wiki/bfwrepo/js/module/zim/zim_physics.js";

// see https://zimjs.com
// and https://zimjs.com/learn
// and https://zimjs.com/docs

new Frame({
  scaling: FIT,
  width: 1024,
  height: 768,
  color: darker,
  outerColor: darker,
  ready: ready,
  // set allowDefault to true to access key controlls
  // normally we do not need this - but in a CodePen iFrame we do
  allowDefault: true });

function ready() {

  // given F (Frame), S (Stage), W (width), H (height)
  // put your code here

  var backing = new Rectangle(W * 4, W * 4, black).center();

  // make some foliage
  loop(400, () => {
    new Circle(rand(50, 300), null, [
    orange.darken(.5, .8), green.darken(.5, .8)],
    rand(1, 5)).
    sca(1, rand(10)).
    rot(rand(360)).
    alp(.2).
    loc(rand(backing.width), rand(backing.height), backing);
  });
  backing.cache(); // so do not have to redraw all circles 60 times a second

  // create Physics world with no gravity, as big as background, and scrollable

  var physics = new Physics(0, new Boundary(backing), true);


  // add pumpkins to visit - then add to stage so physics works properly

  var pumpkins = new Tile(makePumpkin, 6, 6, 200, 200).center();

  pumpkins.loop(function (pumpkin) {
    pumpkin.addTo().mov(rand(-50, 50), rand(-50, 50)).addPhysics(false, 10);
  }, true);

  new Pane(W + 200, 300, "Light the Pumpkins!\n\nuse WASD or arrow keys", black, orange).show(init);

  function init() {

    // the carrier will rotate 
    // we can counter the rotation 
    // see https://codepen.io/danzen/pen/daJj.........完整代码请登录后点击上方下载按钮下载查看

网友评论0