Jump to content

Recommended Posts

I am trying to change the shape/colour of 1 (floor/wall) character for each level of a game so that each level has a different look.

 

I was hoping to do this by having a character definition for each level via BITMAP or DATA BYTE statements, and then using VARPTR to specify the start-point - but so far all my attempts to achieve this have failed.

 

1. I couldn't work out how to use VARPTR with BITMAP definitions (i.e. how to get the BITMAP data into an array?).

2. I tried to READ BYTE the definitions (i.e. 32 bytes for 4 characters) from a DATA BYTE table into an ARRAY and then specify 'DEFINE CHAR 97,1,VARPTR ARRAY(LevelNum*8)' to load the appropriate definition at the start of each level - but this did not work (the resulting 'a' looked nothing like the data!).

 

Can anyone provide a small example of how this should be done?

Edited by chalkyw64
Change 'A' to 'a'
Link to comment
https://forums.atariage.com/topic/371532-define-charcolor-with-varptr-how/
Share on other sites

It is actually relatively easy.

 

I made this example using two characters redefined between two levels.

 

	'
	' Using VARPTR to redefine graphics for levels
	'
	' by Oscar Toledo G.
	' https://nanochess.org/
	'
	' Creation date: Aug/26/2024.
	'

	level = 1

	WHILE 1

		CLS

		DEFINE CHAR 128,2,VARPTR level_bitmaps((level - 1) * 16)	' Each character is 8 bytes. 2*8 = 16

		DEFINE COLOR 128,2,VARPTR level_colors((level - 1) * 16)	' Each character is 8 bytes. 2*8 = 16

		FOR c = 1 TO 10
			PRINT AT RANDOM(768),"\128"
		NEXT c
		FOR c = 1 TO 10
			PRINT AT RANDOM(768),"\129"
		NEXT c

		FOR c = 1 TO 120: WAIT: NEXT

		level = level + 1

		IF level = 3 THEN level = 1

	WEND

level_bitmaps:
	BITMAP "..XXXX.."
	BITMAP ".X....X."
	BITMAP "X.X..X.X"
	BITMAP "X......X"
	BITMAP "X.X..X.X"
	BITMAP "X..XX..X"
	BITMAP ".X....X."
	BITMAP "..XXXX.."

        BITMAP ".....X.."
	BITMAP "....XXXX"
	BITMAP "XX..X.XX"
	BITMAP ".XXXXXXX"
	BITMAP "..XXXX.."
	BITMAP ".XXXXX.."
	BITMAP ".XX..XX."
	BITMAP ".XX..XX."

	BITMAP "..XXXX.."
	BITMAP ".X....X."
	BITMAP "X......X"
	BITMAP "X.X..X.X"
	BITMAP "X......X"
	BITMAP "X......X"
	BITMAP ".X....X."
	BITMAP "..XXXX.."

        BITMAP "..X..X.."
	BITMAP ".XX..XX."
	BITMAP ".XXXXXX."
	BITMAP ".X.XX.X."
	BITMAP ".XXXXX.X"
	BITMAP "..XXXX.X"
	BITMAP ".XX.XXXX"
	BITMAP ".XX.XXXX"

level_colors:
	DATA BYTE $A1,$A1,$A1,$A1,$A1,$A1,$A1,$A1
	DATA BYTE $31,$31,$31,$31,$31,$31,$31,$31
	DATA BYTE $91,$91,$91,$91,$91,$91,$91,$91
	DATA BYTE $51,$51,$51,$51,$51,$51,$51,$51

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...