简体   繁体   English

如何使用Sprite Sheet和JavaScript制作字符生成器

[英]How to make a character generator using sprite sheet and JavaScript

http://www.famitsu.com/freegame/tool/chibi/index1.html http://www.famitsu.com/freegame/tool/chibi/index1.html

I want to build a character generator exactly like this one. 我想构建一个与此完全相同的字符生成器。 Someone suggested me that it'd be easy to use a canvas library, followed by low level JavaScript programming. 有人建议我使用画布库,然后进行底层JavaScript编程会很容易。 Some said I don't need canvas and can do it easily with JavaScript. 有人说我不需要画布,可以使用JavaScript轻松完成。 Since I've only learnt core JavaScript so far, hence I really don't have any knowledge or idea about this scene. 由于到目前为止我只学习了核心JavaScript,因此我对这个场景真的一无所知。 So can you suggest me where and how to start this project of mine? 那么,您能建议我在哪里以及如何开始我的这个项目吗? And what are the required languages I should acquire first before jumping onto this project? 在进入该项目之前,我应该首先获得哪些语言要求?

The components of an interactive, graphic application: 交互式图形应用程序的组件:

These things are the basic building blocks of any interactive, graphic application. 这些都是任何交互式图形应用程序的基本构建块。

JavaScript is a great language to use when starting out (or even beyond that) because the same concepts apply here as anywhere else, but you can save your code, and run it in your favorite browser! JavaScript是一门优秀的语言(甚至起步时),因为相同的概念在这里和其他地方一样适用,但是您可以保存代码,然后在自己喜欢的浏览器中运行它!

Here's a Tetris example I've been working on lately in JavaScript that draws the board on an HTML5 canvas. 这是我最近使用JavaScript编写的一个Tetris示例 ,它在HTML5画布上绘制了木板。 It may seem a little complicated and overwhelming, but all the pieces are there that I've discussed (except for sound =/). 看起来似乎有些复杂且令人难以理解,但是我已经讨论了所有内容(声音= /除外)。

Just for reference, the tick function is my main animation loop. 仅供参考, tick功能是我的主要动画循环。 It runs as fast as the window will return animation frames, which is usually quicker than necessary. 它的运行速度与窗口返回动画帧的速度一样快,通常这比必要的快。 Once the tick function is called once, it will continue to run until explicitly stopped. 一旦tick函数被调用一次,它将继续运行直到明确停止为止。

Tet.prototype.tick = function()
{
  var _self = this; // needed for next step
  // This line is what will make this function run repeatedly
  this.requestId = requestAnimationFrame(function(){_self.tick()});

  // Get some time information
  this.tickNow = Date.now();
  this.tickDelta = this.tickNow - this.tickThen;

  // If it's been long enough, and it's time to draw a frame...
  if (this.tickDelta > this.tickInterval)
  {
    this.tickThen = this.tickNow - (this.tickDelta % this.tickInterval);

    // Run the game loop
    this.doGameLoop();

    // Draw the updated board
    this.renderer.drawBoard(this.data, this.curPiece, this.curPieceGuide);
  }
}

Game making can be intimidating at first, because it seems there are SO MANY pieces that need to be understood before you can accomplish what you see in your head, but if you take the concepts one-at-a-time, and start small, you'll be making crazy stuff in no time! 首先,游戏制作会令人生畏,因为在完成脑海中所看到的东西之前,似乎需要理解很多东西,但是如果您一次一次采用这些概念并从小做起,您将很快制作出疯狂的东西!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM