DYSTOPIANPIXEL

Simple Programme

Start with a short NextBASIC programme that demonstrates how to configure playerControl V1.0.

playerControl Driver artwork
playerControl Driver · V1.0 guide.

Simple Programme

This example installs playerControl, loads player artwork into two RAM banks, transfers it into the hardware sprite-pattern memory, and configures the driver before enabling movement. Each setting uses DRIVER 6,1,id,value: the parameter ID selects the setting, and the final value supplies its new value.

Put playerControl.drv and your sprite files in the programme’s working folder. The example filenames PLAYER_WALK.SPR and PLAYER_CLIMB.SPR stand for your own artwork: eight walking frames and four climbing frames respectively. They are not included in the driver package. Use raw 8-bit 16 × 16 patterns with colours matching the current sprite palette; each pattern occupies 256 bytes, so these files contain 2,048 and 1,024 bytes.

BANK NEW reserves free RAM banks and stores their numbers in walkBank and climbBank. LOAD … BANK fills those banks with the file data. SPRITE BANK then copies the artwork into hardware patterns 0–7 and 8–11. The bank numbers, pattern numbers and hardware sprite number 24 each identify a different part of the setup.

The existing position, speed, jump and keyboard settings are retained. A simple solid bottom row provides collision data, with no ladders or background artwork in this first example. The climbing frames are loaded ready for a level with ladders. Run it with the driver not already installed; use O and P to move, SPACE to jump, M to sprint, and X to finish. Short comments at the start of each section explain the setup and keep the listing easy to read.

10 REM playerControl V1.0 configuration example
20 REM Install the driver; keep movement disabled during setup
30 .install "playerControl.drv"
40 DRIVER 6,1,24,0
45 REM Load walking and climbing artwork into separate free RAM banks
50 SPRITE CLEAR
60 BANK NEW walkBank
70 BANK NEW climbBank
80 LOAD "PLAYER_WALK.SPR" BANK walkBank,0
90 LOAD "PLAYER_CLIMB.SPR" BANK climbBank,0
95 REM Transfer eight walking frames to patterns 0-7 and four climbing frames to 8-11
100 SPRITE BANK walkBank,0,0,8
110 SPRITE BANK climbBank,0,8,4
115 REM Use hardware sprite 24 and match the animation settings to the loaded patterns
120 DRIVER 6,1,26,24
130 DRIVER 6,1,56,0
140 DRIVER 6,1,57,0
150 DRIVER 6,1,58,0
160 DRIVER 6,1,59,8
170 DRIVER 6,1,60,8
180 DRIVER 6,1,61,4
190 REM Start at logical position 56,160; draw the sprite with offsets of +8,+1
200 DRIVER 6,1,32,56
210 DRIVER 6,1,33,160
220 DRIVER 6,1,38,8
230 DRIVER 6,1,39,1
240 REM Set walking, sprinting and normal jump strength; leave super jump disabled
250 DRIVER 6,1,40,6
260 DRIVER 6,1,41,10
270 DRIVER 6,1,50,64
280 DRIVER 6,1,51,0
290 REM Use the default keyboard controls: O/P, Q/A, SPACE and M
300 DRIVER 6,1,70,0
310 REM Clear both collision masks, then make the bottom row solid
315 REM This first example has a floor but no ladders
320 FOR row=0 TO 11
330 DRIVER 6,1,row,0
340 DRIVER 6,1,row+12,0
350 NEXT row
360 DRIVER 6,1,11,65535
370 REM Show the player at normal size and enable movement after all setup is complete
380 SPRITE 24,64,161,0,1,0,0,0
390 SPRITE PRINT 1
400 DRIVER 6,1,24,1
405 REM Keep the programme running while the driver moves the player; press X to finish
410 PRINT "O/P move, SPACE jump, M sprint"
420 PRINT "Press X to finish"
430 PAUSE 1
440 IF INKEY$<>"x" AND INKEY$<>"X" THEN GO TO 430
445 REM Stop player movement and hide the sprites before returning to BASIC
450 DRIVER 6,1,24,0
460 SPRITE PRINT 0
470 STOP

Command reference: NextBASIC · ZX Spectrum Next manual: Time and Motion.