I started a small game engine of today's headline applet

Posted May 26, 20201 min read

Some time ago I forgot to renew the fee, which caused the server to expire, and the filing went off. So the WeChat applet can't be played. So I registered today's headline applet. Of course, these small programs seem to have to be filed to add APIs.

But I still experienced a small game development of today's headline applet. However, the canvas of the small game must be written with javascript, so engines such as pixi and phaser can't be used. Of course, it can also be used, but it takes time to port.

So I wrote one myself, in fact, it is to encapsulate the common functions of canvas. Although there are few functions at present, it is enough to develop small games.

Let's take a look at the example below. The game ends when two sprites collide:

import {Res, Sprite, Render, Game, Width, Height} from './codetyphon.js';

Res.add_img('player', './Images/player.png');
Res.add_img('flyobj', './Images/flyobj.png');
Res.setup(function() {
  let x = Width/2-25;
  let y = Height-50;
  let player = new Sprite(Res.imgs ['player'], x, y, 50,65); //x, y, width, height
  let obj = new Sprite(Res.imgs ['flyobj'], x, 0,50,50);

  Game.main(function() {
    player.y- = 2;
    obj.y + = 2;
    //Impact checking
    player.collide(obj, function() {
    Render.background('# 000000');


github address: github.com/codetyphon/codetyphon

Welcome everyone star.

Related Posts