Making my own Wick Editor

More ideas to ping this back up!

I thought that NB Studio should take full ability of Multimedia, unlike Wick, which fails at even SVGs. What i’m getting to is a crazy.

FFMpeg Support built-in!

Yes, i’ll try to add Video Encode, Decode and video playing in a “game engine”.

Concept Art:

WARNING: Missing some stuff, and mostly just a first concept.

2 Likes

There’s a lot of documentation of the Macromedia Director file formats, so something like this wouldn’t be completely impossible… just really hard.

As for the nbs file format, all you need is a simple rename of the file extension from wick to nbs… just saying :grimacing:

FFMpeg Support built-in!

geez, might as well make this a standalone program… or maybe find a way to make ffmpeg into JS yourself… you seem to know what you’re doing!

As for the UI, I think I could help. That’s what I’m pretty good at!

Some guys randomly decided to make a FFMpeg port for the web! (2010)
Some guys randomly decided to make a FFMpeg port for the web! (2015) and it’s using WebAssembly!
Some guys randomly decided to make a FFMpeg port for the web! (2020) and it’s using WebAssembly!
cough cough


Thank the W3C gods for making WASM.

What in the unfinished buggy wikia site i found:

Note, the Scripting part took at least one hour… :sweat_smile:

Possible Implementation:

  • Use the following classes for multimedia tools:
    • MMEncode(images: ImageData[], audio: Audio, framerate: number): Blob, do encode images and audio into video using FFmpeg.
    • MMDecode(video: Blob): [ImageData[], Audio] to decode video to images and audio.
  • Use the following classes for easy video playing:
    • WickVideo: Basically a WickObject with special video powers.
    • Has @loadVideo, which uses MMDecode to make a timeline with all the videos’ frames as images.
    • Contains @currentVideo, a string ref to the video being played currently.
    • Wick may worsen playback, due to the massive amount of images being imported at once.

Scripting update!

The scripting in legacy wick is not usable. Even myself, could not figure, what are these scripts doing?

So, to improve the problem, I’ll rewrite the whole scripting framework in Wick Editor.

(Proposed) Changes:

  • Change from javascript (.js) to coffeescript (.coffee), making most scripts easier:
// Example JS script.
var mySecret = random.uuid4();
var myObj = {
  secret: mySecret,
  name: "someObjectImUsingLater",
  script: "function click(){ alert('peekaboo!') }",
  someVectorData: new VecData generatedDataFromEarlier...,
  position: new Vec2(100, 100)
};
console.dir(myObj); // the syntax to force-log as a object.

function myFunction(...props) {
  for (var i=0;i<props.length;i++) {
    alert(props[i]);
  }
}
myFunction("Hello", "World!")

Now the Coffee Script version:

# Example CoffeeScript Script
mySecret = random.uuid4()

myObject =
    secret: mySecret,
    name: "someObjectImUsingLater",
    script: "function click(){ alert('peekaboo!') }",
    someVectorData: new VecData(generatedDataFromEarlier...),
    position: new Vec2 100, 100

console.dir myObj # the syntax to force-log as a object

myFunction = (props...) ->
  for prop in props
    alert prop
  return # lil' hack so the code doesn't generate a return here.

myFunction "Hello", "World!" # call function test

which generates:

// Example CoffeeScript Script
var myFunction, myObject, mySecret;

mySecret = random.uuid4();

myObject = {
  secret: mySecret,
  name: "someObjectImUsingLater",
  script: "function click(){ alert('peekaboo!') }",
  someVectorData: new VecData(...generatedDataFromEarlier),
  position: new Vec2(100, 100)
};

console.dir(myObj); // the syntax to force-log as a object

myFunction = function(...props) {
  var i, len, prop;
  for (i = 0, len = props.length; i < len; i++) {
    prop = props[i];
    alert(prop); // lil' hack so the code doesn't generate a return here.
  }
};

myFunction("Hello", "World!"); // call function test

Objectively, CoffeeScript is easier, and more helpful on coding- wait… I forgot about the class syntax, silly me!

# Class Creation Speedrun %ANY%
class Position
  # the @val tells it to do the boilerplate of this.val = val.
  constructor: (@x, @y) ->
  toArray -> [@x, @y]

class Player
  constructor: (@name, pos) ->
    @pos = pos if pos instanceof Position

Which translates into:

var Player, Position;

Position = (function() {
  class Position {
    constructor(x, y) {
      this.x = x;
      this.y = y;
    }

  };

  toArray(function() {
    return [this.x, this.y];
  });

  return Position;

}).call(this);

Player = class Player {
  constructor(name, pos) {
    this.name = name;
    if (pos instanceof Position) {
      this.pos = pos;
    }
  }

}; 

Also, if you’re still reading through my walls of transpiled code, thanks!
Scripts shown here will all be in CoffeeScript from now on…

  • Scripts now will have a simplified runner
# old way
editor = wickEditor or wickPlayer

editor.runScript mainFactory, "create", 
  create: "Firey",
  amount: 50,
  callInit: true

# new (proposed) way

@run "create", #local way
  create: "Firey",
  amount: 50,
  callInit: true

# Global Way
editor = wickEditor or wickPlayer
editor.run mainFactory, "create",
  create: "Firey",
  amount: 50,
  callInit: true

I could go creating more things, but just these two improve scripts by a lot.

I’m also gonna compare NB Studio with CT.js, a free game engine, with some CoffeeScript. I’m choosing a simple game to recreate, but almost impossible with legacy wick!

Space Invaders

I’m gonna build a space invaders clone real quick!

Preview thingy:

I’m importing my docs for wick editor, but… ummm… Let me show what the AI generated with it’s files…


To make your **Wick.Clip** draggable, you'll need to use event handlers to track mouse interactions. Wick Editor allows you to use scripting to enable interactivity.

Here’s how you can make a clip draggable:

Steps:

  1. Add event listeners for onMouseDown , onMouseMove , and onMouseUp .
  2. Track the mouse position and update the clip’s position accordingly.
  3. Ensure the drag stops when the mouse is released.

JavaScript Code:

let isDragging = false;
let offsetX = 0;
let offsetY = 0;

this.onMouseDown = function(event) {
    isDragging = true;
    offsetX = event.x - this.x;
    offsetY = event.y - this.y;
}

this.onMouseMove = function(event) {
    if (isDragging) {
        this.x = event.x - offsetX;
        this.y = event.y - offsetY;
    }
}

this.onMouseUp = function(event) {
    isDragging = false;
}

Explanation:

  • onMouseDown : When the user clicks on the clip, it starts tracking the position.
  • onMouseMove : As long as isDragging is true , the clip follows the mouse.
  • onMouseUp : Stops the dragging when the mouse button is released.

This should allow your clip to be moved around the canvas with the mouse! :rocket: Let me know if you need modifications or additional features like constraints (e.g., keeping it inside a certain area).

It’s starting to get it. But geez! This another level of wrong…

1 Like

WebAssembly sure does look promising! If this was in Wick Editor, it’d be pretty awesome.

1 Like

I need immediate help, as my instance of git has initiated death upon it’s premises!

Guys, I kinda hacked my way to make a push, I now have 2 commits!

if you don’t like it, why do use it?

It’s not ready yet. Wait some (maybe too much) time for me to bother to update the thing.

1 Like

A few updates!

It’s been some time since I said about what changed in NB Studio… I’m here to show the new workflows and stuff.

The Gulping of the files

The old method that was used to import the JS was, quite literally, importing every single file from the HTML. So I used my favorite (and easiest to implement) Build library, gulp!

The Gulping Framework

I did a simple job to run the files, which is:

  1. Delete ./dist
  2. Turn all the libs into one libs.js file (minified, too.)
  3. Same thing as the libs, but it’s the engine (engine.js)
  4. Player (player.js)

If you didn’t understand, here’s the Gulpfile.

// Gulpy gulpy!

var [gulp, coffee, concat, uglify] = [require("gulp"), require("gulp-coffee"), require("gulp-concat"), require("gulp-uglify")]; // big hack cuz it's easier to do it this way.
var {src, series, dest} = gulp;
var del = require("delete");

function clean(cb) {
    del(["dist/*.js"], function(err, deleted) {
        if (err) {
            cb(err)
        } else {
            cb()
        }
    })
}

function engine(cb) {
    // Engine function's tasks:
    /*
        - take all the files from .src/project/*.js
        - Uglify it (improves performance by some amount... Also makes debuging impossible without maps.)
        - Concat it into one file (better load on the network?? idk man)
        - return it.
    */
    src("./src/project/*.js")
        .pipe(uglify())
        .pipe(concat("engine.js"))
        .pipe(dest("./dist"))
    cb();
}

function editor(cb) {
    // Takes all of the editor code to match into one file.
    // TODO: Redo Editor, so it isn't one of the WORST codebases to mod.
    src("./src/editor/**")
        .pipe(uglify())
        .pipe(concat("editor.js"))
        .pipe(dest("./dist"))
    cb();
}

function player(cb) {
    // Same thing. Player JS now!
    src("./src/player/*.js")
        .pipe(uglify())
        .pipe(concat("player.js"))
        .pipe(dest("./dist"))
    cb();
}

function lib(cb) {
    src("./lib/**.js")
        .pipe(uglify())
        .pipe(concat("libs.js"))
        .pipe(dest("./dist"))
    cb()
}

exports.default = series(clean, lib, engine, editor, player)

New Direction

I’ve been hyping up changes, but I got snapped back into the reality:

DARN! This is old as heck!

The new direction is to upgrade everything, and then optimize.

Thy Future!

These are the things I’m going to try in the future.

  1. jQuery -> Preact
    a. Though jQuery is a perfect and good library, for the wanted interactivity, it’s terrible.
    b. TLDR: Preact is React, if it was a few hundred KB.
    c. The new component could be puréed into a JSFL like component system for our plugins.
  2. CoffeeScript
    a. Even though it’s really easy to add, I’m wondering if I am going to update the IDE to make this work.
  3. Plugins
    a. Plugins are excellent, since I can implement them once, and never need to update the engine again!
    b. They allow me (and others) to have an easy way to mess and make something new in the editor.

A modular future!

If the plugin system gets good, the engine might not need updates through the code.

That’s all folks!

I’m done. That’s all for now.

1 Like

:nerd_face: Stats Roundup

  1. Here are the sizes of the compiled assets:
    a. styles.css lines: 3263 lines (considering whitespace)
    b. engine.js lines: 12 (minified)
    c. libs.js lines: 58 (minified)
    d. player.js lines: 4 (minified)

WARNING!!! :warning::warning::warning::warning::warning::warning::warning:

The editor is partially broken, and i’m working on updates.

Update:


maybe I’m missing something?

GH Issue

More Direction changes!!!

Since I can’t get UI to work anymore, I’m replacing the editor, and it’s jQuery requirement.