VIDEOGAME ISPIRED: BARBARIAN

This example offers the possibility of illustrating how you can manage elements, even large ones, without the need for hardware sprites. In particular, this example uses double buffering and, to have the maximum availability of colors, the artifacts induced by the NTSC television standard.

source compile sandbox issues? back to examples

SOURCE CODE ()

PROCEDURE demo ON COCO

	SCREEN #14 : COLOR #0,#5
	
	CLS			
	
	DOUBLE BUFFER ON	
	
	scenery := LOAD IMAGE("vdg_barbarian_scenery.png")
	character := LOAD ATLAS("vdg_barbarian_character.png") FRAME SIZE(32,64) TRANSPARENCY
	background := NEW IMAGE(32,64)
	
	PUT IMAGE scenery AT 0, 0
	
	SCREEN SWAP
	
	DIM d(FRAMES(character)) AS BYTE
	
	ox# = 49: oy# = 50
	x# = 50: y# = 50
	b# = 0: cd# = 0
	f# = 0
	
	DO
		IF x <> ox OR y <> oy THEN
			IF x > ox THEN cd = 0
			IF x < ox THEN cd = 1
			IF d(f) <> cd THEN
				FLIP X IMAGE character FRAME f
				d(f) = cd
			ENDIF
			IF b THEN
				PUT IMAGE background AT ox, oy
			ENDIF
			b = 1
			GET IMAGE background FROM x,y
			PUT IMAGE character FRAME f AT x, y WITH TRANSPARENCY
			ADD f, 1, 0 TO FRAMES(character)-1
			ox = x: oy = y
			SCREEN SWAP
		ENDIF
		JMOVE ,x,y,10,200,10,180,8,8
	LOOP

END PROCEDURE

	demo[] ON COCO
	

How to compile and run the example

The instructions here refer to compiling the example from the command line. For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile each single example with just one click.



Are instructions for your specific home computer / console missing? First of all, check if your computer is supported by clicking here. If so, since ugBASIC is a language which does not provide abstractions, it is possible that this example will not work on your target. If you think this is an issue, please click here.

TRS-80 Color Computer, TRS-80 Color Computer 2

In order to compile the example, type this command on the command line:

Linux

ugbc.coco -O bin -o vdg_barbarian.bin vdg_barbarian.bas

Windows

ugbc.coco.exe -O bin -o vdg_barbarian.bin vdg_barbarian.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

Any problem?

If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO EXAMPLES