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. This version does not use the FLIP to invert player direction.
source
compile
sandbox
issues?
back to examples
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_full.png") FRAME SIZE(32,64) TRANSPARENCY
background := NEW IMAGE(32,64)
PUT IMAGE scenery AT 0, 0
SCREEN SWAP
ox# = 49: oy# = 50
x# = 50: y# = 50
b# = 0: cd# = 0
d# = 0
f# = 0: df# = 0
DO
IF x <> ox OR y <> oy THEN
IF x > ox THEN cd = 0
IF x < ox THEN cd = 1
IF d <> cd THEN
IF d = 0 THEN
df = 4
d = 1
ELSE
df = 0
d = 0
ENDIF
ENDIF
IF b THEN
PUT IMAGE background AT ox, oy
ENDIF
b = 1
GET IMAGE background FROM x,y
PUT IMAGE character FRAME df+f AT x, y WITH TRANSPARENCY
ADD f, 1, 0 TO (FRAMES(character)/2)-1
ox = x: oy = y
SCREEN SWAP
ENDIF
JMOVE ,x,y,10,200,10,180,8,8
LOOP
END PROCEDURE
demo[] ON COCO
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.
In order to compile the example, type this command on the command line:
Linux
ugbc.coco -O bin -o vdg_barbarian2.bin vdg_barbarian2.bas
Windows
ugbc.coco.exe -O bin -o vdg_barbarian2.bin vdg_barbarian2.bas
For Microsoft Windows users we suggest using UGBASIC-IDE, which allows
you to download and compile this example with just one click.
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