This forms the basis for more or less everything I write - maybe useful?
float scale = 3.5
float tile_size = 8 * scale
game = [
.active = false,
.rows = 24,
.cols = 32
// ... game stuff too...
]
spectrum_buffer = createImage( game.cols * 8, game.rows * 8, false, IMAGE_RGBA )
offset_x = ( gWidth() - ( tile_size * game.cols ) ) / 2
offset_y = ( gHeight() - ( tile_size * game.rows ) ) / 2
loop
if !game.active then
show_splash()
endIf
initialise_variables()
while game.active loop
game_loop()
repeat
// If lives aren't zero then the game was quit prematurely.
if game.player.lives == 0 then
game_over()
endIf
repeat
/**
* Displays the intro/ "Pre-Game" screen.
*/
function show_splash()
while !game.active loop
setDrawTarget( spectrum_buffer )
clear()
// This prints in "Spectrum font" obviously normal printing will be huge here.
// My Spectrum font is 8x8 pixels as per the Spectrum (the "7, 3" is specific for West Bank - the font is double height and has an attribute value for top/ bottom).
spectrum_print( 11, 0, "WEST BANK", 7, 3 )
// etc
c = controls( 0 )
if old_c and !(c.a or c.b or c.x or c.y) then
game.active = true
endIf
old_c = c.a or c.b or c.x or c.y
setDrawTarget( framebuffer )
clear()
drawImage( spectrum_buffer, offset_x, offset_y, scale )
update()
repeat
return void
I've simplified it somewhat for here, but I think that demos enough what I mean.