PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
No Result
View All Result
Home Web Dev

How to import arcade fonts as sprites [spectrum]

November 4, 2020
in Web Dev
289 3
How to import arcade fonts as sprites [spectrum]


Here’s a quick tutorial on how to add custom arcade fonts into a ZX Spectrum Next game – either using NextBASIC or assembly.

READER DISCOUNTSave $50 on terminal.training

I’ve published 38 videos for new developers, designers, UX, UI, product owners and anyone who needs to conquer the command line today.

$49 – only from this link

Steps

  1. Visit http://arcade.photonstorm.com – select your font from the dropdown.
  2. Still on the font web site, type out the letters you want, or if you’re comfortable, open the browser’s devtools console and run the the following code in the console:
Array.from({ length: 59 }, (_, i) => 0x20 + i).map(_ => String.fromCharCode(_)).forEach(k => window.keyPress(k));
  1. This will generate all the letters in the Spectrum character set – adjust as you feel fit, but this will map nicely to the CODE "a" NextBASIC routine.
  2. Zoom out the font to fairly small – you want either 16 pixels high or 8 pixels, you might need to try a few times to get it right, then hit “save” to download.
  3. Visit https://zx.remysharp.com/sprites/#importer
  4. Drag your arcade-font-writer.png into the import canvas window.
  5. Align the viewfinder over the first character (I find this easier to align over a whole letter or the # symbol, then use shift+right to move to the first character)
  6. In the “Auto repeat import” section, set the width to 59 (if you have 59 character, or the number of characters you have)
  7. Click “Copy in” and then “Download spritesheet”

Using in NextBASIC

You can use this spritesheet as either individual sprites or as tiles (which keeps your sprites free for more interactive use).

This example code will let me render any character using the Tile features.

First I need to load up the sprite sheet which I’ll store in BANK 15 and I’ll use BANK 16 for the tiling process:

#autoline 10

LAYER 2,1
LOAD "font.spr" BANK 15
TILE DIM 16,0,59,8 :
TILE BANK 15

Now two routines, one to write characters (using the TILE routine) and one to loop through each character to print a line – note that the characters I’m generating exclude the lowercase set, so there’s code to adjust appropriately.

DEFPROC writeLine(l$)
  %x=0
  %l= LEN (l$)
  FOR i=1 TO %l
    PROC writeChar(l$(i))
  NEXT i
  %y=%y+1
ENDPROC

DEFPROC writeChar(c$)
  %i=( CODE c$)-32
  IF %i > 63 THEN %i=%i-32: 
  BANK 16 POKE 0,%i
  TILE 1,1 AT 0,0 TO %x,%y
  %x=%x+1
ENDPROC

Rolled together you can get some nice fonts draw up. You can also switch this around to use it in a sprite for some scrolling effects too.

Download all the files for the NextBASIC example



Source link

Share219Tweet137Share55Pin49

Related Posts

On Auto-Generated Atomic CSS | CSS-Tricks
Web Dev

On Auto-Generated Atomic CSS | CSS-Tricks

Robin Weser’s “The Shorthand-Longhand Problem in Atomic CSS” in an interesting journey through a tricky problem. The point is...

January 15, 2021
How to Add Commas Between a List of Items Dynamically with CSS
Web Dev

3 Approaches to Integrate React with Custom Elements

In my role as a web developer who sits at the intersection of design and code, I am drawn...

January 15, 2021
Community Resources, Weekly Newsletter, And Boosting Skills Online — Smashing Magazine
Web Dev

Smashing Workshops & Audits — Smashing Magazine

About The AuthorJuggling between three languages on a daily basis, Iris is known for her love of linguistics, arts,...

January 15, 2021
4 Lessons Web App Designers Can Learn From Google — Smashing Magazine
Web Dev

The Report — Smashing Magazine

About The AuthorSuzanne Scacca is a former WordPress implementer, trainer and agency manager who now works as a freelance...

January 15, 2021
Next Post
Internationalization And Localization For Static Sites — Smashing Magazine

Internationalization And Localization For Static Sites — Smashing Magazine

Getting the WordPress Block Editor to Look Like the Front End Design

Getting the WordPress Block Editor to Look Like the Front End Design

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Quick Tips for High Contrast Mode

Quick Tips for High Contrast Mode

June 26, 2020

Making Memories To Last (August 2020 Wallpapers Edition) — Smashing Magazine

September 1, 2020
Connection UX improvements in the AWS Toolkit for JetBrains : idk.dev

Connection UX improvements in the AWS Toolkit for JetBrains : idk.dev

September 23, 2020
Block Links: The Search for a Perfect Solution

Block Links: The Search for a Perfect Solution

May 25, 2020

Categories

  • AWS
  • Big Data
  • Database
  • DevOps
  • IoT
  • Linux
  • Web Dev
No Result
View All Result
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In