VIDEOGAME ISPIRED: INDIANA JONES

This code will draw the opening title of an exploring videogame, inspired by Indiana Jones. With this example we try to outline an isomorphic way of writing programs and designing graphic resources, so that it is easier to port them from one platform to another. The aim, as always, is to guarantee a comparable visual and gaming experience between systems, without giving up the specificities of each.

source compile sandbox issues? back to examples

SOURCE CODE ()

	' We suggest the use the most coloured
	' resolution (up to 16 colors).
	
	BITMAP ENABLE(16)

	' We clear the graphical screen.

	CLS
	
	' Put the color border to BLACK (if border is present)
	
	COLOR BORDER BLACK	

	' Load from the host the (degrated quality of the) image 
	' of the opening titles of the videogame.
	'
	' Note that the original image has been converted to 
	' match at best each target, and moved the result into 
	' each folder with the same target name. In particular:
	'
	'	atari / atarixl : 160x96 pixel, 4 colors
	'	c64 			: 160x200 pixel, 16 colors
	'	coleco          : 256x160 pixel, 16 colors

	titles := LOAD IMAGE("indiana_titles.png")
	
	' Load from the host the (degrated quality of the) image 
	' of the animated sprites of the character.
	
	indiana := LOAD ATLAS("indiana_full.png") FRAME SIZE (32,64)

	' Finally, load from the host the music track, in MIDI
	' format. It will be converted to the native format, as well.
	
	music := LOAD MUSIC("indiana.mid")

' This is a parallel procedure, that is a procedure that
' will be played in a multitasking fashion. Infact,
' it will animate the characted indipendently from
' music and other tasks.

PARALLEL PROCEDURE animateIndiana

	' Let graphical resource of indiana character
	' be accessible inside this procedure.
	SHARED indiana
	
	' This is the current frame to show.
	
	DIM frame AS BYTE
	
	' Start from the first frame.
	
	frame = 0
	PUT IMAGE indiana FRAME frame AT 0, SCREEN HEIGHT - IMAGE HEIGHT(indiana)
	
	' Wait a random time to animate.
	
	WAIT 4000*(1+RND(3)) MS
	
	' Repeat the animation forever.
	
	DO
	
		' Draw a frame on the screen. The character will be
		' drawn at the bottom left of the screeen. The height
		' of the screen and of the image are calculated at
		' compile time.
		
		PUT IMAGE indiana FRAME frame AT 0, SCREEN HEIGHT - IMAGE HEIGHT(indiana)
		
		' Wait some time, to avoid a too fast animation.
		
		WAIT 80 MS
		
		' Move to the next frame.
		
		INC frame
		
		' If animation is finished...
		
		IF frame = ( FRAMES(indiana) - 1 ) THEN
		
			' ... let start from the beginning,
			' and we will wait for a random
			' time, in order to make a more
			' natural animation.
			
			frame = 0
			WAIT 4000*(2+RND(3)) MS
			
		ENDIF
		
	LOOP
	
END PROCEDURE

	' Let start the music!
	
	MUSIC music

	' Put the titles on the screen!
	
	PUT IMAGE titles AT 0, 0
	
	' Start animation!
	
	SPAWN animateIndiana
	
	' The program finishes here, and it does
	' nothing, but it could do anything else,
	' as long as RUN PARALLEL is called.

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.

Atari 400, Atari 800

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

Linux

ugbc.atari -O xex -o vdg_indiana.xex vdg_indiana.bas

Windows

ugbc.atari.exe -O xex -o vdg_indiana.xex vdg_indiana.bas

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

Coleco Vision, Dina (Chuang Zao Zhe 50), SpectraVideo SV-603 VGA

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

Linux

ugbc.coleco -O rom -o vdg_indiana.rom vdg_indiana.bas

Windows

ugbc.coleco.exe -O rom -o vdg_indiana.rom vdg_indiana.bas

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

Commodore 64, Commodore Executive 64

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

Linux

ugbc.c64 -O prg -o vdg_indiana.prg vdg_indiana.bas

Windows

ugbc.c64.exe -O prg -o vdg_indiana.prg vdg_indiana.bas

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

Commodore 64 + REU

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

Linux

ugbc.c64reu -O d64 -o vdg_indiana.d64 vdg_indiana.bas

Windows

ugbc.c64reu.exe -O d64 -o vdg_indiana.d64 vdg_indiana.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