Crash-tan Crash-tan

Version 2.4.0 released with iPhone Duo support!

Crash BASIC 2.4.0 Release Notes

written by Crash-tan

Rigs can reach for each other now! An IK chain or a pin can follow another
sprite wherever it goes, with no code aiming it every frame. OSCILLATE can
swing a sprite's turn, so a chain can ripple like a tail. And the scene
editor grew up a lot: you can rough out a scene with stand-in blocks, set up
a node's rigging and pose it by dragging, and pick and move several sprites
at once.

Multiplayer games answer your keys when you press them again, instead of a
second or more later. There's a new way to watch a value while your game
runs, DEBUG PRINT, which writes to the IDE's Console instead of your
screen. And a few things that went wrong are put right: a breakpoint's log
message that never showed up, a shaded map that slid out of place in a
window the wrong shape, and the IDE crashing as it closed on some Windows
machines.

IK AND PIN CAN FOLLOW A SPRITE

IK TARGET and PIN TARGET took a point, so your program had to aim them
again every frame to make them follow anything. Now they can follow a
sprite instead:

SET SPRITE tip IK TARGET SPRITE handle LENGTH 4
SET SPRITE eye PIN TARGET SPRITE cursor MIX 0.3
SET SPRITE tip !! ik_target_sprite(handle) ik_length(4)
SET SPRITE eye !! pin_target_sprite(cursor) pin_mix(0.3)

Every tick, I look where that sprite is and reach for it. So anything that
moves the handle steers the chain: a behavior, a pattern, your code, or
another rig. Give an invisible handle a behavior that sways it (BOSCILLATE,
or OSCILLATE in Crash BASIC 2) and the tail sways after it, all by itself.

A chain can't follow a sprite it moves itself, like one of its own links or
something attached to one, because it would chase its own tail forever. I'll
stop with an error if you try. If the sprite it follows goes away, the IK or
pin just waits with nothing to reach for, until you aim it again.

A scene file can do it too, with "ik_target" or "pin_target" naming
another node in the same file:

{ "name": "tip", "ik": { "length": 4 }, "ik_target": "handle" }

SAVE SCENE writes it back the same way.

A SWING THAT TURNS

OSCILLATE swung a sprite's position. Now it can swing its turn too, with
ANGLE: that many degrees either way of how it was turned when the behavior
started, at the same speed and phase as the rest of the swing.

BEHAVIOR "ripple"
  BOSCILLATE AMPLITUDE 0, 0 ANGLE @swing=10 SPEED 4 PHASE @lag=0
END BEHAVIOR
BEHAVIOR "ripple"
    OSCILLATE 0, 0 !! angle(10) speed(4) phase(PARAM("lag", 0))
END BEHAVIOR

With both amplitudes 0, only its turn swings, and where it is stays up to
whatever else moves it. That makes something neat possible: put it on each
link of a chain, give each link a phase a little behind the one before, and
a wave rolls all the way down, like a tail or a tentacle. Turning a link
never stretches it, so the chain stays in one piece. And under an IK with a
MIX below 1, the chain can ripple while it leans toward its target.

MULTIPLAYER KEEPS UP

In a CrashNet game, what the server moved could show up a long way behind
what you did: press a key and the paddle went a second later, then two, then
more as the round went on. It was worst right after a still moment, like a
countdown or a pause. The server and the player were on the same computer, so
it wasn't the network.

Three things were wrong, and all of them were mine:

  • A still moment counted as one long step. The server sends its sprites
    20 times a second (your TICK RATE), and each send says how long it covers.
    After a countdown, the first send said it covered the whole countdown, so I
    played everything after it that far behind, and took minutes to catch up.
    Now a stretch where nothing moved doesn't count, and the next move is one
    step long, as it should be.
  • A move between sends could get lost. Sprites move more often than
    they're sent, and a sprite that moved and then stopped between two
    sends could be shown where it was before it stopped. Now each send carries
    every sprite's latest place.
  • I forgot a late burst too slowly. When the server fell behind for a
    moment, I held everything back to cover it, and let go of that very slowly.
    Now I let go within a few seconds. And a send that comes much later than the
    rest, because the server stalled, is shown as a jump at its own moment
    instead of slowing everything else down to draw it smoothly.

On one computer, playing now runs about a fifteenth of a second behind the
server, and stays there.

DEBUG PRINT

Sometimes you want to see a number while your game runs, and PRINT would
draw it on top of the game. Or you're on a CrashNet server, where there's no
screen to PRINT to at all. DEBUG PRINT writes to the debug log instead:

score = 1200
DEBUG PRINT "score is"; score
score = 1200
DEBUG PRINT "score is", score

That's one line in the IDE's Console, with the file and line it came
from:

[main.bas:2] score is 1200

If you're not running from the IDE, the line goes to the terminal the player
or server was started from. Nothing reaches the screen, so DEBUG PRINT works
anywhere: on a CrashNet host or player-server, inside a MEMORYBUFFER, even
before SCREEN.

The other languages have it too:

crash.debug_print("score is", score)
crash.debug_print("score is", score)
console.debug("score is", score);
crash.debug_print("score is", score);

In JavaScript console.debug goes to the debug log now. console.log,
console.info, console.warn and console.error still draw on the screen,
as they did before.

A BREAKPOINT'S LOG MESSAGE SHOWS UP

A breakpoint can carry a Log message, which is written each time it's
passed instead of stopping your game. I worked it out every time, and then
neither IDE showed it: the desktop IDE dropped it, and the web IDE stopped
reading just before it. Now it's in the Console in both, the same as a
DEBUG PRINT, and so is a note saying why, if the message couldn't be worked
out.

A SHADED MAP STAYS PUT WITH LETTERBOX OFF

With SCREEN ... LETTERBOX OFF, a map layer with a shader of its own could
come out stretched and out of line with your other map layers when the window
wasn't the same shape as your screen. A storm seen through a window landed
somewhere else on the wall, for example. A window the same shape was fine,
so it showed up when you dragged the window taller or wider.

I was drawing every map layer onto the last one's rectangle: the shaded map
belongs on your screen, and the maps without a shader reach out over the
whole window. Now each map is drawn where it belongs, so your shader's UV
runs across your screen again, whatever shape the window is. This was on
macOS, Linux, phones and the web, and on Windows computers that can't use
Direct3D 12; the rest of Windows was already right.

A map layer with a shader stays on your screen, so with LETTERBOX OFF
there's nothing of it in the space around your screen. To fill that space,
put the map on a layer without a shader too.

THE PICTURE DOESN'T STUTTER WHEN YOU MAKE AN IMAGE

Making an image while the game runs, with BEGIN MEMORYBUFFER,
TEXTTOIMAGE, a load or a shader, made the picture stand still for a moment
each time. A minimap remade four times a second stuttered four times a second.
Now I make the image without holding up the picture.

Taking a shader off, with SHADER NONE, held up the picture the same way:
everything waiting to be drawn went to the screen at once. When a boss melted
away and its parts' shaders came off one by one, each part flickered back
for a moment as it went. Now taking a shader off waits its turn with
everything else.

THE SCENE EDITOR SHOWS WHAT IT CAN

A scene file whose images your program makes as it runs ("generated": true)
couldn't be shown in the scene editor at all, and filled the screen with
errors. Now an image your program makes is drawn as nothing in the editor, so
the nodes that show it, and everything attached to them, are still laid out
where you put them. What the editor has to leave out, like a shader or a
behavior your program defines, is one short note per thing, naming where it's
used, instead of one for every node. And the notes aren't written over your
scene anymore: a notice in the toolbar says how many there are, and clicking
it opens them. crashplayer --scene shows a scene the same way.

You can pick more than one sprite now, too. Shift-click (or Command-click)
them, on the scene or in the tree, and drag any of them to move them all.

And Snap grew up: the grid it snaps to is drawn on the scene, you can
pick its size (the map's tiles, 4 to 64 pixels, or any size you type), and
it snaps sprites you drop or add as well as ones you move, and boundaries as
you draw them. Hold Alt while you drag to place something freely.

Click a boundary and the Boundaries page opens right on its settings,
outlined (and clicking its settings there picks it on the scene). And you
can copy, cut and paste sprites and boundaries now, with Command-C,
Command-X and Command-V (Ctrl on Windows and Linux). What you
paste lands a step down and to the right, picked, ready to drag into place.
A sprite brings everything attached to it, gets a new name if the file
already has its own, and keeps its IK or pin aimed at the right sprite. Paste into another scene file and
it brings the pictures, behaviors and patterns it needs along.

STAND-IN BLOCKS

Roughing out a scene before the art is ready? An image in a scene file can
now be a block: a rectangle of one color, or clear.

"images": [
    { "name": "wall", "block": { "size": [32, 64], "color": "#808080" } },
    { "name": "window", "block": { "size": [48, 48], "color": "#80c0ff80" } },
    { "name": "trigger", "block": { "size": [16, 16] } }
]

#rrggbb is solid, #rrggbbaa lets you see through it, and no color is
clear. In the scene editor, pick + New block in a node's Image list
to give it one of its own, or use + Block next to + Image on the
Images page. And an
image your program makes can carry a block too, to stand in for it in the
editor until the game makes the real one: tick Stand-in block.

RIGGING IN THE SCENE EDITOR

A node in a scene file could always carry ik, pin and limit, the same
constraints SET SPRITE gives a rig, but the scene editor gave you nowhere to
set them, and ignored them while you worked. Now a node's fields have a
Rigging section:

  • IK makes an attached node the tip of a chain that bends to reach a
    target. Ticking it makes the links of the chain Rigid, just like
    SET SPRITE IK does. Drag any link of the chain on the canvas and the
    links above it bend to follow, without stretching a bone, and the file
    keeps the pose.
  • Pin pulls a node toward a target.
  • Limit keeps an attached node's offset in a range, or on one axis.
    Dragging it or typing its offset stops at the limit, where your game would
    put it anyway.

Each one can have a Target: another node it follows, wherever you put
it. Drag the target around and the chain bends to reach it, right there in
the editor. With no target, your program aims it with IK TARGET or
PIN TARGET. With a target, dragging an elbow chooses which way the arm
bends while the tip stays put. Rename a
target and whatever followed it keeps following it.

And an IK in a scene file now does what SET SPRITE IK does when the scene
is built: the links of its chain turn with their parents, whether or not
the file says they're Rigid. Before, a chain whose links weren't marked
Rigid turned only its top link and left the rest behind.

A DATABASE EDITOR

The IDE opens databases now! Open a .db (or .sqlite) in your project,
or make one with New database…, and you can look inside it and change
it without writing a line of SQL:

  • Rows shows a table's rows, a page at a time, to sort, filter and
    page through. Double-click a cell to change it, and add, copy and delete
    rows. A number column takes only numbers, so a typo doesn't turn into a
    word your game trips over.
  • Structure has a form for making a table and changing one: add,
    rename, move and remove columns, and pick each one's type, primary key,
    Required, Unique and default. Before anything happens it shows you
    the SQL it will run, and if any of it fails, none of it is kept.
  • SQL runs whatever you type, as many statements as you like.

I read it with the same SQLite your game uses, so what you see is what the
game will find. It all goes into the file when you save, like any other
file, and Undo takes back every change until then. And in a browser,
a database your game wrote while it ran comes straight into the project
when the run ends, without asking: it's where your game keeps what lasts.

A MAP FROM SEVERAL TILESETS

A map can be painted from more than one tileset now: the ground from one,
the trees from another, a dungeon's doors from a third, each kept in its own
file. In the map editor, Add a tileset… in the tileset menu adds
another, and the palette shows each one's tiles under its name. Choosing a
tileset opens a picker that goes through your project's folders, with a
picture of each and a search through them all.
Each tileset's auto-tile sets, animations and arrangement come along with
it, so you can auto-tile with one and stamp from another on the same map.

Each tileset's tiles get numbers of their own on the map, one tileset after
another. When the map loads, I put them all together into one picture, so
CREATE MAP, a scene file's map and BASEMAP all work just as they do with
one tileset, and maptile gives the same numbers the editor shows. If a
tileset grows into the next one's numbers, opening the map in the editor
moves them along. A map that hasn't been opened since, I won't load: I'd
be drawing the wrong tiles, so I tell you which tileset grew instead.

THE MAP EDITOR HAS A TOOL PALETTE

The map editor's tools were in a menu. Now they're a column of buttons down
the left, grouped the way the menu was, like the sprite and tile editors'.
Each has a key: B to paint, E to erase, G to fill, A to auto-tile, S to
stamp, and so on (hover over a button to see its key). The bar at the top
shows only what the tool in hand needs, and the maze generator has a
Maze… button of its own.

EVERY EDITOR HAS ITS OWN SAVE

The sprite and tile editors each had a Save for just the file you were
in, and the rest didn't. Now the map, scene, atlas, song, instrument and
database editors have one too, in the bar along the top. It saves that file
alone. Save in the toolbar, and Cmd+S, still save everything you've
changed.

THE TILE ORGANIZER KEEPS A BIG GRID

The tile editor's Organize tiles grid could be made only up to 32 tiles
across and down, and opening it on a bigger one, like a whole level laid out
for the map editor's Stamp brush, quietly cut it down to 32 by 32. Now
opening it leaves any grid as it is, and you can make one up to 256 across
and down.

CLOSING THE IDE ON WINDOWS

On a Windows computer that draws with OpenGL instead of Direct3D, the desktop
IDE crashed as it closed. Now it closes cleanly.